1
# SNMP::Info::Layer7::APC - SNMP Interface to APC UPS devices
3
# Copyright (c) 2011 Jeroen van Ingen
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions are met:
10
# * Redistributions of source code must retain the above copyright notice,
11
# this list of conditions and the following disclaimer.
12
# * Redistributions in binary form must reproduce the above copyright
13
# notice, this list of conditions and the following disclaimer in the
14
# documentation and/or other materials provided with the distribution.
15
# * Neither the name of the University of California, Santa Cruz nor the
16
# names of its contributors may be used to endorse or promote products
17
# derived from this software without specific prior written permission.
19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
31
package SNMP::Info::Layer7::APC;
35
use SNMP::Info::Layer7;
37
@SNMP::Info::Layer7::APC::ISA
38
= qw/SNMP::Info::Layer7 Exporter/;
39
@SNMP::Info::Layer7::APC::EXPORT_OK = qw//;
41
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
46
%SNMP::Info::Layer7::MIBS,
47
'PowerNet-MIB' => 'upsBasicIdentModel',
51
%SNMP::Info::Layer7::GLOBALS,
52
'ups_serial' => 'upsAdvIdentSerialNumber.0',
53
'mgmt_serial' => 'experimental.2.4.1.2.1',
54
'os_ver' => 'experimental.2.4.1.4.1',
55
'os_bin' => 'experimental.2.4.1.4.2',
56
'ups_model' => 'upsBasicIdentModel.0',
57
'ps1_status' => 'upsBasicOutputStatus.0',
58
'ps2_status' => 'upsBasicBatteryStatus.0',
62
%SNMP::Info::Layer7::FUNCS,
67
# Inherit all the built in munging
68
%SNMP::Info::Layer7::MUNGE,
84
return $apc->ups_model();
89
my $ups = $apc->ups_serial() || 'unknown';
90
my $mgmt = $apc->mgmt_serial() || 'unknown';
91
return sprintf("UPS: %s, management card: %s", $ups, $mgmt);
99
return 'Battery status';
107
SNMP::Info::Layer7::APC - SNMP Interface to APC UPS devices
115
# Let SNMP::Info determine the correct subclass for you.
116
my $apc = new SNMP::Info(
119
DestHost => 'myswitch',
120
Community => 'public',
123
or die "Can't connect to DestHost.\n";
125
my $class = $apc->class();
126
print "SNMP::Info determined this device to fall under subclass : $class\n";
130
Provides abstraction to the configuration information obtainable from a
133
For speed or debugging purposes you can call the subclass directly, but not
134
after determining a more specific class using the method above.
136
my $apc = new SNMP::Info::Layer7::APC(...);
138
=head2 Inherited Classes
142
=item SNMP::Info::Layer7
150
=item F<POWERNET-MIB>
154
All required MIBs can be found in the netdisco-mibs package.
158
These are methods that return scalar value from SNMP
168
C<POWERNET-MIB::experimental.2.4.1.4.2>
172
C<POWERNET-MIB::experimental.2.4.1.4.1>
176
Combines the UPS serial C<upsAdvIdentSerialNumber.0> with the managment
177
card serial C<POWERNET-MIB::experimental.2.4.1.2.1> into a pretty string.
185
C<upsBasicIdentModel.0>
187
=item $apc->ps1_type()
191
=item $apc->ps1_status()
193
Returns the main UPS status from C<upsBasicOutputStatus.0>
195
=item $apc->ps2_type()
197
Returns 'Battery status'
199
=item $apc->ps2_status()
201
Returns the battery status from C<upsBasicBatteryStatus.0>
205
=head2 Globals imported from SNMP::Info::Layer7
207
See documentation in L<SNMP::Info::Layer7/"GLOBALS"> for details.
211
These are methods that return tables of information in the form of a reference
220
=head2 Table Methods imported from SNMP::Info::Layer7
222
See documentation in L<SNMP::Info::Layer7/"TABLE METHODS"> for details.
232
These are methods that provide SNMP set functionality for overridden methods
233
or provide a simpler interface to complex set operations. See
234
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set