SNMP Timeticks not returning as days/hours

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

SNMP Timeticks not returning as days/hours

Postby DiegoAnjos » Wed Aug 30, 2017 3:59 pm

Hi

Since I upgraded from Nagios Core from 4.3.0 to 4.3.2 the "Uptime" checks through SNMP returns data as timeticks.

CLI:
Code: Select all
./check_snmp -H X.X.X.X -C snmpcommunity -o sysUpTime.0

RESULT: SNMP OK - 112536996 | DISMAN-EVENT-MIB::sysUpTimeInstance=112536996

WEB UI:SNMP OK - 733630839

How can I get the information as DAYS/HOURS?

Info:
Nagios Core 4.3.2
Plugins: 2.2.1
net-snmp 5.7.2
DiegoAnjos
 
Posts: 49
Joined: Thu Feb 14, 2013 9:32 am

Re: SNMP Timeticks not returning as days/hours

Postby scottwilkerson » Wed Aug 30, 2017 4:40 pm

You would need to either create a wrapper plugin that does the math calculation, or find on on the exchange that does.

I think this plugin offers what you are looking for
https://exchange.nagios.org/directory/P ... MP/details
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 18661
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: SNMP Timeticks not returning as days/hours

Postby tacolover101 » Wed Aug 30, 2017 4:57 pm

here you go. i hacked this together. i even mixed sed and cut. :shock:

you'll need to address the variable replacing as you please. it would be easy enough to substitute $1 / $2 though.
Code: Select all
[root@localhost libexec]# ./test.sh
29 days, 0:51:14.82 | uptime=250867482


Code: Select all
#!/bin/bash
data=$(snmpget -v2c -c community -mALL hostaddress 1.3.6.1.2.1.1.3.0 | sed -e 's/.*(\(.*\))/\1/')
human=$(echo $data | cut -d ' ' -f 2,3,4)
perf=$(echo $data | cut -d ' ' -f 1)
echo "$human | uptime=$perf"
User avatar
tacolover101
 
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: SNMP Timeticks not returning as days/hours

Postby scottwilkerson » Thu Aug 31, 2017 8:49 am

tacolover101 wrote:here you go. i hacked this together. i even mixed sed and cut. :shock:

you'll need to address the variable replacing as you please. it would be easy enough to substitute $1 / $2 though.
Code: Select all
[root@localhost libexec]# ./test.sh
29 days, 0:51:14.82 | uptime=250867482


Code: Select all
#!/bin/bash
data=$(snmpget -v2c -c community -mALL hostaddress 1.3.6.1.2.1.1.3.0 | sed -e 's/.*(\(.*\))/\1/')
human=$(echo $data | cut -d ' ' -f 2,3,4)
perf=$(echo $data | cut -d ' ' -f 1)
echo "$human | uptime=$perf"


nice, thanks @tacolover101
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 18661
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: SNMP Timeticks not returning as days/hours

Postby DiegoAnjos » Thu Aug 31, 2017 12:48 pm

@tacolover101

you'll need to address the variable replacing as you please. it would be easy enough to substitute $1 / $2 though.


To help others, I will describe what I had to do to get your script working like it was a default plugin:

Changed your script adding the variables:
#!/bin/bash
data=$(snmpget -v2c -c $1 -mALL $2 1.3.6.1.2.1.1.3.0 | sed -e 's/.*(\(.*\))/\1/')
human=$(echo $data | cut -d ' ' -f 2,3,4)
perf=$(echo $data | cut -d ' ' -f 1)
echo "$human | uptime=$perf"

$1: SNMP communit name
$2: hostname


Saved the script on /usr/local/nagios/libexec naming it as uptime_snmp.sh

On commands.cfg I created a command to call the script:
Code: Select all
define command{
        command_name    uptime_snmp
        command_line    $USER1$/uptime_snmp.sh $ARG1$ $ARG2$
        }


Finally, the service on the host file is written as:
define service{
use generic-service
host_name SWITCH-CORE
service_description UPTIME
check_command uptime_snmp!community!$HOSTADDRESS$
}


Thanks for everyone. That was really a quick reply!
DiegoAnjos
 
Posts: 49
Joined: Thu Feb 14, 2013 9:32 am

Re: SNMP Timeticks not returning as days/hours

Postby tmcdonald » Thu Aug 31, 2017 3:31 pm

Glad to hear it! Are we okay to consider this issue resolved?
Former Nagios employee
tmcdonald
 
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: SNMP Timeticks not returning as days/hours

Postby tacolover101 » Thu Aug 31, 2017 7:23 pm

DiegoAnjos wrote:@tacolover101

you'll need to address the variable replacing as you please. it would be easy enough to substitute $1 / $2 though.


To help others, I will describe what I had to do to get your script working like it was a default plugin:

Changed your script adding the variables:
#!/bin/bash
data=$(snmpget -v2c -c $1 -mALL $2 1.3.6.1.2.1.1.3.0 | sed -e 's/.*(\(.*\))/\1/')
human=$(echo $data | cut -d ' ' -f 2,3,4)
perf=$(echo $data | cut -d ' ' -f 1)
echo "$human | uptime=$perf"

$1: SNMP communit name
$2: hostname


Saved the script on /usr/local/nagios/libexec naming it as uptime_snmp.sh

On commands.cfg I created a command to call the script:
Code: Select all
define command{
        command_name    uptime_snmp
        command_line    $USER1$/uptime_snmp.sh $ARG1$ $ARG2$
        }


Finally, the service on the host file is written as:
define service{
use generic-service
host_name SWITCH-CORE
service_description UPTIME
check_command uptime_snmp!community!$HOSTADDRESS$
}


Thanks for everyone. That was really a quick reply!


no problem, thanks for explaining the rest of it. :)
User avatar
tacolover101
 
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am


Return to Community Support

Who is online

Users browsing this forum: RaManaz and 24 guests