From 045e73217460194021286659a6fb4a730cc301e3 Mon Sep 17 00:00:00 2001 From: Stanley Hopcroft Date: Thu, 27 Jan 2005 04:54:16 +0000 Subject: New /contrib plugin git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1113 f882894a-f735-0410-b71e-b25c423dba1c --- contrib/check_fan_fsc_present | 135 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 contrib/check_fan_fsc_present (limited to 'contrib/check_fan_fsc_present') diff --git a/contrib/check_fan_fsc_present b/contrib/check_fan_fsc_present new file mode 100644 index 00000000..5bddb87c --- /dev/null +++ b/contrib/check_fan_fsc_present @@ -0,0 +1,135 @@ +#!/usr/bin/perl +# +# +# check_most.pl -i -p -c community -o [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 + +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_f $opt_h $PROGNAME); +use lib $main::runtimedir; +use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); +use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS); + +delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer + +getopts('H:p:C:f: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 $fan = $opt_f ; + +#my $err_counter=0 ; +#my $err_status=""; + + my $fan_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,4,0,$fan-1 ); +# not used for the moment - gives no usable output +# if reused, enter at end of list to avoid renumbering ! + my $fan_cur_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,8,0,$fan-1 ); + my $fan_nom_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,9,0,$fan-1 ); + my $fan_cur_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,10,0,$fan-1 ); + my $fan_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,3,0,$fan-1 ); + 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 ($fan_locale_oid, $fan_cur_speed_oid, $fan_nom_max_speed_oid, $fan_cur_max_speed_oid, $fan_condition_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_fan_locale= $r_array[1]; + $result_fan_cur_speed= $r_array[2]; + $result_fan_nom_max_speed= $r_array[3]; + $result_fan_cur_max_speed= $r_array[4]; + $result_fan_condition=$r_array[5]; + + + if ( $result_fan_condition != "3" ) { + print "Fan ". $fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; + exit $ERRORS{'CRITICAL'} ; + } + else { + print "Fan " .$fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; + exit $ERRORS{'OK'} ; + } + + +sub print_usage () { + print "Usage: $PROGNAME -H -p -C -f \n"; + } + +sub print_help () { + print_revision($PROGNAME,'$Revision$\n '); + print "Copyright (c) 2003 Rainer Duffner\n "; + print_usage(); + print "\n"; + print " = IP-Address or DNS-Name of the W2K-Server\n"; + print " = SNMP-Port (normaly 161)\n"; + print " = SNMP v1 community\n"; + print " = Fannumber (1, 2, 3 etc.)\n"; + } + +sub version () { + print_revision($PROGNAME,'$Revision$ '); + exit $ERRORS{'OK'}; +} + +sub help () { + print_help(); + exit $ERRORS{'OK'}; +} + -- cgit v1.2.3-74-g34f1