mrtg.conf cleanup

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
kunsjef
Posts: 3
Joined: Wed Feb 27, 2013 9:04 am

mrtg.conf cleanup

Post by kunsjef »

I have deleted a lot of hosts and services from my Nagios XI. This works fine, but my /etc/mrtg/mrtg.conf still has all the graph definitions for the hosts. Shouldn't mrtg.conf be cleaned up automatically after such a deletion, or is this supposed to be a manual task?

Thanks,
Thomas
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: mrtg.conf cleanup

Post by slansing »

This is not something which MTRG does not currently do, in the Adding Services to Preexisting Switch or Router it shows that you will want to reconfigure MRTG when devices are added or removed:

http://assets.nagios.com/downloads/nagi ... Router.pdf

This is something we are developing to automated and added to a future release of XI.
kunsjef
Posts: 3
Joined: Wed Feb 27, 2013 9:04 am

Re: mrtg.conf cleanup

Post by kunsjef »

Ok. That does not scale as well as I had hoped. I look forward to the automated version! ;)
kunsjef
Posts: 3
Joined: Wed Feb 27, 2013 9:04 am

Re: mrtg.conf cleanup

Post by kunsjef »

For those interested; I had to remove about 3000 entries from my mrtg.conf, and I did it all with sed. What I did does not remove the commented out descriptions and leaves some blank lines, but this can also easily be removed by sed if you want to. Here is what I did:

First a basic explanation on how to use sed to remove everything between PATTERN1 and PATTERN2:
$ sed '/PATTERN1/,/PATTERN2/d' mrtg.conf > mrtg.conf.clean

I want to remove everything between the Target[1.2.3.4] statement and the </div> HTML-tag:
$ sed '/Target\[1.2.3.4/,/<\/div>/d' mrtg.cfg > mrtg.cfg.clean

I had to escape the / and [ characters by using the backslash - that is why this may seem complicated at first glance. If you see past the escaping, it is pretty straight forward. I have simply replaced PATTERN1 with Target[1.2.3.4 and PATTERN2 with </div>. This creates a new file named mrtg.cfg.clean. Check if the file is ok, and copy it over your existing mrtg.cfg.

Hope this helps! :)
Locked