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.
17 # $Id: RFC2737_ENTITY_MIB.pm,v 1.1 2010-12-27 00:03:56 ivan Exp $
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;
30 $Torrus::DevDiscover::registry{'RFC2737_ENTITY_MIB'} = {
32 'checkdevtype' => \&checkdevtype,
33 'discover' => \&discover,
34 'buildConfig' => \&buildConfig
41 'entPhysicalDescr' => '1.3.6.1.2.1.47.1.1.1.1.2',
42 'entPhysicalContainedIn' => '1.3.6.1.2.1.47.1.1.1.1.4',
43 'entPhysicalName' => '1.3.6.1.2.1.47.1.1.1.1.7'
51 my $devdetails = shift;
53 my $session = $dd->session();
54 my $data = $devdetails->data();
57 $session->get_table( -baseoid =>
58 $dd->oiddef('entPhysicalDescr') );
59 if( defined $descrTable )
61 $devdetails->storeSnmpVars( $descrTable );
65 $session->get_table( -baseoid =>
66 $dd->oiddef('entPhysicalName') );
67 if( defined $nameTable )
69 $devdetails->storeSnmpVars( $nameTable );
72 return( defined($descrTable) or defined($nameTable) );
79 my $devdetails = shift;
81 my $data = $devdetails->data();
82 my $session = $dd->session();
84 $data->{'entityPhysical'} = {};
87 my $oidContainedIn = $dd->oiddef('entPhysicalContainedIn');
90 ( $devdetails->getSnmpIndices($dd->oiddef('entPhysicalDescr')) )
93 $data->{'entityPhysical'}{$phyIndex} = $ref;
95 # Find the chassis. It is not contained in anything.
96 if( not $chassisIndex )
98 my $oid = $oidContainedIn . '.' . $phyIndex;
99 my $result = $session->get_request( -varbindlist => [ $oid ] );
100 if( $session->error_status() == 0 and $result->{$oid} == 0 )
102 $chassisIndex = $phyIndex;
106 my $descr = $devdetails->snmpVar( $dd->oiddef('entPhysicalDescr') .
110 $ref->{'descr'} = $descr;
113 my $name = $devdetails->snmpVar( $dd->oiddef('entPhysicalName') .
117 $ref->{'name'} = $name;
123 $data->{'entityChassisPhyIndex'} = $chassisIndex;
124 my $chassisDescr = $data->{'entityPhysical'}{$chassisIndex}{'descr'};
125 if( length( $chassisDescr ) > 0 and
126 not defined( $data->{'param'}{'comment'} ) )
128 Debug('ENTITY-MIB: found chassis description: ' . $chassisDescr);
129 $data->{'param'}{'comment'} = $chassisDescr;
139 my $devdetails = shift;
150 # indent-tabs-mode: nil
151 # perl-indent-level: 4