From: Matt Amos Date: Tue, 24 Jan 2017 11:36:17 +0000 (+0000) Subject: Merge pull request #109 from zerebubuth/munin-dump X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/a23861f3d22a827bc1d4676832c7174e24de53df?hp=5fc84c735995f7cf765ed1d5bc7f50a198b2a199 Merge pull request #109 from zerebubuth/munin-dump Downloadable munin data --- diff --git a/cookbooks/munin/files/default/rrddump.sh b/cookbooks/munin/files/default/rrddump.sh new file mode 100644 index 000000000..ba7e42f94 --- /dev/null +++ b/cookbooks/munin/files/default/rrddump.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +RRD_DIR=/var/lib/munin/openstreetmap +DIR=`mktemp -d` +NPROCS=8 + +function cleanup { +rm -rf "$DIR" +} + +trap cleanup EXIT + +cd "$RRD_DIR" +find -name "*.rrd" -print0 | xargs --null --max-procs=$NPROCS -I {} rrdtool dump {} "$DIR/{}.xml" + +cd "$DIR" +find -name "*.xml" -print0 | tar zcf - --null -T - diff --git a/cookbooks/munin/recipes/server.rb b/cookbooks/munin/recipes/server.rb index a03b7d684..d4f8cb047 100644 --- a/cookbooks/munin/recipes/server.rb +++ b/cookbooks/munin/recipes/server.rb @@ -81,7 +81,13 @@ remote_directory "/srv/munin.openstreetmap.org" do files_owner "root" files_group "root" files_mode 0o644 - purge true +end + +# directory to put dumped files in +directory "/srv/munin.openstreetmap.org/dumps" do + owner "www-data" + group "www-data" + mode 0o755 end apache_site "munin.openstreetmap.org" do @@ -95,6 +101,21 @@ template "/etc/cron.daily/munin-backup" do mode 0o755 end +# simple shell script to dump RRD data to a file +cookbook_file "/usr/local/bin/rrddump" do + source "rrddump.sh" + owner "root" + group "root" + mode 0o755 +end + +template "/etc/cron.d/rrddump" do + source "rrddump.cron.erb" + owner "root" + group "root" + mode 0o755 +end + munin_plugin "munin_stats" munin_plugin "munin_update" munin_plugin "munin_rrdcached" diff --git a/cookbooks/munin/templates/default/rrddump.cron.erb b/cookbooks/munin/templates/default/rrddump.cron.erb new file mode 100644 index 000000000..289fde65b --- /dev/null +++ b/cookbooks/munin/templates/default/rrddump.cron.erb @@ -0,0 +1,3 @@ +MAILTO=zerebubuth@gmail.com +# do the dump in the early hours of the morning +43 3 * * * www-data nice /usr/local/bin/rrddump > /srv/munin.openstreetmap.org/dumps/`date "+munin-data-%Y-%m-%d.tar.gz"`