summaryrefslogtreecommitdiffstats
path: root/web/attachments/61644-check_apc_ups.pl.diff
blob: 3ea9a1cf2d2c04927336280c8b0200de76fb85d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
298a
# 802 END INS
# 802 BEG DEL
#   $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`;
#   my @test = split(/ /,$val,3);
#
#   return undef unless (defined ($test[2]));
#
#   if ($test[2] =~ /\(\d+\)/) {	# Later versions of UCD SNMP
#     ($val) = ($test[2] =~ /\((\d+)\)/);
#   } elsif ($test[2] =~ /: \d+/) {
#     ($val) = ($test[2] =~ /: (\d+)/);
#   } else {
#     $val = $test[2];
#   }
# 802 END DEL
.
297c
      $val = undef;
.
286,295c
# 802 BEGIN INS
  my $community="public";
  my $port="161";
  my ($session, $error) = Net::SNMP->session(
	       -hostname => $host,
	       -community => $community,
               -timeout => 2,
               -port => $port,
	       -translate => undef
               );
  if (defined($session)) {
      my $response=$session->get_request($oid);
      if (defined($response)) {
	  $val=$response->{$oid};
      } else {
	  $val = undef;
      }
      $session->close;
.
277c
   Output load pct above which a WARNING status will result (default: 50)
.
275c
   Output load pct above which a CRITICAL status will result (default: 85)
.
242c
  print "unknown\]\n";
.
239c
  print "$diagnosticsResultsVals[$data][0]\]\n";
.
237c
print "\[Diag result: ";
.
232c
  print "unknown\]";
.
223c
  print "$data\]";
.
221c
print "\[Output load (%): ";
.
216c
  print "unknown\]";
.
213c
  print "$battReplVals[$data][0]\]";
.
211c
print "\[Battery repl: ";
.
206c
  print "unknown\] ";
.
197c
  print "$data\]";
.
195c
print "\[Battery temp(C): ";
.
190c
  print "unknown\]";
.
186c
    print "$battStatVals[$data][0]\]";
.
184c
    print "$battStatVals[$data][0] ($failcause)\]";
.
178c
print "\[Battery status: ";
.
173c
  print "unknown\]";
.
164c
  printf "%d:%02d:%05.2f\]", $hrs, $mins, $secs;
.
159c
print "\[Rem time: ";
.
154c
  print "unknown\]";
.
151c
  print "$outputStatVals[$data][0]\]";
.
149c
print "\[Output status: ";
.
143c
my $exitval     = $ERRORS{'OK'};
.
27a
# 801 ADD ONE
{ $^W=0; ($PROGNAME=$0) =~ s!^.*/!!; }

.
14,16c
# 802 ADD ONE
use Net::SNMP;
use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R 
	    $opt_r $opt_L $opt_l $PROGNAME);
#use lib utils.pm;
# 801 CHANGE ONE
use lib '/usr/local/nagios/libexec';
.
11c
#
# DMH Custom
# 801 07-07-2003 Fix use lib statement
#                Fix PROGNAME Assignment
# 802 07-07-2003 Use Net::SNMP to get the info instead of calling
#                an external program.
# 803 09-11-2003 Replaced the output delimiter | with [] as
#                Nagios was truncating the output and only
#                displaying the first check's data.
#
.