Monitoring switches without the Wizard

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Matthew.Cary
Posts: 32
Joined: Fri Nov 10, 2017 11:43 am

Monitoring switches without the Wizard

Post 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.....
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Monitoring switches without the Wizard

Post 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:

Code: Select all

# Created by
# /usr/bin/cfgmaker --show-op-down --noreversedns --zero-speed 100000000 [email protected]:161::::2
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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Matthew.Cary
Posts: 32
Joined: Fri Nov 10, 2017 11:43 am

Re: Monitoring switches without the Wizard

Post 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?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Monitoring switches without the Wizard

Post 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.
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked