Page 1 of 1

check_uptime

Posted: Fri May 01, 2015 10:11 am
by btemple
Do you have an examples of how to run this command against remote linux / hp-ux server with notifications ? I was trying to work with the check_uptime.pl from the exchange but I am having a hard time with it.

check_uptime I believe is the built in plug-in ? check_uptime.pl is not ?

thanks

Re: check_uptime

Posted: Fri May 01, 2015 10:22 am
by jolson
No problem - for now I want to focus on how you are monitoring the remote linux/ht-ux servers to begin with. Are you using NRPE or a similar agent on them? If so, could you show me the nrpe.cfg from the remote hosts you intend to monitor the uptime of?

Code: Select all

cat /usr/local/nagios/etc/nrpe.cfg
I am also interested in the libexec directory of that same remote host:

Code: Select all

ls -l /usr/local/nagios/libexec
What I am interested in here is ensuring the check_uptime plugin has been installed.

Let me know if you have any questions about the above. Thanks!

Re: check_uptime

Posted: Fri May 01, 2015 11:41 am
by btemple
We are using SNMP checks on 90% of our hosts. So we are not using agents only on a couple of older hp-ux clients that we are in the process of decommissioning

Re: check_uptime

Posted: Fri May 01, 2015 12:23 pm
by abrist
Uptime can be checked on the oid: 1.3.6.1.2.1.1.3.0. Check to see if the necessary section of the oid tree is permitted:

Code: Select all

snmpget -c <community> -v2c <hostname> 1.3.6.1.2.1.1.3.0
If it is, you can check it with check_snmp:

Code: Select all

/usr/local/nagios/libexec/check_snmp -H <hostname> -C <community> -o 1.3.6.1.2.1.1.3.0 -w <warn ticks> -c <crit ticks>
Now as we usually want to warn about boxes that have too low of an uptime (signifies they rebooted), you may want to use the syntax: "<ticks>:"
For example, the following check will warn when under 50k ticks, and crit when under 10k ticks:

Code: Select all

[root@localhost libexec]# ./check_snmp -H localhost -C public -o 1.3.6.1.2.1.1.3.0 -w 50000: -c 10000:
SNMP WARNING - *36916* | iso.3.6.1.2.1.1.3.0=36916;0;0;
This should work in your snmp environment, keeping those nasty agent requirements at bay!

Re: check_uptime

Posted: Fri May 01, 2015 12:25 pm
by jolson
I see that abrist has already responded - but as I crafted this response already, I figured I'd post it in case you find it useful. :D

Fortunately this is a pretty straightforward process. It sounds like your remote hosts already have SNMP up and running properly - double check that snmpd is running on the linux hosts.

Next, we'll want to install check_uptime.pl on your Nagios XI server. You can either transfer it over via SCP or similar, or you can copy the text and paste it into a new file. Be sure that the check_uptime.pl plugin is installed in the /usr/local/nagios/libexec directory. Check to sure that the execute bit is set - typical permissions are 755.

Code: Select all

chmod 755 /usr/local/nagios/libexec/check_uptime.pl
After the plugin is installed, let's take a look at the help menu:

Code: Select all

/usr/local/nagios/libexec/check_uptime.pl -h
Uptime Plugin for Nagios (check_uptime) v. 0.52
GPL licence, (c) 2008-2012 William Leibzon

Usage: /usr/local/nagios/libexec/check_uptime.pl [-v [debugfilename]] [-T local|unix-host|unix-sys|win|net] [-H <host> (-C <snmp_community>) [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>]] [-w <warn minutes> -s <crit minutes>] [-f] [-P <previous perf data from nagios $SERVICEPERFDATA$>] [-t <timeout>] | [-V] [--label <string>]

Debug & Console Options:
-v, --verbose[=FILENAME], --debug[=FILENAME]
print extra debugging information.
if filename is specified instead of STDOUT the debug data is written to that file
-h, --help
print this help message
-V, --version
prints version number

Standard Options:
-T, --type=auto|local|unix-host|unis-sys|windows|netswitch
Type of system:
local : localhost (executes 'uptime' command), default if no -C or -l
unix-host : SNMP check from hostUptime (1.3.6.1.2.1.25.1.1.0) OID
unix-sys : SNMP check from sysUptime (1.3.6.1.2.1.1.3.0) OID
win | windows : SNMP check from sysUptime (1.3.6.1.2.1.1.3.0) OID
net | netswitch : SNMP check from snmpEngineTime (1.3.6.1.6.3.10.2.1.3) OID
auto : Autodetect what system by checking sysSystem OID first, default
-w, --warning[=minutes]
Report nagios WARNING alert if system has been up for less then specified
number of minutes. If no minutes are specified but previous preformance
data is fed back with -P option then alert is sent ONLY ONCE when
uptime changes from greater value to smaller
-c, --critical[=minutes]
Report nagios CRITICAL alert if system has been up for less then
specified number of minutes or ONE ALERT if -P option is used and
system's previous uptime is larger then current on
-f, --perfparse
Perfparse compatible output
-P, --prev_perfdata
Previous performance data (normally put '-P $SERVICEPERFDATA$' in
nagios command definition). This is recommended if you dont specify
type of system with -T so that previously checked type of system info
is reused. This is also used to decide on warning/critical condition
if number of seconds is not specified with -w or -c.
--label=[string]
Optional custom label before results prefixed to results
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 15)

SNMP Access Options:
-H, --hostname=HOST
name or IP address of host to check (if not localhost)
-C, --community=COMMUNITY NAME
community name for the SNMP agent (used with v1 or v2c protocols)
-2, --v2c
use snmp v2c (can not be used with -l, -x)
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocols (des|aes : default des)
-p, --port=PORT
SNMP port (Default 161)
Using the above as a guide, we can craft a command that will check the uptime of a remote server using common SNMP OID's. Please take a look at the following examples:

Code: Select all

/usr/local/nagios/libexec/check_uptime.pl -H 192.168.x.x -C public

Code: Select all

/usr/local/nagios/libexec/check_uptime.pl -H 192.168.4.146 -C public -T unix-host
Use the help menu to craft your command. When you're finished, you can define the command in the 'commands' section of CCM and generate services based on it. Please let me know if you need help with that portion of the setup. Thanks!

Re: check_uptime

Posted: Fri May 01, 2015 1:15 pm
by Box293
abrist wrote:Now as we usually want to warn about boxes that have too low of an uptime (signifies they rebooted), you may want to use the syntax: "<ticks>:"
For example, the following check will warn when under 50k ticks, and crit when under 10k ticks:

Code: Select all
[root@localhost libexec]# ./check_snmp -H localhost -C public -o 1.3.6.1.2.1.1.3.0 -w 50000: -c 10000:
SNMP WARNING - *36916* | iso.3.6.1.2.1.1.3.0=36916;0;0;
8600000 = 1 day in timeticks

Re: check_uptime

Posted: Tue May 05, 2015 8:53 am
by btemple
Thank you guys for the info. I think I have it working as expected. This thread can be closed