Able to run check_snmp with Nagios Core ? free version ?
Able to run check_snmp with Nagios Core ? free version ?
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
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
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Able to run check_snmp with Nagios Core ? free version
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
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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Able to run check_snmp with Nagios Core ? free version
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
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
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Able to run check_snmp with Nagios Core ? free version
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:
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
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.1Test:
-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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Able to run check_snmp with Nagios Core ? free version
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
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
Last edited by jdworske on Wed Feb 11, 2015 8:13 pm, edited 1 time in total.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Able to run check_snmp with Nagios Core ? free version
Great, lots of info we've discovered here.
First, your service definition needs to be:
Now your other problem is your community string:
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:
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.1Code: Select all
mypass!wordSo 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
Last edited by Box293 on Wed Feb 11, 2015 9:02 pm, edited 1 time in total.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Able to run check_snmp with Nagios Core ? free version
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
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
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Able to run check_snmp with Nagios Core ? free version
Please post your command and service definition again.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Able to run check_snmp with Nagios Core ? free version
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
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
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Able to run check_snmp with Nagios Core ? free version
Excellent, glad we could get you on the way to happy monitoring 
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.