4 # Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty
13 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # you should have received a copy of the GNU General Public License
17 # along with this program (or with Nagios); if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA
20 ####################################
21 # Nagios pluging to check inlet and outlet temperatures on
22 # Cisco router platforms which support environmental monitoring
23 # (7200, 7500, GSR12000...)
24 ####################################
25 # default temperature thresholds are 30C for inlet, 40C outlet.
26 # if input or output is less than thresholds, returns OK
27 # if equal to (the temps don't change that rapidly) returns WARNING
28 # if greater than threshold, returns CRITICAL
29 # if undetermined, or cannot access environmental, returns UNKNOWN
30 # (in accordance with the plugin coding guidelines)
31 ####################################
35 &Getopt
::Long
::config
('auto_abbrev');
40 my $community = "public";
42 my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1";
43 my $OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3";
46 my $inlet_thresh = 30;
47 my $outlet_thresh = 40;
49 my %STATUSCODE = ( 'UNKNOWN' => '-1',
54 my $state = "UNKNOWN";
58 print "ERROR: No snmp response from $hostname (sigALRM)\n";
59 exit($STATUSCODE{"UNKNOWN"});
62 Getopt
::Long
::Configure
('bundling');
64 ("community=s", \
$community,
67 "hostname=s", \
$hostname,
69 "timeout=i", \
$timeout,
70 "c=s", \
$critical_vals,
71 "w=s", \
$warning_vals,
72 "ithresh=i", \
$inlet_thresh,
73 "othresh=i", \
$outlet_thresh);
79 unless (defined($hostname)) {
80 $hostname = shift || &show_help
;
83 if (defined($critical_vals)) {
84 if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) {
85 ($inlet_thresh,$outlet_thresh) = ($1, $2);
87 die "Cannot Parse Critical Thresholds\n";
91 if (defined($warning_vals)) {
92 if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) {
93 ($inlet_warn,$outlet_warn) = ($1, $2);
95 die "Cannot Parse Warning Thresholds\n";
98 $inlet_warn=$inlet_thresh;
99 $outlet_warn=$outlet_thresh;
104 $in_temp = &SNMPGET
($INTAKE_TEMP);
105 $out_temp = &SNMPGET
($OUTLET_TEMP);
107 if (($in_temp < $inlet_thresh) && ($out_temp < $outlet_thresh)) {
110 elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) {
111 if(($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
118 elsif (($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
125 print "$state Inlet Temp: $in_temp Outlet Temp: $out_temp\n";
126 exit($STATUSCODE{$state});
129 printf("\nPerl envmon temperature plugin for Nagios\n");
132 check_ciscotemp [options] <hostname>
136 -i input temperature threshold
137 -o output temperature threshold
140 printf("Copyright (C)2000 Leland E. Vandervort\n");
141 printf("check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit\n");
142 printf("This program is licensed under the terms of the\n");
143 printf("GNU General Public License\n(check source code for details)\n\n\n");
144 exit($STATUSCODE{"UNKNOWN"});
149 ($session,$error) = Net
::SNMP
->session(
150 Hostname
=> $hostname,
151 Community
=> $community,
154 if(!defined($session)) {
155 printf("$state %s\n", $error);
156 exit($STATUSCODE{$state});
158 if(!defined($response = $session->get_request($OID))) {
159 printf("$state %s\n", $session->error());
161 exit($STATUSCODE{$state});
164 return($response->{$OID});