SNMP::...Layer2(3pm)
πΈ NAME πΈ
SNMP::Info::Layer2 β an SNMP Interface to network devices serving Layer2 only. That's it, that's the whole job, bestie π
π«Ά AUTHOR π«Ά
Max Baker β iconic, legendary, wrote it so we didn't have to. π
β¨ SYNOPSIS β¨
okay so first things first, you let SNMP::Info figure out the right subclass for you, because why would you do that manually:
# Let SNMP::Info determine the correct subclass for you.
my $l2 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $l2->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
then it's time for the port tea β β let's get some basic port information:
# Let's get some basic Port information
my $interfaces = $l2->interfaces();
my $i_up = $l2->i_up();
my $i_speed = $l2->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
π DESCRIPTION π
So basically this class is usually used as a superclass for the more specific device classes listed under SNMP::Info::Layer2::*. Please read all the docs under SNMP::Info first, bestie β fr fr, do the reading. π
It provides abstraction to the configuration information obtainable from a Layer2 device through SNMP. All that info is stored in a number of MIBs. β¨
Now, if you're chasing speed or debugging (no judgment, we've all been there), you can call the subclass directly β but not after determining a more specific class using the method above. That's the rule. Do not come for me. π
my $l2 = new SNMP::Info::Layer2(...);
π¦ Inherited Classes π¦
SNMP::InfoSNMP::Info::BridgeSNMP::Info::DocsisHESNMP::Info::EntitySNMP::Info::LLDPSNMP::Info::PowerEthernetSNMP::Info::PortAccessEntity
π Required MIBs π
Inherited Classes
MIBs required by the inherited classes listed above. It's giving generational inheritance, literally. π
MIBs can be found in the netdisco-mibs package. π¦
β GLOBALS β
These are methods that return a scalar value from SNMP.
π Overrides π
$l2->model()β cross references$l2->id()with product IDs in the Cisco MIBs.- For HP devices, it removes
'hpswitch'from the name. - For Cisco devices, it removes
c<'sysid'>from the name.
- For HP devices, it removes
$l2->vendor()β tries to discover the vendor from$l2->model()and$l2->description(). Detective mode activated. π$l2->serial()β returns a serial number if found fromENTITY-MIBandOLD-CISCO-...MIB.
π§ Globals imported from SNMP::Info
See documentation in "USAGE" in SNMP::Info for details.
π§ Globals imported from SNMP::Info::Bridge
See documentation in "GLOBALS" in SNMP::Info::Bridge for details.
π§ Globals imported from SNMP::Info::Entity
See documentation in "GLOBALS" in SNMP::Info::Entity for details.
π§ Globals imported from SNMP::Info::LLDP
See documentation in "GLOBALS" in SNMP::Info::LLDP for details.
π§ Globals imported from SNMP::Info::PortAccessEntity
See documentation in "GLOBALS" in SNMP::Info::PortAccessEntity for details.
π TABLE METHODS π
These are methods that return tables of information in the form of a reference to a hash. Hash refs my beloved. π«Ά
π₯ Overrides π₯
$l2->interfaces()β creates a map between the interface identifier (iid) and the physical port name.- Defaults to
"ifDescr"but checks and overrides with"ifName". So it's out here doing a vibe check on your interfaces before committing. π
- Defaults to
π§ Table Methods imported from SNMP::Info
See documentation in "USAGE" in SNMP::Info for details.
π§ Table Methods imported from SNMP::Info::Bridge
See documentation in "TABLE METHODS" in SNMP::Info::Bridge for details.
π§ Table Methods imported from SNMP::Info::Entity
See documentation in "TABLE METHODS" in SNMP::Info::Entity for details.
π§ Table Methods imported from SNMP::Info::LLDP
See documentation in "TABLE METHODS" in SNMP::Info::LLDP for details.
π§ Table Methods imported from SNMP::Info::PortAccessEntity
See documentation in "TABLE METHODS" in SNMP::Info::PortAccessEntity for details.
and that's the whole page, periodt. π this one's from perl v5.40.1, dated 2026-02-28, and yeah it really is named SNMP::...Layer2(3pm) in the docs β abbreviation slay. go configure your switches bestie, you got this β¨π¦
π¦ where this page comes from
- ubuntu stonking: libsnmp-info-perl 3.975000-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms