summaryrefslogtreecommitdiffstats
path: root/web/attachments/61644-check_apc_ups.pl.diff
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/61644-check_apc_ups.pl.diff')
-rw-r--r--web/attachments/61644-check_apc_ups.pl.diff141
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 @@
1298a
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.
18297c
19 $val = undef;
20.
21286,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.
41277c
42 Output load pct above which a WARNING status will result (default: 50)
43.
44275c
45 Output load pct above which a CRITICAL status will result (default: 85)
46.
47242c
48 print "unknown\]\n";
49.
50239c
51 print "$diagnosticsResultsVals[$data][0]\]\n";
52.
53237c
54print "\[Diag result: ";
55.
56232c
57 print "unknown\]";
58.
59223c
60 print "$data\]";
61.
62221c
63print "\[Output load (%): ";
64.
65216c
66 print "unknown\]";
67.
68213c
69 print "$battReplVals[$data][0]\]";
70.
71211c
72print "\[Battery repl: ";
73.
74206c
75 print "unknown\] ";
76.
77197c
78 print "$data\]";
79.
80195c
81print "\[Battery temp(C): ";
82.
83190c
84 print "unknown\]";
85.
86186c
87 print "$battStatVals[$data][0]\]";
88.
89184c
90 print "$battStatVals[$data][0] ($failcause)\]";
91.
92178c
93print "\[Battery status: ";
94.
95173c
96 print "unknown\]";
97.
98164c
99 printf "%d:%02d:%05.2f\]", $hrs, $mins, $secs;
100.
101159c
102print "\[Rem time: ";
103.
104154c
105 print "unknown\]";
106.
107151c
108 print "$outputStatVals[$data][0]\]";
109.
110149c
111print "\[Output status: ";
112.
113143c
114my $exitval = $ERRORS{'OK'};
115.
11627a
117# 801 ADD ONE
118{ $^W=0; ($PROGNAME=$0) =~ s!^.*/!!; }
119
120.
12114,16c
122# 802 ADD ONE
123use Net::SNMP;
124use 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
128use lib '/usr/local/nagios/libexec';
129.
13011c
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.