X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/a23861f3d22a827bc1d4676832c7174e24de53df..de5ea0729bd1f982f7fda34729d149d9a40766b9:/cookbooks/munin/files/default/rrddump.sh?ds=inline diff --git a/cookbooks/munin/files/default/rrddump.sh b/cookbooks/munin/files/default/rrddump.sh index ba7e42f94..08942038e 100644 --- a/cookbooks/munin/files/default/rrddump.sh +++ b/cookbooks/munin/files/default/rrddump.sh @@ -2,16 +2,32 @@ RRD_DIR=/var/lib/munin/openstreetmap DIR=`mktemp -d` -NPROCS=8 +DUMP_DIR=/srv/munin.openstreetmap.org/dumps +TARGET_TGZ=`date "+munin-data-%Y-%m-%d.tar.gz"` +KEEP_OLD_COUNT=3 function cleanup { -rm -rf "$DIR" + rm -rf "$DIR" } trap cleanup EXIT +set -e + 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 - +find -name "*.xml" -print0 | tar zcf "dump.tar.gz" --null -T - + +# if we got here, then the file was created okay so we're okay to delete any +# old files. +find "${DUMP_DIR}" -name "munin-data-*.tar.gz" -print0 | \ + sort -z -r | \ + tail -z -n "+${KEEP_OLD_COUNT}" | \ + xargs --null rm -f + +mv dump.tar.gz "${DUMP_DIR}/${TARGET_TGZ}"