]> git.openstreetmap.org Git - chef.git/commitdiff
Merge pull request #109 from zerebubuth/munin-dump
authorMatt Amos <zerebubuth@gmail.com>
Tue, 24 Jan 2017 11:36:17 +0000 (11:36 +0000)
committerGitHub <noreply@github.com>
Tue, 24 Jan 2017 11:36:17 +0000 (11:36 +0000)
Downloadable munin data

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 a03b7d684a7321f6326656761119889c5f5aa840..d4f8cb04703645c4f2502c684a0ecb10febee76d 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"`