diff options
Diffstat (limited to 'contrib/check_fan_cpq_present')
| -rw-r--r-- | contrib/check_fan_cpq_present | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/contrib/check_fan_cpq_present b/contrib/check_fan_cpq_present deleted file mode 100644 index 0bd13909..00000000 --- a/contrib/check_fan_cpq_present +++ /dev/null | |||
| @@ -1,133 +0,0 @@ | |||
| 1 | #!/usr/bin/perl | ||
| 2 | # | ||
| 3 | # | ||
| 4 | # check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical] | ||
| 5 | # | ||
| 6 | # NetSaint host script to get the disk usage from NT snmp | ||
| 7 | # | ||
| 8 | # Changes and Modifications | ||
| 9 | # ========================= | ||
| 10 | # 3-Aug-2000 - Xavier Dusart | ||
| 11 | # Created | ||
| 12 | # 2003 - Rainer Duffner | ||
| 13 | |||
| 14 | BEGIN { | ||
| 15 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
| 16 | $runtimedir = $1; | ||
| 17 | $PROGNAME = $2; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | require 5.004; | ||
| 24 | use POSIX; | ||
| 25 | #use strict; | ||
| 26 | use Getopt::Std ; | ||
| 27 | use BER; | ||
| 28 | require 'SNMP_Session.pm'; | ||
| 29 | use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME); | ||
| 30 | use lib $main::runtimedir; | ||
| 31 | use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); | ||
| 32 | use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED); | ||
| 33 | |||
| 34 | delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer | ||
| 35 | |||
| 36 | getopts('H:p:C:f:hV') ; | ||
| 37 | |||
| 38 | my $ip_address=undef ; | ||
| 39 | |||
| 40 | if ($opt_h) {&help();} | ||
| 41 | |||
| 42 | if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA | ||
| 43 | -Z0-9]*)*)$/) { | ||
| 44 | $ip_address = $opt_H ; | ||
| 45 | } | ||
| 46 | else { | ||
| 47 | usage(); | ||
| 48 | print "IP-Address format wrong\n"; | ||
| 49 | exit $ERRORS{'UNKNOWN'}; | ||
| 50 | } | ||
| 51 | |||
| 52 | #if ($opt_p =~ m/^[0-9] | ||
| 53 | |||
| 54 | my $port = $opt_p; | ||
| 55 | |||
| 56 | my $community = $opt_C; | ||
| 57 | |||
| 58 | my $fan = $opt_f ; | ||
| 59 | |||
| 60 | #my $err_counter=0 ; | ||
| 61 | #my $err_status=""; | ||
| 62 | |||
| 63 | my $fan_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,3,0,$fan ); | ||
| 64 | # not used for the moment - gives no usable output | ||
| 65 | # if reused, enter at end of list to avoid renumbering ! | ||
| 66 | my $fan_present_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,4,0,$fan ); | ||
| 67 | my $fan_speed_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,6,0,$fan ); | ||
| 68 | my $fan_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,9,0,$fan ); | ||
| 69 | my $count=1 ; | ||
| 70 | my $label ; | ||
| 71 | my @r_array=(); | ||
| 72 | my $q ; | ||
| 73 | my $diff ; | ||
| 74 | $warning=$warning/100 ; | ||
| 75 | $crititcal=$critical/100 ; | ||
| 76 | |||
| 77 | |||
| 78 | # get temperature, temperature_threshold bfore shutdown | ||
| 79 | my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; | ||
| 80 | |||
| 81 | if ($session->get_request_response ($fan_present_oid, $fan_locale_oid, $fan_speed_oid, $fan_condition_oid )) { | ||
| 82 | (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); | ||
| 83 | while ($bindings ne '') { | ||
| 84 | ($binding, $bindings) = &decode_sequence ($bindings) ; | ||
| 85 | ($oid,$value) = &decode_by_template ($binding,"%O%@"); | ||
| 86 | $r_array[$count]=&pretty_print($value); | ||
| 87 | $count++; | ||
| 88 | } | ||
| 89 | } else { | ||
| 90 | print "No response from agent\n"; | ||
| 91 | exit $ERRORS{'CRITICAL'}; | ||
| 92 | } | ||
| 93 | $result_fan_present= $r_array[1]; | ||
| 94 | $result_fan_locale= $r_array[2]; | ||
| 95 | $result_fan_speed= $r_array[3]; | ||
| 96 | $result_fan_condition=$r_array[4]; | ||
| 97 | |||
| 98 | |||
| 99 | if ( $result_fan_present != 3 || $result_fan_speed !=2 ) { | ||
| 100 | print "Fan ". $fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; | ||
| 101 | exit $ERRORS{'CRITICAL'} ; | ||
| 102 | } | ||
| 103 | else { | ||
| 104 | print "Fan " .$fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; | ||
| 105 | exit $ERRORS{'OK'} ; | ||
| 106 | } | ||
| 107 | |||
| 108 | |||
| 109 | sub print_usage () { | ||
| 110 | print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n"; | ||
| 111 | } | ||
| 112 | |||
| 113 | sub print_help () { | ||
| 114 | print_revision($PROGNAME,'$Revision: 1113 $\n '); | ||
| 115 | print "Copyright (c) 2003 Rainer Duffner\n "; | ||
| 116 | print_usage(); | ||
| 117 | print "\n"; | ||
| 118 | print "<host> = IP-Address or DNS-Name of the W2K-Server\n"; | ||
| 119 | print "<port> = SNMP-Port (normaly 161)\n"; | ||
| 120 | print "<community> = SNMP v1 community\n"; | ||
| 121 | print "<fannumber> = Fannumber (1, 2, 3 etc.)\n"; | ||
| 122 | } | ||
| 123 | |||
| 124 | sub version () { | ||
| 125 | print_revision($PROGNAME,'$Revision: 1113 $ '); | ||
| 126 | exit $ERRORS{'OK'}; | ||
| 127 | } | ||
| 128 | |||
| 129 | sub help () { | ||
| 130 | print_help(); | ||
| 131 | exit $ERRORS{'OK'}; | ||
| 132 | } | ||
| 133 | |||
