| 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 warnings; | ||
| 35 | use Exporter; | ||
| 36 | use SNMP::Info::Layer7; | ||
| 37 | |||
| 38 | @SNMP::Info::Layer7::APC::ISA | ||
| 39 | = qw/SNMP::Info::Layer7 Exporter/; | ||
| 40 | @SNMP::Info::Layer7::APC::EXPORT_OK = qw//; | ||
| 41 | |||
| 42 | our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); | ||
| 43 | |||
| 44 | $VERSION = '3.985003'; | ||
| 45 | |||
| 46 | %MIBS = ( | ||
| 47 | %SNMP::Info::Layer7::MIBS, | ||
| 48 | 'PowerNet-MIB' => 'upsBasicIdentModel', | ||
| 49 | ); | ||
| 50 | |||
| 51 | %GLOBALS = ( | ||
| 52 | %SNMP::Info::Layer7::GLOBALS, | ||
| 53 | 'mac' => 'ifPhysAddress.2', | ||
| 54 | 'ups_serial' => 'upsAdvIdentSerialNumber.0', | ||
| 55 | 'pdu_serial' => 'rPDUIdentSerialNumber.0', | ||
| 56 | 'mgmt_serial' => 'experimental.2.4.1.2.1', | ||
| 57 | 'os_ver' => 'experimental.2.4.1.4.1', | ||
| 58 | 'os_bin' => 'experimental.2.4.1.4.2', | ||
| 59 | 'ups_model' => 'upsBasicIdentModel.0', | ||
| 60 | 'pdu_model' => 'rPDUIdentModelNumber.0', | ||
| 61 | 'ps1_status' => 'upsBasicOutputStatus.0', | ||
| 62 | 'ps2_status' => 'upsBasicBatteryStatus.0', | ||
| 63 | ); | ||
| 64 | |||
| 65 | %FUNCS = ( | ||
| 66 | %SNMP::Info::Layer7::FUNCS, | ||
| 67 | |||
| 68 | ); | ||
| 69 | |||
| 70 | %MUNGE = ( | ||
| 71 | # Inherit all the built in munging | ||
| 72 | %SNMP::Info::Layer7::MUNGE, | ||
| 73 | ); | ||
| 74 | |||
| 75 | |||
| 76 | # Method Overrides | ||
| 77 | |||
| 78 | sub os { | ||
| 79 | return 'aos'; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub vendor { | ||
| 83 | return 'apc'; | ||
| 84 | } | ||
| 85 | |||
| 86 | sub model { | ||
| 87 | my $apc = shift; | ||
| 88 | return $apc->ups_model() || $apc->pdu_model(); | ||
| 89 | } | ||
| 90 | |||
| 91 | sub serial { | ||
| 92 | my $apc = shift; | ||
| 93 | my $ups = $apc->ups_serial() || 'unknown'; | ||
| 94 | my $mgmt = $apc->mgmt_serial() || 'unknown'; | ||
| 95 | return sprintf("UPS: %s, management card: %s", $ups, $mgmt); | ||
| 96 | } | ||
| 97 | |||
| 98 | sub ps1_type { | ||
| 99 | return 'UPS status'; | ||
| 100 | } | ||
| 101 | |||
| 102 | sub ps2_type { | ||
| 103 | return 'Battery status'; | ||
| 104 | } | ||
| 105 | |||
| 106 | 1; | ||
| 107 | __END__ |