[-]
[+]
|
Changed |
nagios-plugins-snmp.spec
|
|
[-]
[+]
|
Added |
check_snmp_brocade200E
^
|
@@ -0,0 +1,122 @@
+#!/usr/bin/php
+<?php
+/*
+** Author
+** Original author Carsten Schoene (cs@linux-administrator.com)
+**
+** Copyright
+** Copyright (c) 2008 linux-administrator.com
+** All Rights Reserved.
+*/
+// Last change: 2008-09-11
+// required arguments
+// $1 = Host / IP
+// $2 = read community string
+$switchType = "SNMPv2-SMI::mib-2.47.1.1.1.1.2.1";
+
+$grad = iconv("UTF-8","ISO-8859-15","°");
+define('MYNAME',"check_snmp_brocade200E");
+define('OK',0);
+define('WARNING',1);
+define('CRITICAL',2);
+define('UNKNOWN',3);
+define('DEPENDENT',4);
+
+define_syslog_variables();
+openlog(MYNAME,LOG_PID | LOG_ODELAY,LOG_MAIL);
+
+if ( ! extension_loaded("snmp") ) {
+ if ( ! dl("snmp") ) {
+ syslog(LOG_ERR,"snmp extension not loaded!");
+ exit;
+ }
+}
+ini_set("display_errors","on");
+// get working directory
+define('BASE',dirname(__FILE__));
+
+$cmdlineopt = getopt("H:C:");
+if (empty($cmdlineopt)) {
+ echo "Usage: " . MYNAME . " -H [<hostname> | <ipaddress>] -C [<community>]\n";
+ echo "\t -H\t Hostname or IP address (default: localhost)\n";
+ echo "\t -C\t Community (default: public)\n";
+ exit(1);
+}
+if ( isset($cmdlineopt['H']) ) {
+ $hostname = $cmdlineopt['H'];
+} else {
+ $hostname = "localhost";
+}
+
+if ( isset($cmdlineopt['C']) ) {
+ $community = $cmdlineopt['C'];
+} else {
+ $community = "public";
+}
+$swTypeline = @snmpget($hostname,$community,$switchType);
+if ( $swTypeline == FALSE ) {
+ echo "Can't get switchtype\n";
+ exit(UNKNOWN);
+} else {
+ $swTypearr = explode(": ",$swTypeline);
+ $swType = $swTypearr[1];
+}
+
+switch ($swType) {
+ case "\"SilkWorm200E\"":
+ $sensorIDX = ".1.3.6.1.3.94.1.8.1.2";
+ $sensorName = ".1.3.6.1.3.94.1.8.1.3";
+ $sensorStatus = ".1.3.6.1.3.94.1.8.1.4";
+ $sensorInfo = ".1.3.6.1.3.94.1.8.1.5";
+ $sensorMsg = ".1.3.6.1.3.94.1.8.1.6";
+ $oid_add = ".16.0.0.5.30.10.38.186.0.0.0.0.0.0.0.0.";
+ define(1,'STATUS_UNKOWN');
+ define(2,'STATUS_OTHER');
+ define(3,'STATUS_OK');
+ define(4,'STATUS_WARN');
+ define(5,'STATUS_FAIL');
+ $sensorCount = count(@snmpwalk($hostname,$community,$sensorIDX));
+
+ if ($sensorCount > 0 ) {
+
+ for ( $a = 1 ; $a <= $sensorCount ; $a++ ) {
+
+ $sNameline = @snmpget($hostname,$community,$sensorName . $oid_add . $a);
+ $sNamearr = explode("\"",$sNameline);
+ $sName = $sNamearr[1];
+ $sStatusline = @snmpget($hostname,$community,$sensorStatus . $oid_add . $a);
+ $sStatusarr = explode(": ",$sStatusline);
+ $sStatus = $sStatusarr[1];
+ $sMsgline = @snmpget($hostname,$community,$sensorMsg . $oid_add . $a);
+ $sMsglinearr0 = explode("\"",$sMsgline);
+ $sMsglinearr1 = explode(" ",$sMsglinearr0[1]);
+ $sMsgVal = $sMsglinearr1[9];
+ if ( $a == 1 ) {
+ $output = "$sName => $sMsgVal (" . constant($sStatus) . ")";
+ } else {
+ $output .= " , $sName => $sMsgVal (" . constant($sStatus) . ")";
+ }
+ }
+ print $output . "\n";
+ if ( ereg('STATUS_FAIL',$output) ) {
+ exit(CRITICAL);
+ }
+ if ( ereg('STATUS_WARN',$output) ) {
+ exit(WARNGING);
+ }
+ if ( ereg('STATUS_UNKOWN',$output) ) {
+ exit(UNKNOWN);
+ }
+ if ( ereg('STATUS_OTHER',$output) ) {
+ exit(UNKNOWN);
+ }
+ if ( ereg('STATUS_OK',$output) ) {
+ exit(OK);
+ }
+
+ }
+ break;
+ default:
+ echo "Switchtype $swType is currently not supported";
+}
+?>
|
[-]
[+]
|
Added |
check_snmp_disk
^
|
@@ -0,0 +1,143 @@
+#!/bin/bash
+
+# Licensed under GPL. See http://www.fsf.org/licensing/licenses/gpl.html#SEC1
+# Based on private work from poc@pocnet.net - (c) 2006
+
+# Fixes/Changes:
+# Works now with old snmp-utils (Debian Woody Style)
+# Won't get overflow with big disks anymore (but needs bc)
+
+# FIXME: Spaces in storage descr won't get processed properly by getopt
+
+unset LANG LANGUAGE
+
+MYNAME=`basename $0`
+PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+test -x $PROGPATH/utils.sh && . $PROGPATH/utils.sh
+
+# Ohne Parameter blöde machen
+if [ $# -lt 1 ]; then
+ printf "Usage: ${MYNAME} -w limit -c limit -h host [ -s snmp-community ] [ <path> | -l | mem | swap ]\n"
+ exit ${STATE_UNKNOWN}
+fi
+
+# Optionen parsen: ${GETOPT} unter Shell ist der größte Mist, wenn's um : Args geht
+NEXT_IS_W=0
+NEXT_IS_C=0
+NEXT_IS_H=0
+NEXT_IS_S=0
+NEXT_IS_DASH=0
+#
+OPTSTRING=`getopt "vc:w:h:s:l" $*`
+test $? -ne 0 && exit ${STATE_UNKNOWN}
+for OPTION in ${OPTSTRING}; do
+ if [ ${NEXT_IS_W} -eq 1 ]; then
+ WARNLEVEL=$OPTION
+ NEXT_IS_W=0
+ elif [ ${NEXT_IS_C} -eq 1 ]; then
+ CRITLEVEL=$OPTION
+ NEXT_IS_C=0
+ elif [ ${NEXT_IS_S} -eq 1 ]; then
+ COMMUNITY=$OPTION
+ NEXT_IS_S=0
+ elif [ ${NEXT_IS_DASH} -eq 1 ]; then
+ MOUNTPATH=$OPTION
+ NEXT_IS_DASH=0
+ elif [ ${NEXT_IS_H} -eq 1 ]; then
+ HOST=$OPTION
+ NEXT_IS_H=0
+ fi
+
+ case "${OPTION}" in
+ "-v")
+ echo '$Id: check_snmp_disk,v 1.4 2007/06/07 10:01:00 pschindler Exp $'
+ exit ${STATE_UNKNOWN}
+ ;;
+ "-w")
+ NEXT_IS_W=1
+ ;;
+ "-c")
+ NEXT_IS_C=1
+ ;;
+ "-s")
+ NEXT_IS_S=1
+ ;;
+ "--")
+ NEXT_IS_DASH=1
+ ;;
+ "-h")
+ NEXT_IS_H=1
+ ;;
+ "-l")
+ snmpwalk -v1 -OQ -c "${COMMUNITY}" "${HOST}" HOST-RESOURCES-MIB::hrStorageDescr
+ exit ${STATE_UNKNOWN}
+ ;;
+ esac
+done
+
+unset NEXT_IS_W NEXT_IS_C NEXT_IS_DASH NEXT_IS_H NEXT_IS_S
+
+# Sanity Check
+if [ -z "${MOUNTPATH}" ]; then
+ echo "You MUST supply a path to monitor."
+ exit ${STATE_UNKNOWN}
+fi
+if [ -z "${HOST}" ]; then
+ echo "You MUST supply a host to monitor."
+ exit ${STATE_UNKNOWN}
+fi
+if [ -z "${COMMUNITY}" ]; then
+ COMMUNITY="public"
+fi
+if [ \( ! -z "${CRITLEVEL}" -o ! -z "${WARNLEVEL}" \) -a ${CRITLEVEL} -lt ${WARNLEVEL} ]; then
+ echo "Warning level must be less or equal to crit level."
+ exit ${STATE_UNKNOWN}
+fi
+
+# Replace dummy values with the real ones
+if [ "${MOUNTPATH}" = "mem" ]; then
+ MOUNTPATH="Real Memory"
+elif [ "${MOUNTPATH}" = "swap" ]; then
+ MOUNTPATH="Swap Space"
+fi
+
+# Search for Device
+SNMPLINE=`snmpwalk -v1 -OQ -c "${COMMUNITY}" "${HOST}" host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageDescr |grep "${MOUNTPATH}\$"`
+if [ $? -ne 0 ]; then
+ echo "Error: Mount Path not found."
+ exit ${STATE_UNKNOWN}
+fi
+
+# Now get the wanted device's index
+INDEX=`echo ${SNMPLINE} |sed 's/^.*hrStorageDescr\.\([0-9]*\) = .*$/\1/'`
+
+# Next, get neccessary information for some mathematics
+SIZE=`snmpget -v1 -OQv -c "${COMMUNITY}" "${HOST}" host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageSize.${INDEX}`
+USED=`snmpget -v1 -OQv -c "${COMMUNITY}" "${HOST}" host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.${INDEX}`
+
+if [ -z "${SIZE}" -o -z "${USED}" ]; then
+ echo "Could not get size values."
+ exit ${STATE_UNKNOWN}
+fi
+
+if [ ${SIZE} -eq 0 -o ${USED} -eq 0 ]; then
+ echo "Size values are zero."
+ exit ${STATE_UNKNOWN}
+fi
+
+# Now calculon, compute! Ergebnis muß sein: % free
+FREE=`echo "$SIZE - $USED" |bc`
+PCT=`echo "100 * $USED / $SIZE" |bc`
+
+if [ ${PCT} -ge ${CRITLEVEL} ]; then
+ echo "DISK CRITICAL [${PCT}% used on ${MOUNTPATH}]"
+ exit ${STATE_CRITICAL}
+elif [ ${PCT} -ge ${WARNLEVEL} ]; then
+ echo "DISK WARNING [${PCT}% used on ${MOUNTPATH}]"
+ exit ${STATE_WARNING}
+else
+ echo "DISK OK [${PCT}% used on ${MOUNTPATH}]"
+ exit ${STATE_OK}
+fi
+
+# EOF
|
[-]
[+]
|
Added |
check_snmp_klima
^
|
@@ -0,0 +1,98 @@
+#!/usr/bin/php
+<?php
+/*
+** Author
+** Original author Carsten Schoene (cs@linux-administrator.com)
+**
+** Copyright
+** Copyright (c) 2008 linux-administrator.com
+** All Rights Reserved.
+*/
+
+// required arguments
+// $1 = Host / IP
+// $2 = read community string
+
+$lowerthreshold = "SNMPv2-SMI::enterprises.1909.13.1.1.1.3.1";
+$upperthreshold = "SNMPv2-SMI::enterprises.1909.13.1.1.1.4.1";
+$currenttemprature = "SNMPv2-SMI::enterprises.1909.13.1.1.1.5.1";
+$grad = iconv("UTF-8","ISO-8859-15","°");
+define('MYNAME',"check_rms200");
+define('OK',0);
+define('WARNING',1);
+define('CRITICAL',2);
+define('UNKNOWN',3);
+define('DEPENDENT',4);
+
+define_syslog_variables();
+openlog(MYNAME,LOG_PID | LOG_ODELAY,LOG_MAIL);
+
+if ( ! extension_loaded("snmp") ) {
+ if ( ! dl("snmp") ) {
+ syslog(LOG_ERR,"snmp extension not loaded!");
+ exit;
+ }
+}
+ini_set("display_errors","on");
+// get working directory
+define('BASE',dirname(__FILE__));
+
+$cmdlineopt = getopt("H:C:");
+if (empty($cmdlineopt)) {
+ echo "Usage: " . MYNAME . " -H [<hostname> | <ipaddress>] -C [<community>]\n";
+ echo "\t -H\t Hostname or IP address (default: localhost)\n";
+ echo "\t -C\t Community (default: public)\n";
+ exit(1);
+}
+if ( isset($cmdlineopt['H']) ) {
+ $hostname = $cmdlineopt['H'];
+} else {
+ $hostname = "localhost";
+}
+
+if ( isset($cmdlineopt['C']) ) {
+ $community = $cmdlineopt['C'];
+} else {
+ $community = "public";
+}
+$lowerval = @snmpget($hostname,$community,$lowerthreshold);
+if ( $lowerval == FALSE ) {
+ echo "Can't get lower threshold\n";
+ exit(UNKNOWN);
+} else {
+ $lowarr = explode(": ",$lowerval);
+ $lowerval = $lowarr[1];
+}
+$upperval = @snmpget($hostname,$community,$upperthreshold);
+if ( $upperval == FALSE ) {
+ echo "Can't get upper threshold\n";
+ exit(UNKNOWN);
+} else {
+ $upparr = explode(": ",$upperval);
+ $upperval = $upparr[1];
+}
+$currentval = @snmpget($hostname,$community,$currenttemprature);
+if ( $currentval == FALSE ) {
+ echo "Can't get current temprature value\n";
+ exit(UNKNOWN);
+} else {
+ $curarr = explode(": ",$currentval);
+ $currentval = $curarr[1];
+}
+$cur = $currentval / 100;
+$low = $lowerval / 100;
+$high = $upperval / 100;
+
+if ( $currentval < $lowerval ) {
+ echo "Current Temprature " . $cur . " " .$grad . "C is below threshold of " . $low . " " . $grad . "C\n";
+ exit(WARNING);
+}
+if ( $currentval > $upperval ) {
+ echo "Current Temprature " . $cur . " " . $grad . "C is over threshold of " . $high . " " . $grad . "C\n";
+ exit(CRITICAL);
+}
+if ( $currentval < $upperval && $currentval > $lowerval ) {
+ echo "Current Temprature is " . $cur . " " . $grad . "C\n";
+ exit(OK);
+}
+?>
|