From fbf0bbe8808c16a888854594c6e8048583418528 Mon Sep 17 00:00:00 2001 From: Andrey Pazychev Date: Tue, 19 May 2020 20:33:28 +0300 Subject: [PATCH] WIP. Accton, Proscend and Nag vendors initial suppport --- lib/SNMP/Info.pm | 8 +- lib/SNMP/Info/Layer2/Proscend.pm | 108 +++++++++++++++++++++ lib/SNMP/Info/Layer3/Accton.pm | 155 +++++++++++++++++++++++++++++++ lib/SNMP/Info/Layer3/Nag.pm | 149 +++++++++++++++++++++++++++++ 4 files changed, 419 insertions(+), 1 deletion(-) create mode 100755 lib/SNMP/Info/Layer2/Proscend.pm create mode 100755 lib/SNMP/Info/Layer3/Accton.pm create mode 100755 lib/SNMP/Info/Layer3/Nag.pm diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 98dd5964..b97556fb 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -25,7 +25,7 @@ our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE, $AUTOLOAD, $INIT, $DEBUG, %SPEED_MAP, $NOSUCH, $BIGINT, $REPEATERS); -$VERSION = '3.70-135.20.5.5'; +$VERSION = '3.70-135-20.5.6'; =head1 NAME @@ -1671,6 +1671,7 @@ sub device_type { 45 => 'SNMP::Info::Layer2::Baystack', 171 => 'SNMP::Info::Layer3::DLink', 244 => 'SNMP::Info::Layer3::Lantronix', + 259 => 'SNMP::Info::Layer3::Accton', 311 => 'SNMP::Info::Layer3::Microsoft', 637 => 'SNMP::Info::Layer3::AlcatelLucent', 655 => 'SNMP::Info::Layer2::Carelink', @@ -1702,6 +1703,7 @@ sub device_type { 6141 => 'SNMP::Info::Layer3::Ciena', 6486 => 'SNMP::Info::Layer3::AlcatelLucent', 6527 => 'SNMP::Info::Layer3::Timetra', + 6672 => 'SNMP::Info::Layer2::Proscend', 6876 => 'SNMP::Info::Layer3::VMware', 8072 => 'SNMP::Info::Layer3::NetSNMP', 8886 => 'SNMP::Info::Layer3::Raisecom', @@ -1730,6 +1732,7 @@ sub device_type { 35098 => 'SNMP::Info::Layer3::Pica8', 35265 => 'SNMP::Info::Layer3::Eltex', 40310 => 'SNMP::Info::Layer3::Cumulus', + 40418 => 'SNMP::Info::Layer3::Nag', 41112 => 'SNMP::Info::Layer2::Ubiquiti', 44641 => 'SNMP::Info::Layer3::VyOS', 41752 => 'SNMP::Info::Layer3::Raisecom', @@ -1742,6 +1745,7 @@ sub device_type { 45 => 'SNMP::Info::Layer2::Baystack', 171 => 'SNMP::Info::Layer3::DLink', 207 => 'SNMP::Info::Layer2::Allied', + 259 => 'SNMP::Info::Layer3::Accton', 266 => 'SNMP::Info::Layer2::Nexans', 637 => 'SNMP::Info::Layer3::AlcatelLucent', 655 => 'SNMP::Info::Layer2::Carelink', @@ -1762,6 +1766,7 @@ sub device_type { 5624 => 'SNMP::Info::Layer3::Enterasys', 6141 => 'SNMP::Info::Layer3::Ciena', 6486 => 'SNMP::Info::Layer3::AlcatelLucent', + 6672 => 'SNMP::Info::Layer2::Proscend', 8886 => 'SNMP::Info::Layer3::Raisecom', 9303 => 'SNMP::Info::Layer3::PacketFront', 10418 => 'SNMP::Info::Layer1::Cyclades', @@ -1779,6 +1784,7 @@ sub device_type { 32761 => 'SNMP::Info::Layer3::Rotek', 34300 => 'SNMP::Info::Layer3::Eltex', 35265 => 'SNMP::Info::Layer3::Eltex', + 40418 => 'SNMP::Info::Layer3::Nag', 41752 => 'SNMP::Info::Layer3::Raisecom', ); diff --git a/lib/SNMP/Info/Layer2/Proscend.pm b/lib/SNMP/Info/Layer2/Proscend.pm new file mode 100755 index 00000000..41361903 --- /dev/null +++ b/lib/SNMP/Info/Layer2/Proscend.pm @@ -0,0 +1,108 @@ +# SNMP::Info::Layer2::Proscend - SNMP Interface to Proscend Devices +# +# Copyright (c) 2020 by 135. + +package SNMP::Info::Layer2::Proscend; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer2; + +@SNMP::Info::Layer2::Proscend::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Proscend::EXPORT_OK = qw//; + +our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); + +$VERSION = '3.70-135'; + +%MIBS = ( %SNMP::Info::Layer2::MIBS, ); + +%GLOBALS = ( + %SNMP::Info::Layer2::GLOBALS, +); + +%FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); + +sub vendor { + return 'proscend'; +} + +sub os { + return 'proscend'; +} + +sub model { + my $obj = shift; + return $obj->SUPER::model(); +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer2::Proscend - SNMP Interface to Proscend 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 Proscend Devices + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer2 + +=back + +=head2 Inherited Classes' MIBs + +See L for its own MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $obj->vendor() + +Returns 'proscend' + +=item $obj->os() + +Returns 'proscend' + +=item $obj->os_ver() + +Returns the software version. + +=item $obj->model() + +Returns the model extracted. + +=item $obj->serial() + +Returns serial number. + +=cut + +=back \ No newline at end of file diff --git a/lib/SNMP/Info/Layer3/Accton.pm b/lib/SNMP/Info/Layer3/Accton.pm new file mode 100755 index 00000000..65e7531a --- /dev/null +++ b/lib/SNMP/Info/Layer3/Accton.pm @@ -0,0 +1,155 @@ +# SNMP::Info::Layer3::Accton - SNMP Interface to Accton Devices +# +# Copyright (c) 2020 by 135. + +package SNMP::Info::Layer3::Accton; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer3; + +@SNMP::Info::Layer3::Accton::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Accton::EXPORT_OK = qw//; + +our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); + +$VERSION = '3.70-135'; + +%MIBS = ( %SNMP::Info::Layer3::MIBS, ); + +%GLOBALS = ( + %SNMP::Info::Layer3::GLOBALS, + 'os_ver_oid_259_6_10_94' => 'enterprises.259.6.10.94.1.1.5.4.0', + 'os_ver_oid_259_8_1_5' => 'enterprises.259.8.1.5.1.1.5.4.0', +); + +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, +); + +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); + +sub vendor { + return 'accton'; +} + +sub os { + return 'accton-os'; +} + +sub model { + my $obj = shift; + my $hw = $obj->c_hw_ver() || undef; + return $obj->SUPER::description() . ' HW:' . $hw if (defined $hw); + return $obj->SUPER::description() + #return $obj->SUPER::model(); +} + +sub serial { + my $obj = shift; + my $sess = $obj->session(); + my $serial = $sess->get($obj->id() . '.1.1.3.1.10.1') || undef; + return $serial; +} + +sub hwver { + my $obj = shift; + my $sess = $obj->session(); + my $hw = $sess->get($obj->id() . '.1.1.3.1.2.1') || undef; + return $hw; +} + +sub os_ver { + my $obj = shift; + my $sess = $obj->session(); + my $os_ver = $sess->get($obj->id() . '.1.1.5.4.0') || undef; + my $brom = $sess->get($obj->id() . '.1.1.3.1.5.1') || undef; + my $loader = $sess->get($obj->id() . '.1.1.3.1.4.1') || undef; + my $full_os_ver = $os_ver if defined($os_ver) || return; + $full_os_ver .= ' bootrom:' . $brom if defined($brom); + $full_os_ver .= ' loader:' . $loader if defined($loader); + return $full_os_ver; +} + +sub description { + my $obj = shift; + my $descr = undef; + my $sess = $obj->session(); + $descr .= $obj->SUPER::description() . "\n"; + $descr .= "Serial Number: " . $sess->get($obj->id() . '.1.1.3.1.10.1') . "\n"; + $descr .= "Hardware Version: " . $sess->get($obj->id() . '.1.1.3.1.2.1') . "\n"; + $descr .= "EPLD Version: " . $sess->get($obj->id() . '.1.1.3.1.15.1') . "\n"; + $descr .= "Loader Version: " . $sess->get($obj->id() . '.1.1.3.1.4.1') . "\n"; + $descr .= "Boot ROM Version: " . $sess->get($obj->id() . '.1.1.3.1.5.1') . "\n"; + $descr .= "Operation Code Version: " . $sess->get($obj->id() . '.1.1.5.4.0') . "\n"; + return $descr; + #$sess->get($obj->id() . '.1.1.5.4.0') +} +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer3::Accton - SNMP Interface to Accton 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 Accton Devices + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer3 + +=back + +=head2 Inherited Classes' MIBs + +See L for its own MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $obj->vendor() + +Returns 'accton' + +=item $obj->os() + +Returns 'accton-os' + +=item $obj->os_ver() + +Returns the software version. + +=item $obj->model() + +Returns the model extracted. + +=item $obj->serial() + +Returns serial number. + +=cut + +=back \ No newline at end of file diff --git a/lib/SNMP/Info/Layer3/Nag.pm b/lib/SNMP/Info/Layer3/Nag.pm new file mode 100755 index 00000000..7735e8aa --- /dev/null +++ b/lib/SNMP/Info/Layer3/Nag.pm @@ -0,0 +1,149 @@ +# SNMP::Info::Layer3::Nag - SNMP Interface to Nag Devices +# +# Copyright (c) 2020 by 135. + +package SNMP::Info::Layer3::Nag; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer3; + +@SNMP::Info::Layer3::Nag::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Nag::EXPORT_OK = qw//; + +our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); + +$VERSION = '3.70-135'; + +%MIBS = ( %SNMP::Info::Layer3::MIBS, ); + +%GLOBALS = ( + %SNMP::Info::Layer3::GLOBALS, + 'model_oid' => 'mib-2.47.1.1.1.1.13.1', + 'serial_oid' => 'mib-2.47.1.1.1.1.11.1', + 'hw_oid' => 'mib-2.47.1.1.1.1.8.1', + 'brom_oid' => 'mib-2.47.1.1.1.1.9.1', + 'os_ver_oid' => 'mib-2.47.1.1.1.1.10.1', +); + +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); + +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); + +sub vendor { + return 'nag'; +} + +sub os { + return 'snr-os'; +} + +sub os_ver { + my $obj = shift; + my $os_ver = $obj->os_ver_oid || undef; + my $brom = $obj->brom_oid || undef; + + + return $os_ver . ' bootrom:' . $brom + if defined $os_ver and defined $brom; + return $os_ver + if defined $os_ver; + return 'unknown'; +} +sub model { + my $obj = shift; + my $model = $obj->model_oid || undef; + my $hwver = $obj->hwver || undef; + + return $model . ' HW:' . $hwver + if defined $model and defined $hwver; + return $model + if defined $model; + return $obj->SUPER::model(); +} + +sub hwver { + my $obj = shift; + my $hwver = $obj->hw_oid || undef; + + return $hwver + if defined $hwver; +} + +sub serial { + my $obj = shift; + my $serial = $obj->serial_oid || undef; + + return $serial + if defined $serial; + return $obj->SUPER::serial(); +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer3::Nag - SNMP Interface to Nag 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 Nag Devices + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer3 + +=back + +=head2 Inherited Classes' MIBs + +See L for its own MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $obj->vendor() + +Returns 'nag' + +=item $obj->os() + +Returns 'snr-os' + +=item $obj->os_ver() + +Returns the software version. + +=item $obj->model() + +Returns the model extracted. + +=item $obj->serial() + +Returns serial number. + +=cut + +=back \ No newline at end of file