Share, , Google Plus, Pinterest,


Posted in:

Pnp4nagios data migration – convert RRD to XML

A while ago i wrote an article about Nagios migration to a new Linux server. This project also included migration of Pnp4nagios data. Since i was migrating Nagios to a new architecture (i386 -> x86_64) i had to convert RRD files to XML, transfer them to the new server and convert them back from XML to RRD. Since i successfully completed the project and got the past data to be seen on the new server (including the new data of course!) i decided to write an article on Pnp4nagios data migration. In case you are migrating your Pnp4nagios data to the same architecture and even the same Pnp4nagios version you shouldn’t have any problems, just transfer the RRD files and restart Nagios and Apache service.

For information on how to install Pnp4nagios please read Pnp4Nagios CentOS install!

Pnp4nagios graph
Pnp4nagios graph

Let’s start our Pnp4nagios data migration How To guide!

1. Install RRDTool

Install RRDTool package on both machines – if it is not already installed.

[root@foo1&2 ~]# /usr/bin/yum install rrdtool -y

2. Convert RRD files to XML

Convert RRD files to XML with RRD command (if you have alot of files download my rrd2xml conversion script at the bottom of this post!).

[root@foo1 ~]#/usr/bin/rrdtool dump file.rrd file.rrd.xml

3. Transfer XML files

Transfer all of the XML files to the desired destination. You can do that via scp or rsync command – i chose rsync for this job (you can use my XML migration script to do that…).

[root@foo1 ~]# /usr/bin/rsync -avr file.rrd.xml user@destination:/desired/folder

4. Convert XML back to RRD

On the destination machine convert the XML file back to RRD with RRDTool command. Of course the file.rrd must not exist on the destination machine for conversion to succeed (you can use my xml2rrd conversion script…).

[root@foo2 ~]# /usr/bin/rrdtool restore file.rrd.xml file.rrd

5. UPDATED: Chown RRD files

Don’t forget to chown all of your rrd files to nagios user!

[root@foo2 ~]# /bin/chown -R nagios:nagios /your/rrd/dir

6. Restart services

Restart both Nagios and Apache services and wait a couple of minutes.

[root@foo2 ~]# /etc/init.d/nagios restart
[root@foo2 ~]# /etc/init.d/httpd restart

In a couple of minutes you should see all of the configured resources and of course their past and current data in a RRD graph.

  • Tongai

    Hi there.

    I ran the script and it goes thru the rrdtool dump process and at the end it say its done, but I do not see the *xml files.

    please help



    • Mitch

      Hello Tongai and thanks for your question. What does the rrd2xml-convert.log say? Does the line “Dumping #filename# to XML file.” hold the RRD filename? Something like this: Dumping /usr/local/pnp4nagios/var/perfdata/localhost/_HOST_.rrd to XML file.

    • Mitch

      Oh Yeah, i remembered one more thing – what is the owner of the RRD files you are trying to convert and which user is running the script? The user that is running the script must have full acces to the RRD files!! Hope this helps you solve your problem. Regards, Mitch

  • Pingback: Nagios migration to a new Linux server | GeekPeek.Net()

  • Rob

    Great post, thanks! The migration script could use some work, however. I had over 6700 rrd files that I needed to be migrated. The migration script prompted me for the password for each file it copied. No way was I going to enter it 6700 time! Regardless, your post here was of very much help!

    • Mitch

      Hello Rob! The migration script should setup SSH key no password authentication and shouldn’t prompt you for password everytime. Anyway i hope you configured it manually or found another way to solve it. I hope the migration was successfull in the end!