Can you safely delete the .rrd file?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
linuser
Posts: 102
Joined: Fri Sep 18, 2015 9:53 am

Can you safely delete the .rrd file?

Post by linuser »

I was successfully graphing the performance data in pnp4nagios for all of our dhcp pools. I had 3 "datasources" originally. I had to remove one of them from the script that nagios checks on the server itself. Which left me at 2. After doing so, Pnp4nagios has stopped graphing. In nagios web GUI itself the correct perf data is coming though. I have restarted nagios to no avail.

The performance data line shows:

Code: Select all

Performance Data:	dhcpmarket1=45.1% dhcpmarket2=81.1%
In pnp4nagios web GUI, I see the 2 datasources, (dhcpmarket1 and dhcpmarket2) and even though its stopped graphing, my last, max, and average numbers are still populating on chart, but not on the graph. However its only doing this on my first datasource. On my second datasource my last, max, and avg numbers are zero'ed out, and nothing on the graph. So slightly different behavior on that one.

So I am looking at my .xml file on the nagios server itself. I see something that *may* be the problem but am not sure.
It only shows 2 datasources, but I see this:

Code: Select all

<RRD>
    <RC>1</RC>
    <TXT>/var/lib/pnp4nagios/server/DHCPD-Stats.rrd: expected 3 data source readings (got 3) from 1466712086</TXT>
  </RRD>
So I am wondering why its expecting 3 when I actually have 2. This is why I ask is it safe to delete the corresponding .rrd file and let it rebuild, or if thats not possible how can I fix this?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Can you safely delete the .rrd file?

Post by tgriep »

You could delete the xml and rrd file and they will rebuild themselves with the correct data but you will lose the history for that check.
If you want to keep the history, you can look at this KB article for rebuilding those files while keeping the history.
https://support.nagios.com/kb/article.php?id=497
Be sure to check out our Knowledgebase for helpful articles and solutions!
linuser
Posts: 102
Joined: Fri Sep 18, 2015 9:53 am

Re: Can you safely delete the .rrd file?

Post by linuser »

Ok, that fixed it. Thanks.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Can you safely delete the .rrd file?

Post by tgriep »

Your welcome. Shall we close and lock up this post?
Be sure to check out our Knowledgebase for helpful articles and solutions!
linuser
Posts: 102
Joined: Fri Sep 18, 2015 9:53 am

Re: Can you safely delete the .rrd file?

Post by linuser »

One more question. That KB article talks only about removing a datasource. Will adding datasources cause these same issues for the .xml and .rrd files? If so is there a KB article on how to add a datasource without losing historical data?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Can you safely delete the .rrd file?

Post by tgriep »

Yes, adding a data source will cause the same issue and here is an article to fix that.
https://support.nagios.com/kb/article.php?id=149
Be sure to check out our Knowledgebase for helpful articles and solutions!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Can you safely delete the .rrd file?

Post by ssax »

You can always follow this method to remove a datasource from the RRD as well and keep your existing data:

The reason why this is not working is because you changed the command which changed the perfdata information.

This the RRD file is expecting two parameters (called datasources) because that is what it was originally built with:

Code: Select all

    cpu_usagemhz=1160.00Mhz;; cpu_usage=3.62%;;
When you modified the check command it removed the cpu_usagemhz datasource so it's only trying to insert one datasource value now when the RRD is expecting two, which causes an error and will not insert the data.

You can remove the RRD and XML files for this service in /usr/local/nagios/share/perfdata/HOSTNAME/ so that it can rebuild them if you don't care about the historical data.

Note: You will lose all historical performance graph information for this service if you delete those files.

The only ways to get it graphing again WITHOUT losing the historical data would be to change the command back to what it was before OR follow this sweet guide that I wrote:

How to delete a datasource from an RRD

Here is how I did it:

First, open up the /usr/local/nagios/share/perfdata/HOSTNAME/SERVICE.xml file and find the <DS>NUMBER</DS> entry (this means data source number) for the one you want to remove.

Code: Select all

      <DATASOURCE>
        <TEMPLATE>check_isis</TEMPLATE>
        <RRDFILE>/usr/local/nagios/share/perfdata/UVN-DCD-SD02/Performance_Data.rrd</RRDFILE>
        <RRD_STORAGE_TYPE>SINGLE</RRD_STORAGE_TYPE>
        <RRD_HEARTBEAT>8460</RRD_HEARTBEAT>
        <IS_MULTI>0</IS_MULTI>
        <DS>4</DS>
        <NAME>MESSAGESPS</NAME>
        <LABEL>MESSAGESPS</LABEL>
        <UNIT></UNIT>
        <ACT>2324</ACT>
        <WARN></WARN>
        <WARN_MIN></WARN_MIN>
        <WARN_MAX></WARN_MAX>
        <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
        <CRIT></CRIT>
        <CRIT_MIN></CRIT_MIN>
        <CRIT_MAX></CRIT_MAX>
        <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
        <MIN></MIN>
        <MAX></MAX>
      </DATASOURCE>
Since you want to remove MESSAGESPS we can see that the DS number is 4.

Then remove the MESSAGEPS from the script/plugin/perfdata output.

Run these commands to install the tool that we will use to delete the data source:

Code: Select all

cd /tmp
wget "http://downloads.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz?r=&ts=1452788875&use_mirror=iweb" -O /tmp/pnp4nagios-0.6.25.tar.gz
tar zxf /tmp/pnp4nagios-0.6.25.tar.gz
cd /tmp/pnp4nagios-0.6.25
./configure
make all
cp /tmp/pnp4nagios-0.6.25/scripts/rrd_modify.pl /root/scripts/
chmod +x /root/scripts/rrd_modify.pl
Run these commands to delete the data source:
*** NOTE: Make sure to change DATASOURCENUM, HOSTNAME, and SERVICENAME to the proper values.
*** NOTE: SERVICENAME should be changed to the actual service name from the filename (validate what it should be, it may differ from what you have set in Nagios)

Code: Select all

/root/scripts/rrd_modify.pl /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd delete DATASOURCENUM
mv /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd.bak
mv /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd.chg /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd
chown nagios.nagios /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd
chmod 775 /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.rrd
Now it should start graphing properly when the new checks come in (may take 15 to 20 minutes).
linuser
Posts: 102
Joined: Fri Sep 18, 2015 9:53 am

Re: Can you safely delete the .rrd file?

Post by linuser »

Great! We can close this one out.
linuser
Posts: 102
Joined: Fri Sep 18, 2015 9:53 am

Re: Can you safely delete the .rrd file?

Post by linuser »

Hey I am getting "you are not authorized to read this forum" message on that last link.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Can you safely delete the .rrd file?

Post by tgriep »

That link points to the customer side of the forums and your login doesn't have access to it.
The link I sent should work for you so give it a try and let us know how it works.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked