Page 1 of 1

Remove old RRDs

Posted: Thu Nov 13, 2014 4:03 pm
by snapon_admin
Over time we've gotten quite a few RRD files created that are no longer being used. Either the service was deleted, a new plugin was used to perform a specific check, or a service's name was changed at some point. All of these lead to a bunch of RRD files that essentially do nothing on the server but take up space. Is there any way to easily remove the unused RRDs from our system? I've just started looking into this so if there's an easy way to do this that I just haven't found yet I apologize.

Re: Remove old RRDs

Posted: Thu Nov 13, 2014 4:04 pm
by tmcdonald
Sort by date with "find" or "ls" and remove anything with an older timestamp? There's nothing I know of built-in to XI for this.

Re: Remove old RRDs

Posted: Thu Nov 13, 2014 4:38 pm
by jwelch
Digging through my notes on cleaning up old check* files in /tmp.....

Using find to delete files last modified more than 2 days in current directory:
find . -maxdepth 1 -type f -mtime +2 -name "check*" -exec rm {} \;

You could use a version of this to remove the stale rrd files
under /usr/local/nagios/share/perfdata.

cd /usr/local/nagios/share/perfdata
find . -maxdepth 2 -type f -mtime +2 -name "*.rrd" -exec rm {} \;

If you want to get rid of the associated *.xml files (not actively updated),
you could write a script to use the find command without the '-exec rm {} \;'
to generate a list of files, parse the output, and delete the .rrd and .xml files
for each host.

Hopefully, you have decent backups. The dirs/files are owned by nagios, so
running any commands/scripts as nagios should limit the damage when the
system does what you told it to do (but not what you meant).

---
As always, if you or any member of your team is caught or killed,
the Secretary will disavow any knowledge of your actions.
Good Luck,
<Jim>

Re: Remove old RRDs

Posted: Thu Nov 13, 2014 4:51 pm
by abrist
^This. jwlech is absolutely right.

Re: Remove old RRDs

Posted: Thu Nov 13, 2014 11:26 pm
by Box293
snapon_admin wrote:Is there any way to easily remove the unused RRDs from our system?
The Performance Data Tool I created for Nagios XI can do exactly this.

Download from here: http://exchange.nagios.org/directory/Ad ... ol/details

Upload through Admin > System Extensions > Manage Components

The tool is located under the Tools menu.
Click the Delete tab
Select the perfdata folder you want
Change the Date Filter
Select the files and select an action next to the Perform Action button