1
# Copyright (C) 2010 Roman Hochuli
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19
# Sensor-MIBs of Jacarta iMeter-Products
22
package Torrus::DevDiscover::Jacarta;
30
$Torrus::DevDiscover::registry{'Jacarta'} = {
32
'checkdevtype' => \&checkdevtype,
33
'discover' => \&discover,
34
'buildConfig' => \&buildConfig
40
'jacarta' => '1.3.6.1.4.1.19011',
41
'sensorEntry' => '1.3.6.1.4.1.19011.2.3.1.1',
42
'sensorIndex' => '1.3.6.1.4.1.19011.2.3.1.1.1',
43
'sensorDescription' => '1.3.6.1.4.1.19011.2.3.1.1.2',
44
'sensorType' => '1.3.6.1.4.1.19011.2.3.1.1.3',
45
'sensorValue' => '1.3.6.1.4.1.19011.2.3.1.1.4',
46
'sensorUnit' => '1.3.6.1.4.1.19011.2.3.1.1.5',
53
'template' => 'Jacarta::imeter-humi-sensor',
54
'max' => 'NetBotz::humi-max',
57
'template' => 'Jacarta::imeter-temp-sensor',
58
'max' => 'NetBotz::dew-max',
61
'template' => 'Jacarta::imeter-amps-sensor',
62
'max' => 'NetBotz::dew-max',
72
my $devdetails = shift;
74
if( not $dd->oidBaseMatch
76
$devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
81
$devdetails->setCap('interfaceIndexingPersistent');
90
my $devdetails = shift;
92
my $data = $devdetails->data();
93
my $session = $dd->session();
95
$data->{'Jacarta'} = {};
98
$session->get_table( -baseoid => $oiddef{'sensorEntry'} );
100
if( not defined( $sensorTable ) )
105
$devdetails->storeSnmpVars( $sensorTable );
107
# store the sensor names to guarantee uniqueness
111
($devdetails->getSnmpIndices( $oiddef{'sensorIndex'} ))
114
$devdetails->snmpVar( $oiddef{'sensorType'} . '.' .
117
$devdetails->snmpVar( $oiddef{'sensorDescription'} . '.' .
120
if( not defined( $sensor_types{$sensorType} ) )
122
Error('Sensor ' . $INDEX . ' of unknown type: ' . $sensorType);
126
if( $sensorNames{$sensorName} )
128
Warn('Duplicate sensor names: ' . $sensorName);
129
$sensorNames{$sensorName}++;
133
$sensorNames{$sensorName} = 1;
136
if( $sensorNames{$sensorName} > 1 )
138
$sensorName .= sprintf(' %d', $INDEX);
141
my $leafName = $sensorName;
142
$leafName =~ s/\W/_/g;
145
'imeter-sensor-index' => $INDEX,
146
'node-display-name' => $sensorName,
147
'graph-title' => $sensorName,
148
'precedence' => sprintf('%d', 1000 - $INDEX)
152
if( defined( $sensor_types{$sensorType}{'max'} ) )
155
$devdetails->param($sensor_types{$sensorType}{'max'});
157
if( defined($max) and $max > 0 )
159
$param->{'upper-limit'} = $max;
163
$data->{'Jacarta'}{$INDEX} = {
165
'leafName' => $leafName,
166
'template' => $sensor_types{$sensorType}{'template'}};
168
Debug('Found Sensor ' . $INDEX . ' of type ' . $sensorType .
169
', named ' . $sensorName );
178
my $devdetails = shift;
182
my $data = $devdetails->data();
185
'node-display-name' => 'Sensors',
186
'comment' => 'All sensors connected via this iMeter Master',
190
$cb->addSubtree( $devNode, 'Sensors', $param );
192
foreach my $INDEX ( sort {$a<=>$b} keys %{$data->{'Jacarta'}} )
194
my $ref = $data->{'Jacarta'}{$INDEX};
196
$cb->addLeaf( $sensorTree, $ref->{'leafName'}, $ref->{'param'},
197
[$ref->{'template'}] );
208
# indent-tabs-mode: nil
209
# perl-indent-level: 4