How do I monitor Cisco CPU utilisation ?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
vijilants
Posts: 215
Joined: Wed Jun 12, 2013 2:50 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by vijilants »

jdalrymple wrote:When you add custom plugins there is no magic integration with the wizards. Furthermore the switch and router wizard has some magic of its own, and as such it is exclusively used for monitoring port metrics, nothing else.

You will have to manually create your service in the CCM. It's all in the document you referenced earlier:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Unfortunately what you have referenced and what was referenced to me earlier are two different documents....and your document appears to have a lot more detail....I find this typical of Nagios as the documentation appears to be all over the place.

Does this mean that I have to create this service to every single device as I want to monitor the CPU on all devices ?
vijilants
Posts: 215
Joined: Wed Jun 12, 2013 2:50 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by vijilants »

ssax wrote:Here is what I do:

Code: Select all

cd /usr/local/nagios/libexec
./check_nwc_health -h
That will give you the options that it supports.

Then create the command like this:

Command Name: check_nwc_health
Command Line:

Code: Select all

$USER1$/check_nwc_health --hostname $HOSTADDRESS$ --mode $ARG1$ --community '$ARG2$' --warning $ARG3$ --critical $ARG4$ $ARG5$
You can add anything else you need to the command as well but that seems to be the basic settings.

Now under your service set:

$ARG1$ = cpu-load
$ARG2$ = snmp community
$ARG3$ = warning threshold
$ARG4$ = critical threshold
$ARG5$ = you can pass in any other arguments that you need here that differ from the basic command.

You best option is to test from the command line first to make sure it's working the way you want it to:

Code: Select all

cd /usr/local/nagios/libexec
./check_nwc_health --hostname 192.168.4.44 --mode cpu-load --community 'mycommunity' --warning 60 --critical 80

I have tried all of these steps but when I go to create a New Service and press the Test Command button, this is what I get:

Code: Select all

Testing check from command line...

COMMAND: /usr/local/nagios/libexec/check_nwc_health --hostname DartSW01 --mode cpu-load --community 'test123' --warning 60 --critical 80 
OUTPUT: UNKNOWN - cannot write status dir /var/tmp/check_nwc_health! check your filesystem (permissions/usage/integrity) and disk devices, cannot write status file /var/tmp/check_nwc_health/DartSW01_cpu-load_protect_10_usage0b3645a1f7f1dcac467cb0cd60a7d6f0! check your filesystem (permissions/usage/integrity) and disk devices, cpu 1 usage (5 min avg.) is 6.00% | 'cpu_1_usage'=6%;60;80;0;100
Can you please advise ?
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: How do I monitor Cisco CPU utilisation ?

Post by snapon_admin »

Does this mean that I have to create this service to every single device as I want to monitor the CPU on all devices ?
Technically yes, but this is one of those situations where the bulk modifications tool comes in handy.
I have tried all of these steps but when I go to create a New Service and press the Test Command button, this is what I get
Check the permissions of /var/tmp/check_nwc_health. The error is saying that the permissions on that directory are incorrect. Mine are

Code: Select all

[root@lisl-ngos-01-pv tmp]# ls -l
total 32
drwxr-xr-x. 2 nagios users 4096 Aug  6 16:01 check_nwc_health
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by ssax »

Try running this command and try the test command again.

Code: Select all

rm -rf /var/tmp/check_nwc_health*
The files would have been created by root when testing, sorry, I should have said to su - nagios before testing from the command line.
vijilants
Posts: 215
Joined: Wed Jun 12, 2013 2:50 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by vijilants »

ssax wrote:Try running this command and try the test command again.

Code: Select all

rm -rf /var/tmp/check_nwc_health*
The files would have been created by root when testing, sorry, I should have said to su - nagios before testing from the command line.
Thanks for your support guys....however...

I did this and under CCM and in Services, the command now works when you hit the Test Check Command button

However when I go to Home, Services, and force an immediate check, this is what I get:

Code: Select all

UNKNOWN - cannot write status dir /var/tmp/check_nwc_health! check your filesystem (permissions/usage/integrity) and disk devices, cannot write status file /var/tmp/check_nwc_health/10.1.2.243_cpu-load_protect_10_usage0b3645a1f7f1dcac467cb0cd60a7d6f0! che
So, I go back to CCM again and try the command again via Services and that still works when you hit the Test Check Command button

Any ideas as to what is going on here ?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by jdalrymple »

Repeat what ssax said earlier... `rm -Rf /var/tmp/check_nwc_health*` At this point your check result is owned by apache so the nagios user cannot write it. Once the Nagios user is in control all will be good.

Also, let's have a howto on how to NOT do more work than necessary. snapon_admin is right, bulk mod can be great. In this case though having more than 1 service is just silly.

Note that when you are in CCM creating or modifying your service, and you click the "manage hosts" button you have the option to add more than one host. Unfortunately the wizard way of doing things obfuscates some of the better and more elegant ways of service handling. There is no good reason to have more than 1 service defined on your system with all the same object definitions and only a different hostname. Hostname doesn't come into the check directly, it comes via macro $HOSTADDRESS$.

That's my long winded way of saying it's quite likely that you don't need more than 1 service. The only reason to have more than 1 would be if you had some specific different needs from one Cisco device to the other, say like you wanted to alert every 5 minutes for one of them but only every 30 minutes for another.

Make sense?
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: How do I monitor Cisco CPU utilisation ?

Post by snapon_admin »

When you run a test check it's ran as a different user than when Nagios actually runs the check (i.e. forcing an immediate check). You would have to run the rm command again and then force an immediate check for it to work. Alternatively you can modify the permissions of that directory so that both apache (or root?...I forget) and nagios users can write to it.

And I see that jdalrymple beat me to answering so I'll comment on that as well.
if you had some specific different needs from one Cisco device to the other, say like you wanted to alert every 5 minutes for one of them but only every 30 minutes for another.
This is the exact reason we DO have separate services so he's absolutely correct that you don't need to have a separate service per each host for this to work. The reason we do here is so that certain hosts can have different check periods, different notification times, different SNMP communities in some cases, and different alert thresholds. If these things are the same on all of your devices, then you can just have one service that checks all the devices.
vijilants
Posts: 215
Joined: Wed Jun 12, 2013 2:50 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by vijilants »

jdalrymple wrote:Repeat what ssax said earlier... `rm -Rf /var/tmp/check_nwc_health*` At this point your check result is owned by apache so the nagios user cannot write it. Once the Nagios user is in control all will be good.

Also, let's have a howto on how to NOT do more work than necessary. snapon_admin is right, bulk mod can be great. In this case though having more than 1 service is just silly.

Note that when you are in CCM creating or modifying your service, and you click the "manage hosts" button you have the option to add more than one host. Unfortunately the wizard way of doing things obfuscates some of the better and more elegant ways of service handling. There is no good reason to have more than 1 service defined on your system with all the same object definitions and only a different hostname. Hostname doesn't come into the check directly, it comes via macro $HOSTADDRESS$.

That's my long winded way of saying it's quite likely that you don't need more than 1 service. The only reason to have more than 1 would be if you had some specific different needs from one Cisco device to the other, say like you wanted to alert every 5 minutes for one of them but only every 30 minutes for another.

Make sense?
OK...Great and thank you

Doing a `rm -Rf /var/tmp/check_nwc_health* again appears to have got it going.

OK....on to the services let me see if I can get this.......In order to get this to work, in CCM under Services I have a host named Dart01. So, When I created the Service I called the service name Dart01, Description Dart01 CPU , display name Dart01 CPU. Under Managed hosts I assigned host Dart01.

In my home view this now appears under Dart01 services as dart01 CPU.

So what I need to do is use the CPU service across all my Cisco devices, so that I can monitor all the devices as far as CPU utilisation is concerned, and I have many Cisco devices.

Are you sating to give the service say a global name like router CPUand assign more than one host to it ?

The only orher way I can see of doing this is to create a service with a name for each device which will take forever.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by jdalrymple »

vijilants wrote:Are you sating to give the service say a global name like router CPUand assign more than one host to it ?
The name doesn't matter. When you look at a service detail page of any sort - the host is always noted - you will never see a service description all by itself. Services were always meant to be modular. So yes, it would make more sense to have a generic service name - but really it doesn't matter.
You do not have the required permissions to view the files attached to this post.
vijilants
Posts: 215
Joined: Wed Jun 12, 2013 2:50 pm

Re: How do I monitor Cisco CPU utilisation ?

Post by vijilants »

Thank you all...

snapon_admin wrote:I can tell you that we use this one for ASA devices: https://exchange.nagios.org/directory/P ... EM/details .
Now with the plugin for the ASA, what I need to do to get that in to the /usr/local/nagios/libexec directory ?

I noticed that it was a txt file.....can you please talk me through the process and any commands to make this a plugin ?

Many Thanks
Locked