summaryrefslogtreecommitdiffstats
path: root/contrib/checkciscotemp.pl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 13:16:24 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 13:16:24 +0200
commitb15adb7762b6caaecaa83637abfcf5fdb4802092 (patch)
tree64eddbe2aa1a7f98a140be0f7973f05d7a781ae0 /contrib/checkciscotemp.pl
parentc4d5882b9e1d07c7b61091062b7d085fa5f00284 (diff)
downloadmonitoring-plugins-b15adb7762b6caaecaa83637abfcf5fdb4802092.tar.gz
Remove "contrib" plugins
These days, sites such as "Nagios Exchange" are a much better place for publishing plugins not maintained by the Plugins Development Team.
Diffstat (limited to 'contrib/checkciscotemp.pl')
-rw-r--r--contrib/checkciscotemp.pl166
1 files changed, 0 insertions, 166 deletions
diff --git a/contrib/checkciscotemp.pl b/contrib/checkciscotemp.pl
deleted file mode 100644
index 8fdc4294..00000000
--- a/contrib/checkciscotemp.pl
+++ /dev/null
@@ -1,166 +0,0 @@
1#!/usr/bin/perl -wT
2# check_ciscotemp.pl
3#
4# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com>
5#
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.
10#
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.
15#
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####################################
32
33use Net::SNMP;
34use Getopt::Long;
35&Getopt::Long::config('auto_abbrev');
36
37my $status;
38my $response = "";
39my $timeout = 10;
40my $community = "public";
41my $port = 161;
42my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1";
43my $OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3";
44my $in_temp;
45my $out_temp;
46my $inlet_thresh = 30;
47my $outlet_thresh = 40;
48
49my %STATUSCODE = ( 'UNKNOWN' => '-1',
50 'OK' => '0',
51 'WARNING' => '1',
52 'CRITICAL' => '2');
53
54my $state = "UNKNOWN";
55
56
57$SIG{'ALRM'} = sub {
58 print "ERROR: No snmp response from $hostname (sigALRM)\n";
59 exit($STATUSCODE{"UNKNOWN"});
60};
61
62Getopt::Long::Configure('bundling');
63$status = GetOptions
64 ("community=s", \$community,
65 "C=s", \$community,
66 "H=s", \$hostname,
67 "hostname=s", \$hostname,
68 "port=i", \$port,
69 "timeout=i", \$timeout,
70 "c=s", \$critical_vals,
71 "w=s", \$warning_vals,
72 "ithresh=i", \$inlet_thresh,
73 "othresh=i", \$outlet_thresh);
74
75if($status == 0) {
76 &show_help;
77}
78
79unless (defined($hostname)) {
80 $hostname = shift || &show_help;
81}
82
83if (defined($critical_vals)) {
84 if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) {
85 ($inlet_thresh,$outlet_thresh) = ($1, $2);
86 } else {
87 die "Cannot Parse Critical Thresholds\n";
88 }
89}
90
91if (defined($warning_vals)) {
92 if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) {
93 ($inlet_warn,$outlet_warn) = ($1, $2);
94 } else {
95 die "Cannot Parse Warning Thresholds\n";
96 }
97}else{
98 $inlet_warn=$inlet_thresh;
99 $outlet_warn=$outlet_thresh;
100}
101
102alarm($timeout);
103
104$in_temp = &SNMPGET($INTAKE_TEMP);
105$out_temp = &SNMPGET($OUTLET_TEMP);
106
107if (($in_temp < $inlet_thresh) && ($out_temp < $outlet_thresh)) {
108 $state = "OK";
109}
110elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) {
111 if(($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
112 $state = "CRITICAL";
113 }
114 else {
115 $state = "WARNING";
116 }
117}
118elsif (($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
119 $state = "CRITICAL";
120}
121else {
122 $state = "WARNING";
123}
124
125print "$state Inlet Temp: $in_temp Outlet Temp: $out_temp\n";
126exit($STATUSCODE{$state});
127
128sub show_help {
129 printf("\nPerl envmon temperature plugin for Nagios\n");
130 printf("Usage:\n");
131 printf("
132 check_ciscotemp [options] <hostname>
133 Options:
134 -C snmp-community
135 -p snmp-port
136 -i input temperature threshold
137 -o output temperature threshold
138
139");
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"});
145}
146
147sub SNMPGET {
148 $OID = shift;
149 ($session,$error) = Net::SNMP->session(
150 Hostname => $hostname,
151 Community => $community,
152 Port => $port
153 );
154 if(!defined($session)) {
155 printf("$state %s\n", $error);
156 exit($STATUSCODE{$state});
157 }
158 if(!defined($response = $session->get_request($OID))) {
159 printf("$state %s\n", $session->error());
160 $session->close();
161 exit($STATUSCODE{$state});
162 }
163 $session->close();
164 return($response->{$OID});
165}
166