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::Info
  • SNMP::Info::Bridge
  • SNMP::Info::DocsisHE
  • SNMP::Info::Entity
  • SNMP::Info::LLDP
  • SNMP::Info::PowerEthernet
  • SNMP::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.
  • $l2->vendor() β€” tries to discover the vendor from $l2->model() and $l2->description(). Detective mode activated. πŸ”
  • $l2->serial() β€” returns a serial number if found from ENTITY-MIB and OLD-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. πŸ’…

🧚 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