1 # Copyright (C) 2008 Jon Nistor
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: RFC1628_UPS_MIB.pm,v 1.1 2010-12-27 00:03:56 ivan Exp $
18 # Jon Nistor <nistor at snickers dot org>
20 # Discovery module for UPS-MIB (RFC 1628)
23 # ConnectUPS Web/SNMP Card V4.20 [powerware 9390]
26 # ConnectUPS Web/SNMP Card V3.16 [powerware 9155]
27 # - InputFrequency and InputTruePower are missing from RFC UPS-MIB
30 package Torrus::DevDiscover::RFC1628_UPS_MIB;
36 $Torrus::DevDiscover::registry{'RFC1628_UPS_MIB'} = {
38 'checkdevtype' => \&checkdevtype,
39 'discover' => \&discover,
40 'buildConfig' => \&buildConfig
47 'upsIdent' => '1.3.6.1.2.1.33.1.1',
48 'upsIdentManufacturer' => '1.3.6.1.2.1.33.1.1.1.0',
49 'upsIdentModel' => '1.3.6.1.2.1.33.1.1.2.0',
50 'upsIdentUPSSoftwareVersion' => '1.3.6.1.2.1.33.1.1.3.0',
51 'upsIdentAgentSoftwareVersion' => '1.3.6.1.2.1.33.1.1.4.0',
52 'upsIdentName' => '1.3.6.1.2.1.33.1.1.5.0',
54 'upsInputNumLines' => '1.3.6.1.2.1.33.1.3.2.0',
55 'upsOutputNumLines' => '1.3.6.1.2.1.33.1.4.3.0',
56 'upsBypassNumLines' => '1.3.6.1.2.1.33.1.5.2.0'
64 my $devdetails = shift;
66 my $session = $dd->session();
67 my $data = $devdetails->data();
69 return $dd->checkSnmpTable( 'upsIdent' );
76 my $devdetails = shift;
78 my $data = $devdetails->data();
79 my $session = $dd->session();
81 my $upsInfo = $dd->retrieveSnmpOIDs('upsIdentManufacturer',
82 'upsIdentModel', 'upsIdentUPSSoftwareVersion',
83 'upsIdentAgentSoftwareVersion', 'upsIdentName',
84 'upsInputNumLines', 'upsOutputNumLines', 'upsBypassNumLines');
86 $data->{'param'}{'comment'} = $upsInfo->{'upsIdentManufacturer'} . " " .
87 $upsInfo->{'upsIdentModel'} . " " .
88 $upsInfo->{'upsIdentUPSSoftwareVersion'};
90 # PROG: Discover number of lines (in,out,bypass)...
91 $data->{'numInput'} = $upsInfo->{'upsInputNumLines'};
92 $data->{'numOutput'} = $upsInfo->{'upsOutputNumLines'};
93 $data->{'numBypass'} = $upsInfo->{'upsBypassNumLines'};
95 Debug("UPS Lines Input: " . $data->{'numInput'} .
96 ", Output: " . $data->{'numOutput'} .
97 ", Bypass: " . $data->{'numBypass'} );
99 if( $devdetails->param('RFC1628_UPS::disable-input') ne 'yes' )
101 $devdetails->setCap('UPS-input');
104 if( $devdetails->param('RFC1628_UPS::disable-output') ne 'yes' )
106 $devdetails->setCap('UPS-output');
109 if( $devdetails->param('RFC1628_UPS::disable-bypass') ne 'yes' )
111 $devdetails->setCap('UPS-bypass');
120 my $devdetails = shift;
123 my $data = $devdetails->data();
125 # PROG: Add static battery information
126 $cb->addSubtree( $devNode, 'Battery',
127 { 'precedence' => 999 },
128 [ 'RFC1628_UPS_MIB::battery-subtree' ] );
130 if( $devdetails->hasCap('UPS-input') )
132 my $nodeInput = $cb->addSubtree( $devNode, 'Input',
133 { 'comment' => 'Input feeds' },
134 [ 'RFC1628_UPS_MIB::ups-input-subtree' ] );
136 foreach my $INDEX ( 1 .. $data->{'numInput'} )
138 $cb->addSubtree( $nodeInput, sprintf('Phase_%d', $INDEX),
139 { 'ups-input-idx' => $INDEX },
140 [ 'RFC1628_UPS::ups-input-leaf' ] );
144 if( $devdetails->hasCap('UPS-output') )
146 my $nodeOutput = $cb->addSubtree( $devNode, 'Output',
147 { 'comment' => 'Output feeds' },
148 [ 'RFC1628_UPS_MIB::ups-output-subtree' ] );
150 foreach my $INDEX ( 1 .. $data->{'numOutput'} )
152 $cb->addSubtree( $nodeOutput, sprintf('Phase_%d', $INDEX),
153 { 'ups-output-idx' => $INDEX },
154 [ 'RFC1628_UPS::ups-output-leaf' ] );
158 if( $devdetails->hasCap('UPS-bypass') )
160 my $nodeBypass = $cb->addSubtree( $devNode, 'Bypass',
161 { 'comment' => 'Bypass feeds' },
162 [ 'RFC1628_UPS_MIB::ups-bypass-subtree' ] );
164 foreach my $INDEX ( 1 .. $data->{'numBypass'} )
166 $cb->addSubtree( $nodeBypass, sprintf('Phase_%d', $INDEX),
167 { 'ups-bypass-idx' => $INDEX },
168 [ 'RFC1628_UPS::ups-bypass-leaf' ] );
178 # indent-tabs-mode: nil
179 # perl-indent-level: 4