summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:54:16 +0000
committerStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:54:16 +0000
commit045e73217460194021286659a6fb4a730cc301e3 (patch)
treed4e9665fad8911dbbb57186afcd7143bc5f1acb9
parentfce1f09f770fc5bbc6d323865af709ff515c803c (diff)
downloadmonitoring-plugins-045e73217460194021286659a6fb4a730cc301e3.tar.gz
New /contrib plugin
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1113 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--contrib/check_fan_cpq_present133
-rw-r--r--contrib/check_fan_fsc_present135
-rw-r--r--contrib/check_mysqlslave.pl174
-rw-r--r--contrib/check_temp_cpq162
-rw-r--r--contrib/check_temp_fsc160
5 files changed, 764 insertions, 0 deletions
diff --git a/contrib/check_fan_cpq_present b/contrib/check_fan_cpq_present
new file mode 100644
index 00000000..476a0c36
--- /dev/null
+++ b/contrib/check_fan_cpq_present
@@ -0,0 +1,133 @@
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
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36getopts('H:p:C:f:hV') ;
37
38my $ip_address=undef ;
39
40if ($opt_h) {&help();}
41
42if ($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 }
46else {
47 usage();
48 print "IP-Address format wrong\n";
49 exit $ERRORS{'UNKNOWN'};
50 }
51
52#if ($opt_p =~ m/^[0-9]
53
54my $port = $opt_p;
55
56my $community = $opt_C;
57
58my $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
109sub print_usage () {
110 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
111 }
112
113sub print_help () {
114 print_revision($PROGNAME,'$Revision$\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
124sub version () {
125 print_revision($PROGNAME,'$Revision$ ');
126 exit $ERRORS{'OK'};
127}
128
129sub help () {
130 print_help();
131 exit $ERRORS{'OK'};
132}
133
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 @@
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
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36getopts('H:p:C:f:hV') ;
37
38my $ip_address=undef ;
39
40if ($opt_h) {&help();}
41
42if ($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 }
46else {
47 usage();
48 print "IP-Address format wrong\n";
49 exit $ERRORS{'UNKNOWN'};
50 }
51
52#if ($opt_p =~ m/^[0-9]
53
54my $port = $opt_p;
55
56my $community = $opt_C;
57
58my $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,231,2,10,2,2,5,2,2,1,4,0,$fan-1 );
64# not used for the moment - gives no usable output
65# if reused, enter at end of list to avoid renumbering !
66 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 );
67 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 );
68 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 );
69 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 );
70 my $count=1 ;
71 my $label ;
72 my @r_array=();
73 my $q ;
74 my $diff ;
75 $warning=$warning/100 ;
76 $crititcal=$critical/100 ;
77
78
79# get temperature, temperature_threshold bfore shutdown
80 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
81
82 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 )) {
83 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
84 while ($bindings ne '') {
85 ($binding, $bindings) = &decode_sequence ($bindings) ;
86 ($oid,$value) = &decode_by_template ($binding,"%O%@");
87 $r_array[$count]=&pretty_print($value);
88 $count++;
89 }
90 } else {
91 print "No response from agent\n";
92 exit $ERRORS{'CRITICAL'};
93 }
94 $result_fan_locale= $r_array[1];
95 $result_fan_cur_speed= $r_array[2];
96 $result_fan_nom_max_speed= $r_array[3];
97 $result_fan_cur_max_speed= $r_array[4];
98 $result_fan_condition=$r_array[5];
99
100
101 if ( $result_fan_condition != "3" ) {
102 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" ;
103 exit $ERRORS{'CRITICAL'} ;
104 }
105 else {
106 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" ;
107 exit $ERRORS{'OK'} ;
108 }
109
110
111sub print_usage () {
112 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
113 }
114
115sub print_help () {
116 print_revision($PROGNAME,'$Revision$\n ');
117 print "Copyright (c) 2003 Rainer Duffner\n ";
118 print_usage();
119 print "\n";
120 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
121 print "<port> = SNMP-Port (normaly 161)\n";
122 print "<community> = SNMP v1 community\n";
123 print "<fannumber> = Fannumber (1, 2, 3 etc.)\n";
124 }
125
126sub version () {
127 print_revision($PROGNAME,'$Revision$ ');
128 exit $ERRORS{'OK'};
129}
130
131sub help () {
132 print_help();
133 exit $ERRORS{'OK'};
134}
135
diff --git a/contrib/check_mysqlslave.pl b/contrib/check_mysqlslave.pl
new file mode 100644
index 00000000..ab7af89f
--- /dev/null
+++ b/contrib/check_mysqlslave.pl
@@ -0,0 +1,174 @@
1#!/usr/bin/perl -w
2#
3# check_mysqlslave.pl - nagios plugin
4#
5#
6# Copyright 2002 Mario Witte
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version 2
11# of the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21#
22# Credits:
23# - Thanks to Christoph Kron <ck@zet.net> for check_ifstatus.pl
24# I used check_ifstatus.pl as a layout when writing this
25#
26# Report bugs to: chengfu@users.sourceforge.net
27#
28# 20.09.2002 Version 0.1
29
30
31use strict;
32use lib "/usr/local/nagios/libexec";
33use utils qw($TIMEOUT %ERRORS &print_revision &support);
34
35use DBI;
36use DBD::mysql;
37use Getopt::Long;
38Getopt::Long::Configure('bundling');
39
40# Predeclare some variables
41my $PROGNAME = 'check_mysqlslave';
42my $REVISION = '0.1';
43my $status;
44my $state = 'UNKNOWN';
45my $opt_V;
46my $opt_h;
47my $port = 3306;
48my $hostname;
49my $user = 'root';
50my $pass = '';
51my $driver;
52my $dbh;
53my $query;
54my $result;
55my $data;
56
57# Just in case of problems, let's not hang Nagios
58$SIG{'ALRM'} = sub {
59 print ("ERROR: No response from $hostname (alarm timeout)\n");
60 exit $ERRORS{"UNKNOWN"};
61};
62alarm($TIMEOUT);
63
64$status = GetOptions(
65 "V" => \$opt_V, "version" => \$opt_V,
66 "h" => \$opt_h, "help" => \$opt_h,
67 "p=i" => \$port, "port=i" => \$port,
68 "H=s" => \$hostname, "hostname=s" => \$hostname,
69 "u=s" => \$user, "user=s" => \$user,
70 "P=s" => \$pass, "pass=s" => \$pass,
71 );
72
73
74if ($status == 0) {
75 print_help() ;
76 exit $ERRORS{'OK'};
77}
78
79if ($opt_V) {
80 print_revision($PROGNAME,'$Revision$REVISION .' $ ');
81 exit $ERRORS{'OK'};
82}
83
84if ($opt_h) {
85 print_help();
86 exit $ERRORS{'OK'};
87}
88
89if (! utils::is_hostname($hostname)){
90 usage();
91 exit $ERRORS{"UNKNOWN"};
92}
93
94
95$driver = 'DBI:mysql::'. $hostname;
96
97eval {
98 $dbh = DBI->connect($driver, $user, $pass, { RaiseError => 1, PrintError => 0});
99};
100if ($@) {
101 $status = $@;
102 if ($status =~ /^.*failed:\ (.+)\ at\ $0/i) { $status = $1; }
103 $state='CRITICAL';
104 print $state .': Connect failed: '."$status\n";
105 exit ($ERRORS{$state});
106}
107
108eval {
109 $query = 'SHOW SLAVE STATUS';
110 $result = $dbh->prepare($query);
111 $result->execute;
112 $data = $result->fetchrow_hashref();
113 $result->finish();
114 $dbh->disconnect();
115};
116if ($@) {
117 $status = $@;
118 $status =~ s/\n/ /g;
119 if ($status =~ /^DB[ID].*(failed|prepare):\ (.+)\ at\ $0/i) { $status = $2; }
120 $state = 'CRITICAL';
121 print $state .': Couldn\'t check slave: '."$status\n";
122 exit($ERRORS{$state});
123}
124
125if ($data->{'Slave_Running'} eq 'Yes') {
126 $status = 'Replicating from '. $data->{'Master_Host'};
127 $state = 'OK';
128 print $state .': '. $status ."\n";
129 exit($ERRORS{$state});
130} elsif ($data->{'Slave_Running'} eq 'No') {
131 if (length($data->{'Last_error'}) > 0) {
132 $status = 'Slave stopped with error message';
133 $state = 'CRITICAL';
134 print $state .': '. $status ."\n";
135 exit($ERRORS{$state});
136 } else {
137 $status = 'Slave stopped without errors';
138 $state = 'WARNING';
139 print $state .': '. $status ."\n";
140 exit($ERRORS{$state});
141 }
142} else {
143 $status = 'Unknown slave status: (Running: '. $data->{'Slave_Running'} .')';
144 $state = 'UNKNOWN';
145 print $state .': '. $status ."\n";
146 exit($ERRORS{$state});
147}
148
149sub usage {
150 printf "\nMissing arguments!\n";
151 printf "\n";
152 printf "check_mysqlslave -H <hostname> [-p <port> -u <username> -P <password>]\n";
153 printf "Copyright 2002 Mario Witte\n";
154 printf "\n\n";
155 support();
156 exit $ERRORS{"UNKNOWN"};
157}
158
159sub print_help {
160 printf "check_mysqlslave plugin for Nagios checks \n";
161 printf "if the replication on a backup mysql-server\n";
162 printf "is up and running\n";
163 printf "\nUsage:\n";
164 printf " -H (--hostname) Hostname to query\n";
165 printf " -p (--port) mysql port (default: 3306)\n";
166 printf " -u (--user) username for accessing mysql host\n";
167 printf " (default: root)\n";
168 printf " -P (--pass) password for accessing mysql host\n";
169 printf " (default: '')\n";
170 printf " -V (--version) Plugin version\n";
171 printf " -h (--help) usage help \n\n";
172 print_revision($PROGNAME, '$Revision$REVISION .' $');
173
174}
diff --git a/contrib/check_temp_cpq b/contrib/check_temp_cpq
new file mode 100644
index 00000000..14b06a2b
--- /dev/null
+++ b/contrib/check_temp_cpq
@@ -0,0 +1,162 @@
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# Note: CPQ starts numbering sensors etc. with "1"
14
15BEGIN {
16 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
17 $runtimedir = $1;
18 $PROGNAME = $2;
19 }
20}
21
22
23
24require 5.004;
25use POSIX;
26#use strict;
27use Getopt::Std ;
28use BER;
29require 'SNMP_Session.pm';
30use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
31use lib $main::runtimedir;
32use utils qw($TIMEOUT %ERRORS &print_revision &usage &support );
33
34use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
35
36delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
37
38
39getopts('H:p:C:s:w:c:hV') ;
40
41my $ip_address=undef ;
42
43if ($opt_h) {&help();}
44
45if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
46-Z0-9]*)*)$/) {
47 $ip_address = $opt_H ;
48 }
49else {
50 usage();
51 print "IP-Address format wrong\n";
52 exit $ERRORS{'UNKNOWN'};
53 }
54
55#if ($opt_p =~ m/^[0-9]
56
57my $port = $opt_p;
58
59my $community = $opt_C;
60
61my $sensor = $opt_s ;
62
63my $warning = $opt_w;
64
65my $critical = $opt_c;
66
67
68 my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,3,0,$sensor );
69# not used for the moment - gives no usable output
70# if reused, enter at end of list to avoid renumbering !
71 my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,4,0,$sensor );
72 my $temperature_threshold_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,5,0,$sensor );
73 my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,6,0,$sensor );
74 my $count=1 ;
75 my $label ;
76 my @r_array=();
77 my $q ;
78 my $diff ;
79 $warning=$warning/100 ;
80 $crititcal=$critical/100 ;
81
82
83# get temperature, temperature_threshold bfore shutdown
84 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
85
86 if ($session->get_request_response ($temperature_celsius_oid, $temperature_threshold_oid, $temperature_condition_oid, $temperature_locale_oid )) {
87 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
88 while ($bindings ne '') {
89 ($binding, $bindings) = &decode_sequence ($bindings) ;
90 ($oid,$value) = &decode_by_template ($binding,"%O%@");
91 $r_array[$count]=&pretty_print($value);
92 $count++;
93 }
94 } else {
95 print "No response from agent\n";
96 exit $ERRORS{'CRITICAL'};
97 }
98 $result_celsius=$r_array[1];
99 $result_threshold=$r_array[2];
100 $result_condition=$r_array[3];
101 $result_locale=$r_array[4];
102
103 if ($result_celsius < 0) {
104 print "Result is negative - Sensor unavailable ?\n";
105 exit $ERRORS{'UNKNOWN'};
106 }
107 if ($result_threshold==0) {
108 print "Division by zero \n";
109 exit $ERRORS{'CRITICAL'};
110 }
111
112 if ($result_condition=="2") {
113 $result_condition="OK";
114 }
115 else {
116 $result_condition=$result_condition." (other)";
117 }
118 $q=$result_celsius/$result_threshold ;
119 $diff=$result_threshold-$result_celsius ;
120
121
122 if ( $q > $critical ) {
123 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" ;
124 exit $ERRORS{'CRITICAL'} ;
125 }
126 elsif ( $q > $warning ) {
127 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" ;
128 exit $ERRORS{'WARNING'} ;
129 }
130 else {
131 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" ;
132 exit $ERRORS{'OK'} ;
133 }
134
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> [-w <warn>] [-c <crit>]\n";
138 }
139
140sub print_help () {
141 print_revision($PROGNAME,'$Revision$\n ');
142 print "Copyright (c) 2003 Rainer Duffner\n ";
143 print_usage();
144 print "\n";
145 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
146 print "<port> = SNMP-Port (normaly 161)\n";
147 print "<community> = SNMP v1 community\n";
148 print "<sensornumber> = Sensornumber (1, 2, 3 etc.)\n";
149 print "<warn> = report warning when more than <warn> % of the temperature is reached defaults to 80\n";
150 print "<crit> = report critical when more than <crit> % of the temperature is reached defaults to 90\n";
151 }
152
153sub version () {
154 print_revision($PROGNAME,'$Revision$ ');
155 exit $ERRORS{'OK'};
156}
157
158sub help () {
159 print_help();
160 exit $ERRORS{'OK'};
161}
162
diff --git a/contrib/check_temp_fsc b/contrib/check_temp_fsc
new file mode 100644
index 00000000..6cae859c
--- /dev/null
+++ b/contrib/check_temp_fsc
@@ -0,0 +1,160 @@
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
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%FSC_LOCALE %FSC_TEMP_CONDITION);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36
37getopts('H:p:C:s:w:c:hV') ;
38
39my $ip_address=undef ;
40
41if ($opt_h) {&help();}
42
43if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
44-Z0-9]*)*)$/) {
45 $ip_address = $opt_H ;
46 }
47else {
48 usage();
49 print "IP-Address format wrong\n";
50 exit $ERRORS{'UNKNOWN'};
51 }
52
53#if ($opt_p =~ m/^[0-9]
54
55my $port = $opt_p;
56
57my $community = $opt_C;
58
59my $sensor = $opt_s ;
60
61#my $warning = $opt_w;
62
63#my $critical = $opt_c;
64
65
66 my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,4,0,$sensor-1 );
67# not used for the moment - gives no usable output
68# if reused, enter at end of list to avoid renumbering !
69 my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,11,0,$sensor-1 );
70 my $temperature_warning_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,6,0,$sensor-1 );
71 my $temperature_critical_oid =encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,8,0,$sensor-1 );
72 my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,3,0,$sensor-1 );
73 my $count=1 ;
74 my $label ;
75 my @r_array=();
76 my $q ;
77 my $diff ;
78 $warning=$warning/100 ;
79 $crititcal=$critical/100 ;
80
81
82# get temperature, temperature_threshold bfore shutdown
83 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
84
85 if ($session->get_request_response ($temperature_celsius_oid, $temperature_warning_oid, $temperature_critical_oid, $temperature_condition_oid, $temperature_locale_oid )) {
86 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
87 while ($bindings ne '') {
88 ($binding, $bindings) = &decode_sequence ($bindings) ;
89 ($oid,$value) = &decode_by_template ($binding,"%O%@");
90 $r_array[$count]=&pretty_print($value);
91 $count++;
92 }
93 } else {
94 print "No response from agent\n";
95 exit $ERRORS{'CRITICAL'};
96 }
97 $result_celsius=$r_array[1];
98 $result_warning=$r_array[2];
99 $result_critical=$r_array[3];
100 $result_condition=$r_array[4];
101 $result_locale=$r_array[5];
102
103 if ($result_celsius < 0) {
104 print "Result is negative - Sensor unavailable ?\n";
105 exit $ERRORS{'UNKNOWN'};
106 }
107 if ($result_warning==0) {
108 print "Division by zero \n";
109 exit $ERRORS{'CRITICAL'};
110 }
111
112 if ($result_critical==0) {
113 print "Division by zero \n";
114 exit $ERRORS{'CRITICAL'};
115 }
116
117
118# $q=$result_celsius/$result_threshold ;
119 $diff=$result_critical-$result_celsius ;
120
121
122 if ( $result_celsius > $result_critical ) {
123 print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Crit-Threshold:".$result_critical." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
124 exit $ERRORS{'CRITICAL'} ;
125 }
126 elsif ( $result_celsius > $result_warning ) {
127 print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Crit-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition}."\n" ;
128 exit $ERRORS{'WARNING'} ;
129 }
130 else {
131 print "Sensor " .$sensor. " (".$FSC_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Warn-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
132 exit $ERRORS{'OK'} ;
133 }
134
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> \n";
138 }
139
140sub print_help () {
141 print_revision($PROGNAME,'$Revision$\n ');
142 print "Copyright (c) 2003 Rainer Duffner\n ";
143 print_usage();
144 print "\n";
145 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
146 print "<port> = SNMP-Port (normaly 161)\n";
147 print "<community> = SNMP v1 community\n";
148 print "<drvnumber> = Sensornumber (1, 2, 3 etc.)\n";
149 }
150
151sub version () {
152 print_revision($PROGNAME,'$Revision$ ');
153 exit $ERRORS{'OK'};
154}
155
156sub help () {
157 print_help();
158 exit $ERRORS{'OK'};
159}
160