[rrd-users] Dump and rebuild and restore XML with perl
0xception
0xception at gmail.com
Tue Mar 11 23:03:20 CET 2008
I think i have found my own problem... but not a solution (other then
starting all over with a new perl script)...
It would seem, and correct me if i'm wrong, that the rrdtool restore
requires the XML elements to be ordered. When the XML::Simple reads in and
exports to XML the order of the original XML is lost and exported in
alphebetical order. Maybe this could be considered a bug maybe it's by
design of the rrd tool. either way i'm not sure if there are any explicit
specification in XML 1.0 on element ordering.
I dont believe XML::Simple perl module can maintain the origional order of
the XML it reads in... so i'll have to find another module or another way to
rebuilding the XML file if i wasn to get around this. But just to add my
opinion, i think it would make the tool more versitail if it was not
dependend on the order of the XML.
On Mon, Mar 10, 2008 at 2:16 PM, 0xception <0xception at gmail.com> wrote:
> Hello, I'm currently working with several hundred RRD files and a large
> chunk have the incorrect step and heartbeat .they were setup with a step of
> 300 and heartbeat of 900 where i would like to change them to 600 and 1800.
> I've read that in order to accomplish this you need to dump the database
> into XML with the rrdtool dump command and then alter the XML files
> (adding/removing data points, and updating the settings) and then restore
> the database from the modified XML, please correct me if i'm wrong about
> that.
>
> Anyway I've created a Perl script to dump to XML, read in the XML and
> change the values of heartbeat and step and then remove every other data
> collection point to be inline with the step of 600 sec. I then rebuild the
> XML and save that to a file. The new XML file does not have any comments but
> contains everything else. When i try and restore the database from this XML
> file i get the error
>
> * 'ERROR: Incompatible file version, detected version . This is not
> supported by the version 0003 restore tool.*'
>
> returned. I've looked through the modified XML file and i don't see
> anything different, other then the order the tags are listed in the file.
> could this cause a problem? or could the lack of comments cause a problem?
> I'm also using the same version of rrdtool to dump as i am to restore the
> database, RRDtool 1.2.23.
>
> Original XML:
> https://www.ondashboard.com/origional.xml
>
> Modified XML:
> https://www.ondashboard.com/modified.xml
>
> Part of the Perl Script:
>
> # read XML file
> my $data = $xml->XMLin("dump.xml");
>
> $data->{step} = 600;
>
> my @xml;
>
> for my $rra ( @{ $data->{rra} } ) {
> my $lcv=0;
> my @new;
>
> # Loop through database and remove every other entry.
> for my $value ( @{ $rra->{database}->{row} } ) {
> if($lcv % 2 == 0 || $lcv == 0) {
> push(@new, \%$value);
> }
> $lcv++;
> }
>
> # Append XML with new Database
> $rra->{database}->{row} = \@new;
> push(@xml, $rra);
> }
>
> $data->{rra} = \@xml;
>
> # Export the perl structure into XML
> XMLout($data, OutputFile => $file.".xml",
> RootName => 'rrd',
> NoAttr => 1);
>
>
>
>
> Thanks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20080311/61990db0/attachment.html
More information about the rrd-users
mailing list