From: octo Date: Sat, 22 Apr 2006 09:38:55 +0000 (+0000) Subject: Added `contrib/add_rra.sh' which allows to add an very detailed RRA to old RRD files. X-Git-Tag: svn-trunk~52 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=75687920dd15af4524e68b9b43d687dff74b45c9;p=collectd.git Added `contrib/add_rra.sh' which allows to add an very detailed RRA to old RRD files. --- diff --git a/contrib/add_rra.sh b/contrib/add_rra.sh new file mode 100755 index 00000000..c9306b05 --- /dev/null +++ b/contrib/add_rra.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +INPUT=$1 +OUTPUT=$2 + +if [ -z "$INPUT" -o -z "$OUTPUT" ] +then + cat < +USAGE + exit 1 +fi + +if [ ! -e "$INPUT" ] +then + echo "No such file: $INPUT" + exit 1 +fi + +if [ -e "$OUTPUT" ] +then + echo "File exists: $OUTPUT" + exit 1 +fi + +NUM_DS=0 +rrdtool dump "$INPUT" | while read LINE +do + echo "$LINE" + + if [ "$LINE" = "" ] + then + NUM_DS=$(($NUM_DS + 1)) + fi + + if [ "$LINE" = "" ] + then + for CF in MIN MAX AVERAGE + do + cat < + $CF + 1 + 0.0000000000e+00 + + +RRA + for ((i=0; i < $NUM_DS; i++)) + do + echo " NaN 1 " + done + echo " " + echo " " + + DS_VALUES=`for ((i=0; i < $NUM_DS; i++)); do echo -n " NaN "; done` + for ((i=0; i < 2200; i++)) + do + echo " $DS_VALUES" + done + echo " " + echo " " + done + fi +done >"$OUTPUT.xml" + +rrdtool restore "$OUTPUT.xml" "$OUTPUT" -r >/dev/null +rm -f "$OUTPUT.xml"