Page 1 of 1
Monitoring switches without the Wizard
Posted: Tue Mar 06, 2018 5:26 pm
by Matthew.Cary
In our environment I have all my Servers and Webpages setup with host templates connected to contact and host groups so as new servers are added I can just apply the appropriate templates and away we go.
We are now looking to add Switch/Router monitoring. I can run the XI wizard and get monitoring working that way just fine, but I'd normally avoid the wizards in favor of templates. As such, I'd like too use the same template based setup for these routers. This *mostly* works but it looks like the bandwidth on individual ports use a MRTG setup that is created by the wizard.
Is there a guide anywhere on how to do this outside the wizard? Or another way to graph bandwidth without needing to run a wizard for each switch/router? There are hundreds in my environment.....
Re: Monitoring switches without the Wizard
Posted: Wed Mar 07, 2018 12:49 pm
by npolovenko
Hi,
@Matthew.Cary.
Yes, the Switch/Router wizard is unique in a way that It not only creates service and host definitions but also it creates a new mrtg config in /etc/mrtg/conf.d/ folder. Here is the way Nagios gets the Bandwidth data: MRTG daemon looks into the config file in the /etc/mrtg/conf.d/ folder, gets the data from the Router or Switch and saves it into the RRD file in /var/lib/mrtg/ folder. Then, Nagios pulls the info from the RRD file and displays it in the GUI.
So In order to automate the process of adding new routers, you need to find a way to create new *.cfg in /etc/mrtg/conf.d/ for each new host. If you go to that folder right now and open any .cfg file you'll see a similar line at the top:
This means you can create the current config file by running the command and putting its contents to a new .cfg file.
Hope this info will help with your automation efforts.
Re: Monitoring switches without the Wizard
Posted: Wed Mar 07, 2018 4:22 pm
by Matthew.Cary
This helps, but I have another question.
I'm sure I can figure out a way to script the creation of the .cfg files for each router, but it looks like the actual port bandwidth checks refer to the .rrd file by name in the command line argument. For example the bandwidth check for port 1 on a router named remoteA has an $ARG1$ of remoteA_1.rrd.
Is there a way to use a variable in this $ARG$? Is there a way for example to use the hostname of the router? (ex: $HOSTNAME$_1.rrd)
This would allow me to create a service that performs a bandwidth check for port 1 on a router and then associate it with 50 different routers. As things are currently configured it looks like I end up needing a separate service for each port on each router which means templates aren't going to work.
Or is there another way to make the check more portable across different hosts?
Re: Monitoring switches without the Wizard
Posted: Wed Mar 07, 2018 4:41 pm
by npolovenko
@Matthew.Cary,
Untitled.png
Yep, this would work. Don't forget to actually save and apply the config. Macros won't get applied when you "Run Check Command" in CCM, but once you actually save the check and go to the home page in GUI Nagios should use a macro just fine.