Page 4 of 7

Re: check_snmp not working but snmpget works

Posted: Sat Nov 08, 2014 9:18 pm
by rhassing
Could you please do the check_snmp again with the -vvv option and post the output?
Did you recompile the check_snmp also?

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 8:05 am
by Kerflumpre
I even fired up a whole new VM with Debian 7.7 and Nagios 4.0.8 and plugins 2.0.3 and I get the same results.

Code: Select all

root@nagios-core:/usr/local/nagios/libexec# ./check_snmp -P 1 -C COMMUNITY -H 192.168.1.1 -vvv -o iso.3.6.1.2.1.31.1.1.1.16.1
/usr/bin/snmpget -Le -t 1 -r 5 -m ALL -v 1 [authpriv] 192.168.1.1:161 iso.3.6.1.2.1.31.1.1.1.16.1
CRITICAL - Plugin timed out while executing system call
I think something in the check_snmp isn't passing the community string or is passing it incorrectly. If I run the following directly:

Code: Select all

/usr/bin/snmpget -Le -t 1 -r 5 -m ALL -v 1 -c COMMUNITY 192.168.1.1:161 iso.3.6.1.2.1.31.1.1.1.16.1
It works. But if I put the wrong community, I get the timeout.

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 8:11 am
by rhassing
Could you do

Code: Select all

/usr/bin/snmpget -V

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 9:24 am
by Kerflumpre
root@nagios-core:/usr/local/nagios/libexec# /usr/bin/snmpget -V
NET-SNMP version: 5.4.3

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 9:50 am
by rhassing
I had the same problem you have with net-snmp 5.4.3.
Let me prove it:

I have two different versions installed, 1 is from the debian package (version 5.4.3) and 1 is installed from source (version 5.7.2):

Code: Select all

root@debian64:~# /usr/local/bin/snmpget -V
NET-SNMP version: 5.7.2
root@debian64:~# /usr/bin/snmpget -V
NET-SNMP version: 5.4.3
root@debian64:~# snmpget -V
NET-SNMP version: 5.7.2
root@debian64:~# 
Both version work with a normal snmpget:

Code: Select all

root@debian64:~# /usr/local/bin/snmpget -Le -t 1 -v 1 -r 5 -c public 192.168.122.1 iso.3.6.1.2.1.31.1.1.1.16.1
IF-MIB::ifPromiscuousMode.1 = INTEGER: false(2)
root@debian64:~# /usr/bin/snmpget -Le -t 1 -v 1 -r 5 -c public 192.168.122.1 iso.3.6.1.2.1.31.1.1.1.16.1
iso.3.6.1.2.1.31.1.1.1.16.1 = INTEGER: 2
With the newer version the check_snmp does work:

Code: Select all

root@debian64:~# /home/rob/Downloads/nagios-plugins-2.0.3/plugins/check_snmp -P 1 -H 192.168.122.1 -o iso.3.6.1.2.1.31.1.1.1.16.1 -vvv
/usr/local/bin/snmpget -Le -t 1 -r 5 -m ALL -v 1 [authpriv] 192.168.122.1:161 iso.3.6.1.2.1.31.1.1.1.16.1
IF-MIB::ifPromiscuousMode.1 = INTEGER: false(2)
Processing oid 1 (line 1)
  oidname: IF-MIB::ifPromiscuousMode.1
  response: INTEGER: false(2)
SNMP OK - false(2) | 
root@debian64:~# 
And if I remove the newer version of the snmpget file and use the same version you have installed:

Code: Select all

root@debian64:~# mv /usr/local/bin/snmpget /usr/local/bin/snmpget.572
root@debian64:~# cp /usr/bin/snmpget /usr/local/bin/snmpget
root@debian64:~# /home/rob/Downloads/nagios-plugins-2.0.3/plugins/check_snmp -P 1 -H 192.168.122.1 -o iso.3.6.1.2.1.31.1.1.1.16.1 -vvv
/usr/local/bin/snmpget -Le -t 1 -r 5 -m ALL -v 1 [authpriv] 192.168.122.1:161 iso.3.6.1.2.1.31.1.1.1.16.1
CRITICAL - Plugin timed out while executing system call

root@debian64:~# 
So it is definitely the snmpget version you are using that causes the problem.

There are some things you could do:
  • Compile the latest version of net-snmp on your system.
  • Switch over to CentOS, I never had these kind of problems on CentOS.
  • Don't use check_snmp, and write your own scripts using the snmpget you have.

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 10:11 am
by Kerflumpre
Did you have any trouble compiling net-snmp on Debian? I'm getting stuck with this:

Code: Select all

/usr/bin/ld: cannot find -lperl
collect2: error: ld returned 1 exit status
make[1]: *** [libnetsnmpagent.la] Error 1
make[1]: Leaving directory `/root/downloads/net-snmp-5.7.2.1/agent'
make: *** [subdirs] Error 1

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 10:19 am
by rhassing
I had that problem as well.
This is my apt-get history:

Code: Select all

apt-get install libc6
apt-get install libnet-snmp-perl
apt-get install automake autoconf make gcc gcc-multilib libtool m4 perl bzip2
apt-get install libperl-dev
apt-get install libsensors4-dev
I think the last two are most important, but you could best install all packages I installed. :-)

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 12:34 pm
by Kerflumpre
Looks promising. And how did you get check_snmp to use the new version?

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 12:42 pm
by rhassing
I just recompiled all plugins and after that it used the one in /usr/local/bin/ instead of the one /usr/bin/.

Re: check_snmp not working but snmpget works

Posted: Sun Nov 09, 2014 2:17 pm
by Kerflumpre
Getting a slightly different result now:

Code: Select all

root@nagios-core:/usr/local/nagios/libexec# ./check_snmp -P 1 -c COMMUNITY -H 192.168.1.1 -vvv -o iso.3.6.1.2.1.31.1.1.1.16.1
/usr/local/bin/snmpget -Le -t 1 -r 5 -m ALL -v 1 [authpriv] 192.168.1.1:161 iso.3.6.1.2.1.31.1.1.1.16.1
External command error: Timeout: No Response from 192.168.1.1:161.
But I'm seeing it in the tcpdump now:

Code: Select all

14:11:45.459696 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
14:11:46.461420 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
14:11:47.463562 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
14:11:48.465881 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
14:11:49.468139 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
14:11:50.469115 IP 192.168.1.2.55798 > 192.168.1.1.snmp:  GetRequest(31)  31.1.1.1.16.1
Here is the same with snmpget:

Code: Select all

root@nagios-core:/usr/local/nagios/libexec# snmpget -v 1 -c COMMUNITY 192.168.1.1 iso.3.6.1.2.1.31.1.1.1.16.1
IF-MIB::ifPromiscuousMode.1 = INTEGER: true(1)

Code: Select all

14:16:38.671152 IP 192.168.1.2.38381 > 192.168.1.1.snmp:  C=COMMUNITY GetRequest(31)  31.1.1.1.16.1
14:16:38.673382 IP 192.168.1.1.snmp > 192.168.1.2.38381:  C=COMMUNITY GetResponse(32)  31.1.1.1.16.1=1