Re: [rrd-users] Dump and rebuild and restore XML with perl

This is a discussion on Re: [rrd-users] Dump and rebuild and restore XML with perl within the RRD Users forums, part of the Networking and Network Related category; --===============0300802457== Content-Type: multipart/alternative; boundary="----=_Part_1612_7883414.1205273000752" ------=_Part_1612_7883414.1205273000752 Content-Type: text/plain; charset=ISO-8859-1 ...


Go Back   Usenet Forums > Networking and Network Related > RRD Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-11-2008
0xception
 
Posts: n/a
Default Re: [rrd-users] Dump and rebuild and restore XML with perl

--===============0300802457==
Content-Type: multipart/alternative;
boundary="----=_Part_1612_7883414.1205273000752"

------=_Part_1612_7883414.1205273000752
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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@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.
>


------=_Part_1612_7883414.1205273000752
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I think i have found my own problem... but not a solution (other then starting all over with a new perl script)...<br><br>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. <br>
<br>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. <br>
<br><br><br><div class="gmail_quote">On Mon, Mar 10, 2008 at 2:16 PM, 0xception &lt;<a href="mailto:0xception@gmail.com">0xception@gmail. com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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. <br>
<br>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<br>
<br><i>&nbsp;&nbsp; 'ERROR: Incompatible file version, detected version . This is not supported by the version 0003 restore tool.</i>'<br><br>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. <br>
<br>Original XML:<br><a href="https://www.ondashboard.com/origional.xml" target="_blank">https://www.ondashboard.com/origional.xml</a><br><br>Modified XML:<br><a href="https://www.ondashboard.com/modified.xml" target="_blank">https://www.ondashboard.com/modified.xml</a><br>

<br>Part of the Perl Script:<br><br><div style="margin-left: 40px;">&nbsp;&nbsp;&nbsp; # read XML file<br>&nbsp;&nbsp;&nbsp; my $data = $xml-&gt;XMLin(&quot;dump.xml&quot;);<br><br>&nbsp;&nbs p;&nbsp; $data-&gt;{step} = 600;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; my @xml;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; for my $rra ( @{ $data-&gt;{rra} } ) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; my $lcv=0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; my @new;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp; # Loop through database and remove every other entry.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for my $value ( @{ $rra-&gt;{database}-&gt;{row} } ) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if($lcv % 2 == 0 || $lcv == 0) {<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; push(@new, \%$value); &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $lcv++;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; # Append XML with new Database<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $rra-&gt;{database}-&gt;{row} = \@new;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; push(@xml, $rra);<br>

&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $data-&gt;{rra} = \@xml;<br><br>&nbsp;&nbsp;&nbsp; # Export the perl structure into XML<br>&nbsp;&nbsp;&nbsp; XMLout($data, &nbsp;&nbsp;&nbsp; OutputFile =&gt; $file.&quot;.xml&quot;,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RootName =&gt; 'rrd',<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; NoAttr =&gt; 1);<br>

</div><br><br><br><br>Thanks.<br>
</blockquote></div><br>

------=_Part_1612_7883414.1205273000752--


--===============0300802457==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
rrd-users mailing list
rrd-users@lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

--===============0300802457==--

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:07 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0