~ubuntu-branches/ubuntu/wily/torrus/wily-proposed

« back to all changes in this revision

Viewing changes to perllib/Torrus/DevDiscover/Liebert.pm

  • Committer: Package Import Robot
  • Author(s): Bernhard Schmidt
  • Date: 2014-10-05 21:16:04 UTC
  • mfrom: (1.2.5)
  • mto: (6.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20141005211604-qqkvq1k0uqiv3bvk
Tags: upstream-2.08
ImportĀ upstreamĀ versionĀ 2.08

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#  along with this program; if not, write to the Free Software
18
18
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
19
 
20
 
# $Id$
21
20
# Jon Nistor <nistor at snickers.org>
22
21
#
23
22
# NOTE: Options for this module
24
23
#       Liebert::use-fahrenheit
25
 
#       Liebert::disable-temperature
26
 
#       Liebert::disable-humidity
27
 
#       Liebert::disable-state
28
 
#       Liebert::disable-stats
 
24
#       Liebert::disable-temperature
 
25
#       Liebert::disable-humidity
 
26
#       Liebert::disable-state
 
27
#       Liebert::disable-stats
29
28
#
30
29
# NOTE: This module supports both Fahrenheit and Celcius, but for ease of
31
30
#       module and cleanliness we will convert Celcius into Fahrenheit
36
35
package Torrus::DevDiscover::Liebert;
37
36
 
38
37
use strict;
 
38
use warnings;
 
39
 
39
40
use Torrus::Log;
40
41
 
41
42
 
49
50
our %oiddef =
50
51
    (
51
52
     # LIEBERT-GP-REGISTRATION-MIB
52
 
     'GlobalProducts'     => '1.3.6.1.4.1.476.1.42',
 
53
     'GlobalProducts'     => '1.3.6.1.4.1.476.1.42',
53
54
 
54
55
     # LIEBERT-GP-AGENT-MIB
55
56
     'Manufacturer'       => '1.3.6.1.4.1.476.1.42.2.1.1.0',
107
108
    $data->{'param'}{'snmp-oids-per-pdu'} = 10;
108
109
 
109
110
    # Temperature
110
 
    if( $devdetails->param('Liebert::disable-temperature') ne 'yes' ) 
 
111
    if( $devdetails->paramDisabled('Liebert::disable-temperature') ) 
111
112
    {
112
113
        $devdetails->setCap('env-temperature');
113
114
 
114
 
        if( $devdetails->param('Liebert::use-fahrenheit') ne 'yes' )
 
115
        if( $devdetails->paramDisabled('Liebert::use-fahrenheit') )
115
116
        {
116
117
            # ENV: Temperature in Celcius
117
118
            my $idTable = $session->get_table(
150
151
    }
151
152
 
152
153
    # ENV: Humidity
153
 
    if( $devdetails->param('Liebert::disable-humidity') ne 'yes' )
 
154
    if( $devdetails->paramDisabled('Liebert::disable-humidity') )
154
155
    {
155
156
        my $idTable = $session->get_table(
156
157
                 -baseoid => $dd->oiddef('HumidityIdRel') );
169
170
    }
170
171
 
171
172
    # ENV: State
172
 
    if( $devdetails->param('Liebert::disable-state') ne 'yes' )
 
173
    if( $devdetails->paramDisabled('Liebert::disable-state') )
173
174
    {
174
175
        my $stateTable = $session->get_table(
175
176
                 -baseoid => $dd->oiddef('lgpEnvState') );
188
189
    }
189
190
 
190
191
    # Statistics
191
 
    if( $devdetails->param('Liebert::disable-stats') ne 'yes' )
 
192
    if( $devdetails->paramDisabled('Liebert::disable-stats') )
192
193
    {
193
194
        my $statsTable = $session->get_table(
194
195
                 -baseoid => $dd->oiddef('lgpEnvStatistics') );
226
227
        if( $devdetails->hasCap('env-temperature-fahrenheit') )
227
228
        {
228
229
            $dataFile   = "%system-id%_temperature_f.rrd";
229
 
            $fahrenheit = 1;
 
230
            $fahrenheit = 1;
230
231
            $snmpVar    = 2;
231
232
            $tempUnit   = "F";
232
233
            $tempScale  = "Fahrenheit";
248
249
        my $nodeTemp = $cb->addSubtree( $devNode, 'Temperature', $paramSubTree,
249
250
                                      [ 'Liebert::temperature-subtree' ] );
250
251
 
251
 
        # ----------------------------------------------------------------
 
252
        # ----------------------------------------------------------------
252
253
        # PROG: Figure out how many indexes we have
253
254
        foreach my $index ( keys %{$data->{'liebert'}{'tempidx'}} )
254
255
        {
255
 
            my $dataFile = "%system-id%_sensor_$index" . 
256
 
                           ($fahrenheit ? '_fahrenheit':'') . ".rrd";
257
256
            Debug("Liebert: Temperature idx: $index : $tempScale");
258
257
            my $param = {
259
258
                'comment'    => "Sensor: $index",
260
 
                'data-file'  => $dataFile,
261
259
                'sensor-idx' => $index
262
260
            };
263
261
 
 
262
            $param->{'data-file'} =
 
263
                '%system-id%_sensor_' . $index . 
 
264
                ($fahrenheit ? '_fahrenheit':'') . '.rrd';
 
265
 
264
266
            $cb->addSubtree( $nodeTemp, 'sensor_' . $index, $param,
265
 
                        [ @template ] );
 
267
                             [ @template ] );
266
268
        } # END: foreach my $index
267
269
    } # END: env-temperature
268
270
 
302
304
                           [ 'Liebert::state-capacity' ] );
303
305
        }
304
306
    }
 
307
 
 
308
    return;
305
309
}
306
310
 
307
311
1;