Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
>
nagios-plugins-snmp
> check_snmp_klima
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_snmp_klima of Package nagios-plugins-snmp
#!/usr/bin/php5 <?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); } ?>