Imported Upstream version 1.4.5
This commit is contained in:
parent
62d1e7d5fe
commit
6a280f6f24
412 changed files with 168642 additions and 0 deletions
162
contrib/check_temp_cpq
Normal file
162
contrib/check_temp_cpq
Normal file
|
@ -0,0 +1,162 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
#
|
||||
# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
|
||||
#
|
||||
# NetSaint host script to get the disk usage from NT snmp
|
||||
#
|
||||
# Changes and Modifications
|
||||
# =========================
|
||||
# 3-Aug-2000 - Xavier Dusart
|
||||
# Created
|
||||
# 2003 - Rainer Duffner
|
||||
# Note: CPQ starts numbering sensors etc. with "1"
|
||||
|
||||
BEGIN {
|
||||
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
|
||||
$runtimedir = $1;
|
||||
$PROGNAME = $2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
require 5.004;
|
||||
use POSIX;
|
||||
#use strict;
|
||||
use Getopt::Std ;
|
||||
use BER;
|
||||
require 'SNMP_Session.pm';
|
||||
use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
|
||||
use lib $main::runtimedir;
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support );
|
||||
|
||||
use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
|
||||
|
||||
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
|
||||
|
||||
|
||||
getopts('H:p:C:s:w:c:hV') ;
|
||||
|
||||
my $ip_address=undef ;
|
||||
|
||||
if ($opt_h) {&help();}
|
||||
|
||||
if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
|
||||
-Z0-9]*)*)$/) {
|
||||
$ip_address = $opt_H ;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
print "IP-Address format wrong\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
#if ($opt_p =~ m/^[0-9]
|
||||
|
||||
my $port = $opt_p;
|
||||
|
||||
my $community = $opt_C;
|
||||
|
||||
my $sensor = $opt_s ;
|
||||
|
||||
my $warning = $opt_w;
|
||||
|
||||
my $critical = $opt_c;
|
||||
|
||||
|
||||
my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,3,0,$sensor );
|
||||
# not used for the moment - gives no usable output
|
||||
# if reused, enter at end of list to avoid renumbering !
|
||||
my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,4,0,$sensor );
|
||||
my $temperature_threshold_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,5,0,$sensor );
|
||||
my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,6,0,$sensor );
|
||||
my $count=1 ;
|
||||
my $label ;
|
||||
my @r_array=();
|
||||
my $q ;
|
||||
my $diff ;
|
||||
$warning=$warning/100 ;
|
||||
$crititcal=$critical/100 ;
|
||||
|
||||
|
||||
# get temperature, temperature_threshold bfore shutdown
|
||||
my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
|
||||
|
||||
if ($session->get_request_response ($temperature_celsius_oid, $temperature_threshold_oid, $temperature_condition_oid, $temperature_locale_oid )) {
|
||||
(my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
|
||||
while ($bindings ne '') {
|
||||
($binding, $bindings) = &decode_sequence ($bindings) ;
|
||||
($oid,$value) = &decode_by_template ($binding,"%O%@");
|
||||
$r_array[$count]=&pretty_print($value);
|
||||
$count++;
|
||||
}
|
||||
} else {
|
||||
print "No response from agent\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
$result_celsius=$r_array[1];
|
||||
$result_threshold=$r_array[2];
|
||||
$result_condition=$r_array[3];
|
||||
$result_locale=$r_array[4];
|
||||
|
||||
if ($result_celsius < 0) {
|
||||
print "Result is negative - Sensor unavailable ?\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
if ($result_threshold==0) {
|
||||
print "Division by zero \n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
if ($result_condition=="2") {
|
||||
$result_condition="OK";
|
||||
}
|
||||
else {
|
||||
$result_condition=$result_condition." (other)";
|
||||
}
|
||||
$q=$result_celsius/$result_threshold ;
|
||||
$diff=$result_threshold-$result_celsius ;
|
||||
|
||||
|
||||
if ( $q > $critical ) {
|
||||
print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
|
||||
exit $ERRORS{'CRITICAL'} ;
|
||||
}
|
||||
elsif ( $q > $warning ) {
|
||||
print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
|
||||
exit $ERRORS{'WARNING'} ;
|
||||
}
|
||||
else {
|
||||
print "Sensor " .$sensor. " (".$CPQ_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
|
||||
exit $ERRORS{'OK'} ;
|
||||
}
|
||||
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> [-w <warn>] [-c <crit>]\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print_revision($PROGNAME,'$Revision: 1.1 $\n ');
|
||||
print "Copyright (c) 2003 Rainer Duffner\n ";
|
||||
print_usage();
|
||||
print "\n";
|
||||
print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
|
||||
print "<port> = SNMP-Port (normaly 161)\n";
|
||||
print "<community> = SNMP v1 community\n";
|
||||
print "<sensornumber> = Sensornumber (1, 2, 3 etc.)\n";
|
||||
print "<warn> = report warning when more than <warn> % of the temperature is reached defaults to 80\n";
|
||||
print "<crit> = report critical when more than <crit> % of the temperature is reached defaults to 90\n";
|
||||
}
|
||||
|
||||
sub version () {
|
||||
print_revision($PROGNAME,'$Revision: 1.1 $ ');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
sub help () {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue