Sometimes arises the wish to delete some broken datasets from RRD files.
This is not possible out-of-the-box by design. But there are the rrdtool dump/restore
commands.
The interchange format is XML. So the idea is to modify the XML before restoring it.
There are two little deficiencies with the XML. It's not documented and some useful information is provided by XML comments instead of be part of the XML itself. This makes XSLT processing difficult.
Here are some XSLT transformations, that are trying to handle the deletion of some datasets and producing a new working RRD file.
rrdtool dump $rrd.corrupt |\
xsltproc rrd.dump.clean.xslt - |\
xsltproc rrd.dump.modify.xslt - |\
xsltproc rrd.dump.reorder.xslt - |\
xmllint --format - |\
rrdtool restore - $rrd.new
-
rrd.dump.clean.xslt
- pulls time information from XML comments to attributes, notably for
<row/>
- removes all XML comments
- pulls time information from XML comments to attributes, notably for
-
rrd.dump.modify.xslt
- sets lastupdate time and removes all RRA datasets beyond
- sets lastupdate values to
NaN
because the real value is lost - deletes
<cdp_prep/>
because its not documented (seems rrdrestore 1.4.7. doesn't care about that)
-
rrd.dump.reorder.xslt
- moves the removed datasets to head of RRA