Check_SNMP vs snmpwalk

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
cgerow
Posts: 1
Joined: Tue Mar 07, 2017 3:03 pm

Check_SNMP vs snmpwalk

Post by cgerow »

I get different output from check_snmp than I do snmpwalk...

----------------------------------------------------------

/> /usr/lib64/nagios/plugins/check_snmp -H 192.168.1.1 -C ComString -o sysUpTime.0
SNMP OK - 76017933 | DISMAN-EVENT-MIB::sysUpTimeInstance=76017933

----------------------------------------------------------

/> snmpwalk -v 1 -c ComString 192.168.1.1 sysUpTime.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (76017937) 8 days, 19:09:39.37

----------------------------------------------------------

Is there a way to convert what check_snmp displays (timetick value only) to a human readable format (example: 8 days, 18:32:42.80)?
This is how Nagios used to display the information "x days, hh:mm:ss". I use this as more a visual than I do for an alert.

Nagios® Core™ Version 4.2.4
CentOS Linux release 7.3.1611 (Core) 64bit

System Check:
define host{
use generic-switch
host_name switch01
alias switch01
address 192.168.1.1
}

define service{
use generic-service
host_name switch01
service_description System - Uptime
check_command check_snmp!-C ComString -o sysUpTime.0
}

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

Thank you.

--
Thank you,
CG

--
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Check_SNMP vs snmpwalk

Post by tmcdonald »

They're reporting the same info, just in different formats. Short of modifying the check_snmp plugin directly, you would need to write a wrapper script which calls the check_snmp plugin, grabs the output, and converts the date itself.
Former Nagios employee
homer_2001
Posts: 5
Joined: Sat Mar 25, 2017 4:02 am

Re: Check_SNMP vs snmpwalk

Post by homer_2001 »

Same Problem for me. I have updated my System from Nagios 4.1.1 with Nagios-Plugins 2.0.2 under Ubuntu 14.04.
In this case all things looks good. There are the Timeticks and the Uptime in a human readable format. Without wrapper script or other things.
Now, with Ubuntu 16.04, Nagios 4.2.4. and Nagios-Plugins 2.1.4 only shown timeticks.
Is this a bug or a feature ? Can I go back to 2.0.2-plugins ?

regards
homer
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_SNMP vs snmpwalk

Post by mcapra »

You should be able to re-compile nagios-plugins 2.0.2.

Can you share the check_command as well as command definition that you're using for your SNMP checks? I'll see if I can replicate the problem between those 2 versions of nagios-plugins.
Former Nagios employee
https://www.mcapra.com/
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Check_SNMP vs snmpwalk

Post by avandemore »

I have confirmed the newer plugin has different output. Just a guess but this may be related:

https://github.com/nagios-plugins/nagio ... issues/108
Previous Nagios employee
homer_2001
Posts: 5
Joined: Sat Mar 25, 2017 4:02 am

Re: Check_SNMP vs snmpwalk

Post by homer_2001 »

Hi, better late then never ….

command an service definitions:

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

define service{
use generic-service ;
host_name Datenserver;
service_description Uptime
check_interval 5
check_command check_snmp!-C public -l Uptime -o .1.3.6.1.2.1.25.1.1.0;
}

Output with Nagios-Plugins 2.2.0
Uptime OK 04-06-2017 16:39:35 0d 0h 4m 35s 1/3 SNMP OK - Uptime 114718

Output with Nagios-Plugins 2.0.2
Uptime OK 06-04-2017 16:59:04 33d 6h 30m 58s 1/3 SNMP OK - Uptime Timeticks: (231370) 0:38:33.70
Command and Sevicedefinitions are the same.

I have compiled the plugins 2.2.0 with the new check_snmp.c from github, but no success.

regards
homer_2001
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Check_SNMP vs snmpwalk

Post by dwhitfield »

The suggestion was to compile 2.0.2 not 2.2.0. Was that a typo?
homer_2001
Posts: 5
Joined: Sat Mar 25, 2017 4:02 am

Re: Check_SNMP vs snmpwalk

Post by homer_2001 »

I have compiled booth versions, the 2.0.2 and the 2.2.0.

2.0.2. works good, showing timeticks and human readable uptime. 2.2.0. shows only timeticks. Look at my previous mail, there are the outputs from booth versions.

regards
homer_2001
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Check_SNMP vs snmpwalk

Post by dwhitfield »

homer_2001 wrote: Can I go back to 2.0.2-plugins ?
Maybe this wasn't clear in the earlier comment, but the answer is yes. Is there a reason you are not doing that?
homer_2001
Posts: 5
Joined: Sat Mar 25, 2017 4:02 am

Re: Check_SNMP vs snmpwalk

Post by homer_2001 »

It is o.k. so. I was wondering about the less function in the new version.

many thanks
homer_2001
Locked