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!
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
[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
[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.