1 # Copyright (C) 2002 Stanislav Sinyagin
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.
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # Discovery module for ENTITY-MIB (RFC 2737)
21 # This module does not generate any XML, but provides information
22 # for other discovery modules
24 package Torrus
::DevDiscover
::RFC2737_ENTITY_MIB
;
33 $Torrus::DevDiscover
::registry
{'RFC2737_ENTITY_MIB'} = {
35 'checkdevtype' => \
&checkdevtype
,
36 'discover' => \
&discover
,
37 'buildConfig' => \
&buildConfig
44 'entPhysicalDescr' => '1.3.6.1.2.1.47.1.1.1.1.2',
45 'entPhysicalContainedIn' => '1.3.6.1.2.1.47.1.1.1.1.4',
46 'entPhysicalName' => '1.3.6.1.2.1.47.1.1.1.1.7'
54 my $devdetails = shift;
56 my $session = $dd->session();
57 my $data = $devdetails->data();
60 $session->get_table( -baseoid
=>
61 $dd->oiddef('entPhysicalDescr') );
62 if( defined $descrTable )
64 $devdetails->storeSnmpVars( $descrTable );
68 $session->get_table( -baseoid
=>
69 $dd->oiddef('entPhysicalName') );
70 if( defined $nameTable )
72 $devdetails->storeSnmpVars( $nameTable );
75 return( defined($descrTable) or defined($nameTable) );
82 my $devdetails = shift;
84 my $data = $devdetails->data();
85 my $session = $dd->session();
87 $data->{'entityPhysical'} = {};
90 my $oidContainedIn = $dd->oiddef('entPhysicalContainedIn');
93 ( $devdetails->getSnmpIndices($dd->oiddef('entPhysicalDescr')) )
96 $data->{'entityPhysical'}{$phyIndex} = $ref;
98 # Find the chassis. It is not contained in anything.
99 if( not $chassisIndex )
101 my $oid = $oidContainedIn . '.' . $phyIndex;
102 my $result = $session->get_request( -varbindlist
=> [ $oid ] );
103 if( $session->error_status() == 0 and $result->{$oid} == 0 )
105 $chassisIndex = $phyIndex;
109 my $descr = $devdetails->snmpVar( $dd->oiddef('entPhysicalDescr') .
113 $ref->{'descr'} = $descr;
116 my $name = $devdetails->snmpVar( $dd->oiddef('entPhysicalName') .
120 $ref->{'name'} = $name;
126 $data->{'entityChassisPhyIndex'} = $chassisIndex;
127 my $chassisDescr = $data->{'entityPhysical'}{$chassisIndex}{'descr'};
128 if( defined($chassisDescr) and $chassisDescr ne '' and
129 not defined( $data->{'param'}{'comment'} ) )
131 Debug
('ENTITY-MIB: found chassis description: ' . $chassisDescr);
132 $data->{'param'}{'comment'} = $chassisDescr;
142 my $devdetails = shift;
154 # indent-tabs-mode: nil
155 # perl-indent-level: 4