checking for reboots of a host
Andreas Ericsson
ae at op5.se
Mon Aug 23 14:54:18 CEST 2004
Frank Pikelner wrote:
> Yes, I'm currently using SNMP to obtain uptime of hosts and network devices.
> Is there a way of doing comparison from the return value in the standard
> script?
>
> I would like to check if value X returned is less than < 86400 (seconds for
> 24 hours), if less than then return uptime with a WARNING, if greater than
>
>>= 86400 simply return uptime (okay)
>
Simplest possible;
-----------
#!/bin/bash
uptime=`snmpwalk -m: -v 1 -c <community> -Ovq $1 <uptime-oid>`
ret=$?
if [ $ret -ne 0 ]; then
echo "SNMP ERROR: snmpget returned $ret"
exit 2
fi
if [ $uptime -gt 86400 ]; then
echo "OK: $1 has made it past its first 24 hours"
exit 0
fi
echo "WARNING: $1 has uptime less than 24 hours ($uptime seconds)"
exit 1
-------------
Cut 'n paste.
The above script runs faster than anything but a pure C plugin, since it
forks only once and parses no mib files.
>
> Frank
>
> <steve wrote>
>
> couldn't you use SNMP to pull the uptime from the host? (Assuming the hosts
> have some SNMP daemon running) Even a custom script that stores the returned
> info, so on next check, it can compare it... if current uptime for host "X"
> is less that last uptime for host "X", then alert?
>
> Steve
>
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list