Hi,
I'm attempting to create a perl script that will modify a series of RRD databases (a couple hundred of them). in order to do this the RRD database can be exported to XML modified and then restored from XML.
My issue is when using XML::Simple to read in and edit the xml structure and then output it back out the section of XML that was
previously:
-
<cdp_prep>
-
<ds>
-
<primary_value>8.2156307858e+03</primary_value>
-
<secondary_value>8.2156307858e+03</secondary_value>
-
<value> NaN </value>
-
<unknown_datapoints> 0 </unknown_datapoints>
-
</ds>
-
</cdp_prep>
-
becomes:
-
-
<cdp_prep>
-
<name>ds</name>
-
<primary_value> 8.2156307858e+03 </primary_value>
-
<secondary_value> 8.2156307858e+03 </secondary_value>
-
<unknown_datapoints> 0 </unknown_datapoints>
-
<value> NaN </value>
-
</cdp_prep>
-
the ds tags are no longer there and are instead turned into a new tag called name with a value of ds.
here's a bit of the perl that's doing the altering of the xml files
-
-
# read XML file
-
my $data = $xml->XMLin("dump.xml");
-
$data->{step} = 600;
-
-
my @xml;
-
-
for my $rra ( @{ $data->{rra} } ) {
-
my $lcv=0;
-
my @new;
-
-
for my $value ( @{ $rra->{database}->{row} } ) {
-
if($lcv % 2 == 0 || $lcv == 0) {
-
push(@new, \%$value);
-
}
-
$lcv++;
-
}
-
-
$rra->{database}->{row} = \@new;
-
push(@xml, $rra);
-
}
-
-
$data->{rra} = \@xml;
-
-
XMLout($data, OutputFile => $file.".xml", RootName => 'rrd', NoAttr => 1);
-
I've been looking around for a while now and don't understand what the problem is. There is however another ds tag higher up in the hierarchy...
Original XML:
-
-
<ds>
-
<name> ds0 </name>
-
<type> DERIVE </type>
-
<minimal_heartbeat> 900 </minimal_heartbeat>
-
<min> 0.0000000000e+00 </min>
-
<max> NaN </max>
-
-
<!-- PDP Status -->
-
<last_ds> 1808321630 </last_ds>
-
<value> 3.3702190024e+06 </value>
-
<unknown_sec> 0 </unknown_sec>
-
</ds>
-
-
<!-- Round Robin Archives -->
-
<rra>
-
<cf> AVERAGE </cf>
-
<pdp_per_row> 1 </pdp_per_row> <!-- 300 seconds -->
-
<params>
-
<xff> 5.0000000000e-01 </xff>
-
</params>
-
<cdp_prep>
-
<ds>
-
<primary_value> 8.2156307858e+03 </primary_value>
-
<secondary_value> 8.2156307858e+03 </secondary_value>
-
<value> NaN </value>
-
<unknown_datapoints> 0 </unknown_datapoints>
-
</ds>
-
</cdp_prep>
-
... etc
-
I could use any help or suggestions or reading materials anyone could suggest on this.
Thanks