#!/usr/bin/perl ######################################################################## # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see .# ######################################################################## use strict; use warnings; use Switch; use Getopt::Std; our($opt_w, $opt_c, $opt_l, $opt_H, $opt_V); # $opt_w = warning, $opt_c = Critical, $opt_l = Label, $opt_H = host IP my $status; # Used to check if we passe the parameter to the option my $result; # Used to store the result my $version="0.1"; # Script version $status = getopts('w:c:l:H:V'); if (!$status) { die("Argument needed...\n"); exit 2; } if ($opt_V) { print "Check_snmp_temp_blade: $version\n"; exit 0; } $opt_l="Temprature" if (!$opt_l); # Set default label value #SNMP OK - "21.00 Centigrade" | Temprature=- ##### Edit the line below and change the YOUR_PASSPHRASE to yours ##### $result = `snmpget -a MD5 -v 3 -A YOUR_PASSPHRASE -x AES -u SNMPV3 -X YOUR_PASSPHRASE -l authPriv $opt_H .1.3.6.1.4.1.2.3.51.2.2.1.5.1.0`; ##### Edit the line above and change the YOUR_PASSPHRASE to yours ##### $result =~ s/.*\"(\d\d\.\d\d).*/$1/; chomp($result); if ( !$result ){ print "$opt_l UNKNOW - No Temperature return"; exit 3; } switch ($result) { case { $result < $opt_w } { print "$opt_l OK - \"$result Centigrade\" | $opt_l=$result;$opt_w;$opt_c;15;35\n"; exit 0; } case { $result >= $opt_c } { print "$opt_l CRITICAL - \"$result Centigrade\" | $opt_l=$result;$opt_w;$opt_c;15;35\n"; exit 2; } case { $result >= $opt_w } { print "$opt_l WARNING - \"$result Centigrade\" | $opt_l=$result;$opt_w;$opt_c;15;35\n"; exit 1; } else { print "$opt_l UNKNOWN - \"$result\" | $opt_l=$result;$opt_w;$opt_c;15;35\n"; exit 3; } } #print "$opt_l=$result;$opt_w;$opt_c;15;35\n"; #'label'=value[UOM];[warn];[crit];[min];[max]