From: Matt Amos Date: Tue, 24 Jan 2017 12:45:07 +0000 (+0000) Subject: Touch XML files to reflect date of original RRD file. Don't run dump in parallel... X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/11fdc9157c3243a489cd1c5f05b1abd686952555 Touch XML files to reflect date of original RRD file. Don't run dump in parallel. Only keep latest 3 files, delete older ones. --- diff --git a/cookbooks/munin/files/default/rrddump.sh b/cookbooks/munin/files/default/rrddump.sh index ba7e42f94..7e54630bc 100644 --- a/cookbooks/munin/files/default/rrddump.sh +++ b/cookbooks/munin/files/default/rrddump.sh @@ -2,16 +2,18 @@ RRD_DIR=/var/lib/munin/openstreetmap DIR=`mktemp -d` -NPROCS=8 function cleanup { -rm -rf "$DIR" + rm -rf "$DIR" } trap cleanup EXIT cd "$RRD_DIR" -find -name "*.rrd" -print0 | xargs --null --max-procs=$NPROCS -I {} rrdtool dump {} "$DIR/{}.xml" +for f in *.rrd; do + rrdtool dump "$f" "$DIR/${f}.xml" + touch -r "$f" "$DIR/${f}.xml" +done cd "$DIR" find -name "*.xml" -print0 | tar zcf - --null -T - diff --git a/cookbooks/munin/templates/default/rrddump.cron.erb b/cookbooks/munin/templates/default/rrddump.cron.erb index 289fde65b..604917336 100644 --- a/cookbooks/munin/templates/default/rrddump.cron.erb +++ b/cookbooks/munin/templates/default/rrddump.cron.erb @@ -1,3 +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"` +# do the dump in the early hours of the morning and follow, if successful, by a cleanup of the old files. i don't think these are of any historical interest, so just keep three consecutive. +43 3 * * * www-data nice /usr/local/bin/rrddump > /srv/munin.openstreetmap.org/dumps/`date "+munin-data-%Y-%m-%d.tar.gz"` && ls -1 /srv/munin.openstreetmap.org/dumps/munin-data-*.tar.gz | sort -r | tail -n +4 | xargs rm -f