Page 1 of 1

Able to run check_snmp with Nagios Core ? free version ?

Posted: Mon Feb 09, 2015 8:29 pm
by jdworske
Nagios Team,

Is it possible to fun the 'check_snmp' command to check disk usage via snmp from a Nagios server checking disk space on a linux server using SNMP?

I am trying to get this done, however, not working for me right now.

Is there a tutorial that I can follow that shows examples of how to use check_snmp using Nagios Core 4.0.8?

Thank you,
John Dworske

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Mon Feb 09, 2015 9:46 pm
by Box293
Yes you can.

While this guide is for Nagios XI, the first two pages are the same for Nagios Core:
http://assets.nagios.com/downloads/nagi ... g_SNMP.pdf

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 6:24 pm
by jdworske
Box293,

Thank you for your prompt reply.

So I am getting somewhere now however not quite there yet. Hoping you guys can help?

From my Nagios server:

Querying OID for DISK space available / partion:

[root@hq-nagios-02 jdworske]# /usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -C 'mypassword' -o .1.3.6.1.4.1.2021.9.1.7.1
SNMP OK - 10879380 | iso.3.6.1.4.1.2021.9.1.7.1=10879380


In my hq-ui-01 host configuration file I have the service defined like this:

define service{
use generic-service
host_name hq-ui-01
service_description Disk Avail /
check_command check_snmp!-c "mypassword" -o .1.3.6.1.4.1.2021.9.1.7.1
contacts aahmad
}

On my Nagios WEB interface the result is this:

(No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'

Not exactly sure why this is happening? Any ideas much appreciated ?

Thank you,
John Dworske

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 7:01 pm
by Box293
Can you please post your command definition for the command check_snmp

Also, when you do your tests please run them as the user nagios and see if you get the same result:

Code: Select all

su nagios
/usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -C 'mypassword' -o .1.3.6.1.4.1.2021.9.1.7.1
Also I noticed the following:
Test:
-C 'mypassword' -o .1.3.6.1.4.1.2021.9.1.7.1

Definition:
-c "mypassword" -o .1.3.6.1.4.1.2021.9.1.7.1

In your definition you have a lower case -c whereas in your test you have an upper case -C
In your definition you are using "double quotes" for the password whereas in your test you are using 'single quotes' for the password

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 7:13 pm
by jdworske
Box293,

OK:

As user nagios from my nagios server:

[nagios@hq-nagios-02 jdworske]$ /usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -C 'mypass!word' -o .1.3.6.1.4.1.2021.9.1.7.1
SNMP OK - 10875448 | iso.3.6.1.4.1.2021.9.1.7.1=10875448


[nagios@hq-nagios-02 jdworske]$ /usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -c 'mypass!word' -o .1.3.6.1.4.1.2021.9.1.7.1
External command error: Timeout: No Response from hq-ui-01:161.

From the command line test need to use -C as you can see from above doesn't like lowercase -c.

[nagios@hq-nagios-02 jdworske]$ /usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -C "mypass!word" -o .1.3.6.1.4.1.2021.9.1.7.1
bash: !sNmP": event not found

Also only likes the 'Single Quotes' - Double quotes breaks the test.

Finally here is my command definition in commands.cfg:

# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}

Thanks again for your help.

John

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 7:39 pm
by Box293
Great, lots of info we've discovered here.

First, your service definition needs to be:

Code: Select all

check_command check_snmp!-P 2c -C 'mypassword' -o .1.3.6.1.4.1.2021.9.1.7.1
Now your other problem is your community string:

Code: Select all

mypass!word
It has the exclamation mark ! in it and this conflicts with how the Nagios check_command arguments are separated.
So what is happening is Nagios thinks that $ARG1$ is:
-P 2c -C 'mypass
as the ! in the community string defines the end of $ARG1$

You have two solutions here:
1) Change the name of the community string on the device so it does not have a !
2) Add the community string to a $USERxx$ variable in resources.cfg and then you can reference $USERxx$ in your command like like:

Code: Select all

check_command check_snmp!-P 2c -C $USER18$ -o .1.3.6.1.4.1.2021.9.1.7.1

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 8:00 pm
by jdworske
Box293,


OK so I change community string to hot have the !.

now result is:

External command error: Timeout: No Response from 192.168.0.26:161.

Your help is much appreciated.

I can run external commands from the web gui also.

Any thoughts ?

John

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Wed Feb 11, 2015 9:06 pm
by Box293
Please post your command and service definition again.

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Thu Feb 12, 2015 2:00 pm
by jdworske
Box293,

OK man ... Thanks a million for your help brah.

I finally got it working. Here is the output from my Nagios GUI:

Disk Avail /
OK 02-12-2015 10:42:32 0d 0h 5m 36s 1/2 SNMP OK - 10862244

Service definition as defined in my host config file:

define service{
use generic-service
host_name hq-ui-01
service_description Disk Avail /
check_command check_snmp2!.1.3.6.1.4.1.2021.9.1.7.1 -P 2c
contacts aahmad
}


Then the command Definition:

# 'check_snmp' command definition
define command{
command_name check_snmp2
command_line $USER1$/check_snmp2 -H $HOSTADDRESS$ -C xxxxx -o $ARG1$
}


[nagios@hq-nagios-02 libexec]$ /usr/local/nagios/libexec/check_snmp -H hq-ui-01 -P 2c -C 'xxxxxxx' -o .1.3.6.1.4.1.2021.9.1.7.1
SNMP OK - 10868396 | iso.3.6.1.4.1.2021.9.1.7.1=10868396


[root@hq-ui-01 jdworske]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_sfosgttmpl01-lv_root
22569476 10556204 10866804 50% /


Still fine tuning my Nagios installation and cleaning up all my tests, but making some good progress.


Thank you.

John

Re: Able to run check_snmp with Nagios Core ? free version

Posted: Thu Feb 12, 2015 4:58 pm
by Box293
Excellent, glad we could get you on the way to happy monitoring :)