Files
snmp-info/lib/SNMP/Info/Layer3/Eltex.pm
2020-05-17 20:48:30 +03:00

243 lines
5.4 KiB
Perl

# SNMP::Info::Layer3::Eltex - SNMP Interface to Eltex Devices
#
# Copyright (c) 2020 by The 135.
package SNMP::Info::Layer3::Eltex;
use strict;
use warnings;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Eltex::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Eltex::EXPORT_OK = qw//;
our ( $VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE );
$VERSION = '3.70-135';
#our $index = undef;
%MIBS = ( %SNMP::Info::Layer3::MIBS, );
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'model_oid_mes' => 'mib-2.47.1.1.1.1.13.67108992',
'hw_oid_1_81' => 'mib-2.47.1.1.1.1.8.67108992',
'model_oid' => 'iso.0.8802.1.1.2.1.3.4.0',
'model_oid_mxa' => 'enterprises.35265.4.2.0',
'hw_oid' => 'iso.0.8802.1.1.2.1.5.4795.1.2.2.0',
'hw_oid_1_30' => 'iso.0.8802.1.1.2.1.5.1.1.2.2.0',
'serial_oid' => 'mib-2.47.1.1.1.1.11.67108992',
'serial_oid_22' => 'enterprises.35265.1.22.1.18.4.0',
'serial_oid_mxa' => 'enterprises.35265.4.3.0',
'os_ver_oid' => 'mib-2.47.1.1.1.1.10.67108992',
'os_ver_oid_mxa' => 'enterprises.35265.4.5.0',
'bootrom_oid' => 'mib-2.47.1.1.1.1.9.67108992',
#'serial_oid_140' => '',
'os_ver_oid_140' => 'mib-2.47.1.1.1.1.9.1',
#'bootrom_oid_140' => '',
'descr_oid' => 'iso.0.8802.1.1.2.1.3.4.0',
);
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub model {
my $obj = shift;
my $model; my $hw;
my $id = $obj->id();
$model = $obj->model_oid || undef;
$hw = $obj->hwver() || undef;
if ( $id =~ /35265\.1\.22/ ) {
my $descr = $obj->descr_oid;
$descr =~ /Eltex\s(.*)\ssoftware\sversion\s(.*)\sbuild\s(\d+)/;
return $1;
}
elsif ($id =~ /34300\.1\.6/ or $id =~ /35265\.1\.28/) {
return $obj->model_oid_mxa;
}
elsif (defined $model and $model !~ /MES\d+/) {
$model = $obj->model_oid_mes . ' ' . $obj->model_oid || undef;
}
if (defined $model and defined $hw) {
return $model . ' HW:' . $hw;
}
elsif (defined $model) {
return $model;
}
else {
return 'unknown';
}
}
sub vendor {
return 'eltex';
}
sub os {
return 'eltex';
}
sub os_ver {
my $obj = shift;
my $os_ver; my $bootrom;
my $id = $obj->id();
if ($id =~ /35265\.(140|158)$/) {
$os_ver = $obj->os_ver_oid_140;
return $os_ver;
}
if ($id =~ /34300\.1\.6/ or $id =~ /35265\.1\.28$/) {
return $obj->os_ver_oid_mxa;
}
elsif ($id =~ /35265\.1\.(24|43|30|120|5[2,4]|74|8[1,9])$/) {
$os_ver = $obj->os_ver_oid;
$bootrom = $obj->bootrom_oid;
}
elsif ( $id =~ /35265\.1\.22$/ ) {
my $descr = $obj->descr_oid;
$descr =~ /Eltex\s(.*)\ssoftware\sversion\s(.*)\sbuild\s(\d+)/;
return $2;
}
elsif ($id =~ /35265\.1\.30$/) {
}
else {
return 'unknown';
}
return $os_ver . ' bootrom: ' . $bootrom;
}
sub serial {
my $obj = shift;
my $serial;
my $id = $obj->id();
if ($id =~ /35265\.(140|158)$/) {
return;
}
elsif ($id =~ /34300\.1\.6/ or $id =~ /35265\.1\.28$/) {
return $obj->serial_oid_mxa;
}
elsif ($id =~ /35265\.1\.(24|43|30|120|5[2,4]|74|8[1,9]])$/) {
$serial = $obj->serial_oid;
}
elsif ( $id =~ /35265\.1\.22$/ ) {
$serial = $obj->serial_oid_22;
}
else {
return 'unknown';
}
return $serial;
}
sub hwver {
my $obj = shift;
my $id = $obj->id();
if ($id =~ /35265\.1\.30$/) {
return $obj->hw_oid_1_30;
}
elsif($id =~ /35265\.1\.(74|120|30|24|8[1,9]|5[4,2]|43)$/) {
return $obj->hw_oid_1_81;
}
elsif($id =~ /35265\.158/) {
return $obj->hw_oid;
}
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Eltex - SNMP Interface to Eltex Devices
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $obj = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $obj->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Eltex devices.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $obj->model()
Returns the ID or else description.
=item $obj->vendor()
Returns 'eltex'.
=item $obj->serial()
Returns serial number.
=item $obj->fwver()
Returns the firmware version.
=item $obj->hwver()
Returns the hardware version.
=item $obj->stp_i_root_port()
Returns the STP root port.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $obj->interfaces();
Returns the map between SNMP Interface Identifier (iid) and C<ifName>.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut