Convert pnp4nagios graph data from one linux machine to another


Following steps used to convert pnp4nagios data between linux servers (32 bit to 64 bit)

Step 1: Check whether rrdtool is installed on source machine

[root@server.local ~]# which rrdtool
/usr/bin/rrdtool

If rrdtool package is not installed then please install using below commands

[root@server.local ~]# yum install rrdtool

Step 2: Convert RRD data to XML

[root@server.local ~]# /usr/bin/rrdtool dump stats.rrd stats.xml

Step 3: Transfer XML file

Transfer the XML files to the destination machine (using scp/rsync commands)

[root@server.local ~]# scp stats.xml root@client.local:/usr/local/pnp4nagios/var/perfdata/testserver/

Step 4: Convert XML file to RRD

On destination machine convert the XML file back to RRD with RRDtool command

[root@client.local ~]# /usr/bin/rrdtool restore stats.xml stats.rrd

[root@client.local ~]# chown -R nagios:nagios /usr/local/pnp4nagios/var/perfdata

Step 5: Restart nagios and apache services

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

That’s it.

If you want to convert large no. of rrd file to xml then please make use of the below commands

[root@server.local ~]# for i in `find -name "*.rrd"`; do rrdtool dump $i > $i.xml; done

[root@client.local ~]# for i in `find -name "*.xml"`; do rrdtool restore $i `echo $i |sed s/.xml//g`; done