2009-08-21

Removing data from rrdtool files

We benchmarked our new SQL-server and caused a nasty peak in Munin graphs. The peaks really made the graps quite useless as the new information was flattened to the very bottom of the graph.

Nulling days of data was quite easy as rrdtool has dump and restore commands.

root@foo:/var/lib/munin/example.tld# for i in foo.example.tld-* ; do
rrdtool dump $i > /tmp/foo.xml &&\
awk -f /tmp/fix.awk /tmp/foo.xml > /tmp/bar.xml &&\
rrdtool restore -f /tmp/bar.xml $i
done

The /tmp/fix.awk awk script changes sample values to NaN which rrdtool regards as empty samples.

$2=="2009-08-20" || $2=="2009-08-21" {
$9="NaN";
}

{
print $0;
}

No comments: