Vedr.: RE: Use SNMP and check_ping to check the server downtime
Thomas Jens Lauritsen
tjl at topdanmark.dk
Thu Jan 12 09:23:21 CET 2006
Good Morning,
If you have installed the Net-SMNP package - I think it's called that. Then
you can run a snmpwalk command.
This command should work for a w2k box.
snmpwalk -v 1 your-server-ip -c public .1.3.6.1.4.1
I use this script below to give me a waring If a box has been rebooted
recently. Sometime W2K boxes are set to do that....
then I can investigate or try to find the problem ;-)
In the script below you can se a line like this:
usr/bin/snmpget $SERVER $SNMPCOMUNITY .system.sysUpTime.0
It simply check the uptime of a w2k box....
------------------------ script start - and don't use this line in your
script -----------------------
#!/bin/sh
#
# check_booted.sh via SNMP
#
# Autor : Thomas Jens Lauritsen <tjl at topdanmark.dk>
# Date : 2004-06-04 (yyyy-mm-dd)
# Changed : 2005-11-12 - New description
# Version : 1.1
# Purpose : Check if a server has been booted recently
# Description : Script that checks if a box just has been booted via
SNMP.
# Req. : The script uses the bc - calulator (Installed on most
*nix's)
# Advice : Run the script for every 10 min - to keep the load down
on the cpu.
# Nagios : In the services.cfg. Exampel:
check_booted.sh!public!100!1000!
# Info : You have to change Oid for your system - see below (num1
and num2).
#
# crit warn
# ./check_booted.sh <ip-address> <public> <100> <1000>
#
# Verify that there is an input - if not then show syntax
# -------------------------------------------------------
#
if [ -z "$1" ]; then
echo "usage : check_booted.sh <hostname> <snmp-community> <crit-num1>
<warn-num2>"
echo "example: check_booted.sh 192.168.1.1 public 2 2 100 1000"
echo
exit
fi
#
# Variables
# ---------
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/utils.sh
SERVER=$1 # Example: 10.0.0.3
SNMPCOMUNITY=$2 # Example: public
NUM1=$3 # Example: "10" = 10 minutes CRITICAL
NUM2=$4 # Example: "120"= 120 minutes WARNING
# GET UpTime VALUE in Miliseconds
MILISEC=`/usr/bin/snmpget $SERVER $SNMPCOMUNITY .system.sysUpTime.0 | awk
'{ print $4 }'|bc`
#echo $MILISEC
RESULT=`echo $MILISEC/100/60 | bc`
#echo $RESULT in minutes
# TELL NAGIOS WHAT WE COLLECTED - AND GIVE IT A STATE
if [ "$RESULT" -le "$NUM1" ] ; then
$ECHO "BOOTED $RESULT Minutes ago..\n"
exitstatus=$STATE_CRITICAL
elif [ "$RESULT" -le "$NUM2" ] ; then
$ECHO "BOOTED $RESULT Minutes ago..\n"
exitstatus=$STATE_WARNING
elif [ "$RESULT" -ge "$NUM2" ] ; then
$ECHO "UPTIME - OK $RESULT Minutes\n"
exitstatus=$STATE_OK
else
$ECHO "UPTIME - UNKNOWN $RESULT Minutes\n"
exitstatus=$STATE_UNKNOWN
fi
------------------------ script stop - and don't use this line in your
script -----------------------
|---------+---------------------------------------->
| | <Lui.external at infineon.com> |
| | Sendt af: |
| | nagios-users-admin at lists.sour|
| | ceforge.net |
| | |
| | |
| | 12-01-2006 08:15 |
| | |
|---------+---------------------------------------->
>--------------------------------------------------------------------------------------------------------------|
| |
| Til: <nagios-users at lists.sourceforge.net> |
| cc: |
| Vedr.: RE: [Nagios-users] Use SNMP and check_ping to check the server downtime |
>--------------------------------------------------------------------------------------------------------------|
I had wrote a perl script to execute "check_ping" and manipulate the
result.
Now, I would like to add in the SNMP uptime checking to get a more
accurate downtime data.
Just want to know what are the mechanism can be used to achieve the SNMP
uptime checking?
-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Hugo van
der Kooij
Sent: Thursday, January 12, 2006 2:55 PM
To: nagios-users at lists.sourceforge.net
Subject: Re: [Nagios-users] Use SNMP and check_ping to check the server
downtime
On Thu, 12 Jan 2006 Lui.external at infineon.com wrote:
> I am planning to use SNMP + check_ping to get the availability of
> server in Nagios.
> Can anyone guide me on this?
And just what effort have you put into this yourself?
What do you want to obtain? What have you tried? How did it go?
Hugo.
--
I hate duplicates. Just reply to the relevant mailinglist.
hvdkooij at vanderkooij.org
http://hvdkooij.xs4all.nl/
Don't meddle in the affairs of magicians,
for they are subtle and quick to anger.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems? Stop! Download the new AJAX search engine that
makes searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
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
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
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
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
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