diff options
Diffstat (limited to 'web/attachments/61644-check_apc_ups.pl.diff')
-rw-r--r-- | web/attachments/61644-check_apc_ups.pl.diff | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/web/attachments/61644-check_apc_ups.pl.diff b/web/attachments/61644-check_apc_ups.pl.diff new file mode 100644 index 0000000..3ea9a1c --- /dev/null +++ b/web/attachments/61644-check_apc_ups.pl.diff | |||
@@ -0,0 +1,141 @@ | |||
1 | 298a | ||
2 | # 802 END INS | ||
3 | # 802 BEG DEL | ||
4 | # $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`; | ||
5 | # my @test = split(/ /,$val,3); | ||
6 | # | ||
7 | # return undef unless (defined ($test[2])); | ||
8 | # | ||
9 | # if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP | ||
10 | # ($val) = ($test[2] =~ /\((\d+)\)/); | ||
11 | # } elsif ($test[2] =~ /: \d+/) { | ||
12 | # ($val) = ($test[2] =~ /: (\d+)/); | ||
13 | # } else { | ||
14 | # $val = $test[2]; | ||
15 | # } | ||
16 | # 802 END DEL | ||
17 | . | ||
18 | 297c | ||
19 | $val = undef; | ||
20 | . | ||
21 | 286,295c | ||
22 | # 802 BEGIN INS | ||
23 | my $community="public"; | ||
24 | my $port="161"; | ||
25 | my ($session, $error) = Net::SNMP->session( | ||
26 | -hostname => $host, | ||
27 | -community => $community, | ||
28 | -timeout => 2, | ||
29 | -port => $port, | ||
30 | -translate => undef | ||
31 | ); | ||
32 | if (defined($session)) { | ||
33 | my $response=$session->get_request($oid); | ||
34 | if (defined($response)) { | ||
35 | $val=$response->{$oid}; | ||
36 | } else { | ||
37 | $val = undef; | ||
38 | } | ||
39 | $session->close; | ||
40 | . | ||
41 | 277c | ||
42 | Output load pct above which a WARNING status will result (default: 50) | ||
43 | . | ||
44 | 275c | ||
45 | Output load pct above which a CRITICAL status will result (default: 85) | ||
46 | . | ||
47 | 242c | ||
48 | print "unknown\]\n"; | ||
49 | . | ||
50 | 239c | ||
51 | print "$diagnosticsResultsVals[$data][0]\]\n"; | ||
52 | . | ||
53 | 237c | ||
54 | print "\[Diag result: "; | ||
55 | . | ||
56 | 232c | ||
57 | print "unknown\]"; | ||
58 | . | ||
59 | 223c | ||
60 | print "$data\]"; | ||
61 | . | ||
62 | 221c | ||
63 | print "\[Output load (%): "; | ||
64 | . | ||
65 | 216c | ||
66 | print "unknown\]"; | ||
67 | . | ||
68 | 213c | ||
69 | print "$battReplVals[$data][0]\]"; | ||
70 | . | ||
71 | 211c | ||
72 | print "\[Battery repl: "; | ||
73 | . | ||
74 | 206c | ||
75 | print "unknown\] "; | ||
76 | . | ||
77 | 197c | ||
78 | print "$data\]"; | ||
79 | . | ||
80 | 195c | ||
81 | print "\[Battery temp(C): "; | ||
82 | . | ||
83 | 190c | ||
84 | print "unknown\]"; | ||
85 | . | ||
86 | 186c | ||
87 | print "$battStatVals[$data][0]\]"; | ||
88 | . | ||
89 | 184c | ||
90 | print "$battStatVals[$data][0] ($failcause)\]"; | ||
91 | . | ||
92 | 178c | ||
93 | print "\[Battery status: "; | ||
94 | . | ||
95 | 173c | ||
96 | print "unknown\]"; | ||
97 | . | ||
98 | 164c | ||
99 | printf "%d:%02d:%05.2f\]", $hrs, $mins, $secs; | ||
100 | . | ||
101 | 159c | ||
102 | print "\[Rem time: "; | ||
103 | . | ||
104 | 154c | ||
105 | print "unknown\]"; | ||
106 | . | ||
107 | 151c | ||
108 | print "$outputStatVals[$data][0]\]"; | ||
109 | . | ||
110 | 149c | ||
111 | print "\[Output status: "; | ||
112 | . | ||
113 | 143c | ||
114 | my $exitval = $ERRORS{'OK'}; | ||
115 | . | ||
116 | 27a | ||
117 | # 801 ADD ONE | ||
118 | { $^W=0; ($PROGNAME=$0) =~ s!^.*/!!; } | ||
119 | |||
120 | . | ||
121 | 14,16c | ||
122 | # 802 ADD ONE | ||
123 | use Net::SNMP; | ||
124 | use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R | ||
125 | $opt_r $opt_L $opt_l $PROGNAME); | ||
126 | #use lib utils.pm; | ||
127 | # 801 CHANGE ONE | ||
128 | use lib '/usr/local/nagios/libexec'; | ||
129 | . | ||
130 | 11c | ||
131 | # | ||
132 | # DMH Custom | ||
133 | # 801 07-07-2003 Fix use lib statement | ||
134 | # Fix PROGNAME Assignment | ||
135 | # 802 07-07-2003 Use Net::SNMP to get the info instead of calling | ||
136 | # an external program. | ||
137 | # 803 09-11-2003 Replaced the output delimiter | with [] as | ||
138 | # Nagios was truncating the output and only | ||
139 | # displaying the first check's data. | ||
140 | # | ||
141 | . | ||