155 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			155 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
# 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<SNMP::Info::Layer3/"Required MIBs"> 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 |