Add simple script to dump munin data from RRD to XML and tar it up somewhere download...
authorMatt Amos <zerebubuth@gmail.com>
Mon, 23 Jan 2017 18:13:09 +0000 (18:13 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 23 Jan 2017 18:13:09 +0000 (18:13 +0000)
cookbooks/munin/files/default/rrddump.sh [new file with mode: 0644]
cookbooks/munin/recipes/server.rb
cookbooks/munin/templates/default/rrddump.cron.erb [new file with mode: 0644]

diff --git a/cookbooks/munin/files/default/rrddump.sh b/cookbooks/munin/files/default/rrddump.sh
new file mode 100644 (file)
index 0000000..ba7e42f
--- /dev/null
@@ -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 -
index a03b7d6..d4f8cb0 100644 (file)
@@ -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 (file)
index 0000000..289fde6
--- /dev/null
@@ -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"`