~ubuntu-branches/ubuntu/trusty/libsnmp-info-perl/trusty

« back to all changes in this revision

Viewing changes to Info/Layer7/APC.pm

  • Committer: Package Import Robot
  • Author(s): Nuno Carvalho
  • Date: 2012-07-30 22:08:17 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120730220817-bjnr7f6ztu67vnic
Tags: 2.08-1
* Team upload.
* d/control: Update Standards-Version to 3.9.3.
* d/copyright: Update URI for copyright format.
* d/copyright: Update copyright years and add new copyright holders.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# SNMP::Info::Layer7::APC - SNMP Interface to APC UPS devices
 
2
#
 
3
# Copyright (c) 2011 Jeroen van Ingen
 
4
#
 
5
# All rights reserved.
 
6
#
 
7
# Redistribution and use in source and binary forms, with or without
 
8
# modification, are permitted provided that the following conditions are met:
 
9
#
 
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.
 
18
#
 
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.
 
30
 
 
31
package SNMP::Info::Layer7::APC;
 
32
 
 
33
use strict;
 
34
use Exporter;
 
35
use SNMP::Info::Layer7;
 
36
 
 
37
@SNMP::Info::Layer7::APC::ISA
 
38
    = qw/SNMP::Info::Layer7 Exporter/;
 
39
@SNMP::Info::Layer7::APC::EXPORT_OK = qw//;
 
40
 
 
41
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
 
42
 
 
43
$VERSION = '2.08';
 
44
 
 
45
%MIBS = (
 
46
    %SNMP::Info::Layer7::MIBS,
 
47
    'PowerNet-MIB' => 'upsBasicIdentModel',
 
48
);
 
49
 
 
50
%GLOBALS = (
 
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',
 
59
);
 
60
 
 
61
%FUNCS = (
 
62
    %SNMP::Info::Layer7::FUNCS,
 
63
    
 
64
);
 
65
 
 
66
%MUNGE = (
 
67
    # Inherit all the built in munging
 
68
    %SNMP::Info::Layer7::MUNGE,
 
69
);
 
70
 
 
71
 
 
72
# Method Overrides
 
73
 
 
74
sub os {
 
75
    return 'aos';
 
76
}
 
77
 
 
78
sub vendor {
 
79
    return 'apc';
 
80
}
 
81
 
 
82
sub model {
 
83
    my $apc = shift;
 
84
    return $apc->ups_model();
 
85
}
 
86
 
 
87
sub serial {
 
88
    my $apc = shift;
 
89
    my $ups = $apc->ups_serial() || 'unknown';
 
90
    my $mgmt = $apc->mgmt_serial() || 'unknown';
 
91
    return sprintf("UPS: %s, management card: %s", $ups, $mgmt);
 
92
}
 
93
 
 
94
sub ps1_type {
 
95
    return 'UPS status';
 
96
}
 
97
 
 
98
sub ps2_type {
 
99
    return 'Battery status';
 
100
}
 
101
 
 
102
1;
 
103
__END__
 
104
 
 
105
=head1 NAME
 
106
 
 
107
SNMP::Info::Layer7::APC - SNMP Interface to APC UPS devices
 
108
 
 
109
=head1 AUTHOR
 
110
 
 
111
Jeroen van Ingen
 
112
 
 
113
=head1 SYNOPSIS
 
114
 
 
115
 # Let SNMP::Info determine the correct subclass for you. 
 
116
 my $apc = new SNMP::Info(
 
117
                          AutoSpecify => 1,
 
118
                          Debug       => 1,
 
119
                          DestHost    => 'myswitch',
 
120
                          Community   => 'public',
 
121
                          Version     => 2
 
122
                        ) 
 
123
    or die "Can't connect to DestHost.\n";
 
124
 
 
125
 my $class      = $apc->class();
 
126
 print "SNMP::Info determined this device to fall under subclass : $class\n";
 
127
 
 
128
=head1 DESCRIPTION
 
129
 
 
130
Provides abstraction to the configuration information obtainable from a 
 
131
APC UPS via SNMP. 
 
132
 
 
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. 
 
135
 
 
136
 my $apc = new SNMP::Info::Layer7::APC(...);
 
137
 
 
138
=head2 Inherited Classes
 
139
 
 
140
=over
 
141
 
 
142
=item SNMP::Info::Layer7
 
143
 
 
144
=back
 
145
 
 
146
=head2 Required MIBs
 
147
 
 
148
=over
 
149
 
 
150
=item F<POWERNET-MIB>
 
151
 
 
152
=back
 
153
 
 
154
All required MIBs can be found in the netdisco-mibs package.
 
155
 
 
156
=head1 GLOBALS
 
157
 
 
158
These are methods that return scalar value from SNMP
 
159
 
 
160
=over
 
161
 
 
162
=item $apc->os()
 
163
 
 
164
Returns 'aos'
 
165
 
 
166
=item $apc->os_bin()
 
167
 
 
168
C<POWERNET-MIB::experimental.2.4.1.4.2>
 
169
 
 
170
=item $apc->os_ver()
 
171
 
 
172
C<POWERNET-MIB::experimental.2.4.1.4.1>
 
173
 
 
174
=item $apc->serial()
 
175
 
 
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.
 
178
 
 
179
=item $apc->vendor()
 
180
 
 
181
apc
 
182
 
 
183
=item $apc->model()
 
184
 
 
185
C<upsBasicIdentModel.0>
 
186
 
 
187
=item $apc->ps1_type()
 
188
 
 
189
Returns 'UPS status'
 
190
 
 
191
=item $apc->ps1_status()
 
192
 
 
193
Returns the main UPS status from C<upsBasicOutputStatus.0>
 
194
 
 
195
=item $apc->ps2_type()
 
196
 
 
197
Returns 'Battery status'
 
198
 
 
199
=item $apc->ps2_status()
 
200
 
 
201
Returns the battery status from C<upsBasicBatteryStatus.0>
 
202
 
 
203
=back
 
204
 
 
205
=head2 Globals imported from SNMP::Info::Layer7
 
206
 
 
207
See documentation in L<SNMP::Info::Layer7/"GLOBALS"> for details.
 
208
 
 
209
=head1 TABLE METHODS
 
210
 
 
211
These are methods that return tables of information in the form of a reference
 
212
to a hash.
 
213
 
 
214
=head2 Overrides
 
215
 
 
216
=over
 
217
 
 
218
=back
 
219
 
 
220
=head2 Table Methods imported from SNMP::Info::Layer7
 
221
 
 
222
See documentation in L<SNMP::Info::Layer7/"TABLE METHODS"> for details.
 
223
 
 
224
=head1 MUNGES
 
225
 
 
226
=over
 
227
 
 
228
=back
 
229
 
 
230
=head1 SET METHODS
 
231
 
 
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
 
235
operations. 
 
236
 
 
237
=cut