NAME
SNMP::Info::Layer2::TPLink - SNMP Interface to TP-Link Layer2 devices
AUTHORS
Dmitry Sergienko <dmitry.sergienko@gmail.com> and Eric Miller
based on work by the Netdisco Developer Team
SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $tplink = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $tplink->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
DESCRIPTION
Provides abstraction to the configuration information obtainable from a TP-Link JetStream or Omada switch through SNMP. TP-Link private MIBs supply system information, VLANs, PoE, spanning tree, LLDP neighbors and the dynamic address table where the standard MIBs are absent or incomplete.
Inherited Classes
Required MIBs
- TPLINK-SYSINFO-MIB
- TPLINK-MIB
- TPLINK-LLDP-MIB
- TPLINK-LLDPINFO-MIB
- TPLINK-DOT1Q-VLAN-MIB
- TPLINK-PORTCONFIG-MIB
- TPLINK-SPANNING-TREE-MIB
- TPLINK-L2BRIDGE-MIB
- TPLINK-POWER-OVER-ETHERNET-MIB
Inherited MIBs
See "Required MIBs" in SNMP::Info::EtherLike for its MIB requirements.
See "Required MIBs" in SNMP::Info::Layer2 for its MIB requirements.
GLOBALS
These are methods that return scalar value from SNMP
- $tplink->vendor()
-
Returns 'TP-Link'
- $tplink->os()
-
Returns 'tplink'
- $tplink->os_ver()
-
Returns the software version from
tp_sysinfo_swver. When that is absent or empty, returns the first dotted number found insysDescr. - $tplink->model()
-
Returns the first non-blank of
tp_sysinfo_hwver(the short model with hardware version, e.g.T1600G-28TS 3.0),tp_sysinfo_descr, andsysDescr, with surrounding space removed. - $tplink->serial()
-
Returns the serial number from
tp_sysinfo_serial, or undef when it is absent or blank. - $tplink->mac()
-
Returns the base MAC address from
b_mac. When that is absent, returnstp_sysinfo_macin upper case with colon separators. - $tplink->tp_sysinfo_descr()
-
Returns the TP-Link system description, which holds the product name.
(
tpSysInfoDescription) - $tplink->tp_sysinfo_hostname()
-
Returns the administratively assigned host name.
(
tpSysInfoHostName) - $tplink->tp_sysinfo_hwver()
-
Returns the hardware version of the product.
(
tpSysInfoHwVersion) - $tplink->tp_sysinfo_swver()
-
Returns the software version of the product.
(
tpSysInfoSwVersion) - $tplink->tp_sysinfo_mac()
-
Returns the system MAC address as text, for example
74-DA-88-68-2A-D2.(
tpSysInfoMacAddr) - $tplink->tp_sysinfo_serial()
-
Returns the serial number. netdisco-mibs names this object
tpSysInfoUpTime, so it is polled by number (netdisco/netdisco-mibs#281).(
tpSysInfoSerialNum, .1.3.6.1.4.1.11863.6.1.1.8.0) - $tplink->tp_power_limit()
-
Returns the maximum power the PoE switch supplies, in watts.
(
tpSystemPowerLimit) - $tplink->tp_power_consumption()
-
Returns the real time PoE power consumption, in watts.
(
tpSystemPowerConsumption) - $tplink->tp_power_remain()
-
Returns the real time remaining PoE power, in watts.
(
tpSystemPowerRemain) - $tplink->ps1_status()
-
Returns the internal power supply status as the device reports it. netdisco-mibs lacks TPLINK-POWERSUPPLYUNIT-MIB, so it is polled by number (netdisco/netdisco-mibs#281).
(
powerSupplyUnitInternalPower, .1.3.6.1.4.1.11863.6.88.1.1.3.0) - $tplink->ps2_status()
-
Returns the external power supply status as the device reports it. netdisco-mibs lacks TPLINK-POWERSUPPLYUNIT-MIB, so it is polled by number (netdisco/netdisco-mibs#281).
(
powerSupplyUnitExternalPower, .1.3.6.1.4.1.11863.6.88.1.1.4.0)
Overrides
- $tplink->hasLLDP()
-
Returns true when "hasLLDP" in SNMP::Info::LLDP is true, or when the TP-Link neighbor table (
tp_lldp_rem_id) has rows. Otherwise returns false. - $tplink->stp_ver()
-
Returns the spanning tree mode:
stp,rstpormstp.(
tpStpMode) - $tplink->stp_time()
-
Returns the time of the last topology change as text.
(
tpStpLastTopologyChangeTime) - $tplink->stp_root()
-
Returns the CIST root bridge.
(
tpStpCISTRoot) - $tplink->stp_root_port()
-
Returns the root port.
(
tpStpRootPort) - $tplink->stp_priority()
-
Returns the bridge priority in the CIST.
(
tpStpCistPriority) - $tplink->v_index()
-
Returns reference to a hash keyed by VLAN ID. Values are the VLAN IDs. Declared as a global, but it walks the TP-Link VLAN table column in place of the Q-BRIDGE VLAN index.
(
TPLINK-DOT1Q-VLAN-MIB::dot1qVlanId) - $tplink->v_name()
-
Returns reference to a hash keyed by VLAN ID. Values are the VLAN descriptions. Declared as a global, but it walks the TP-Link VLAN table column in place of the Q-BRIDGE VLAN name.
(
TPLINK-DOT1Q-VLAN-MIB::dot1qVlanDescription)
Global Methods imported from SNMP::Info::EtherLike
See "GLOBALS" in SNMP::Info::EtherLike for details.
Global Methods imported from SNMP::Info::Layer2
See "GLOBALS" in SNMP::Info::Layer2 for details.
TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash.
Overrides
- $tplink->i_name()
-
Returns reference to hash. Port name per ifIndex:
i_aliaswhen not blank, elseifName. Wheni_aliashas no rows,tp_port_config_descrsupplies the alias instead. - $tplink->i_duplex()
-
Returns reference to hash. Duplex per ifIndex. Uses
el_duplex(EtherLike,fullorhalf, other states omitted) when it returns any rows, otherwise parsestp_lldp_oper_mau(unknownwhen the string has no duplex). - $tplink->i_duplex_admin()
-
Returns reference to hash. Configured duplex per port:
half,fullorauto.(
tpPortConfigDuplex) - $tplink->i_speed_admin()
-
Returns reference to hash. Configured speed per port, for example
speed-1Gigabpsorauto.(
tpPortConfigSpeed) - $tplink->fw_port()
-
Returns reference to hash of forwarding table entries port interface identifier (iid). Values come from
qb_fw_port(Q-BRIDGE or the TP-Link dynamic table) or else BRIDGE-MIB. Port 0 (not learned) is dropped. A port number resolves to the singleu/s/numberinterface (ambiguous on a stack), else an existing ifIndex, elsebp_index. Unresolved values stay as reported. - $tplink->qb_fw_port()
-
Returns reference to hash of Q-BRIDGE forwarding table ports, keyed
vlan.mac. Usesdot1qTpFdbPortwhen present, otherwise builds it fromtpl2BridgeManageDynPort(indexmac.vlan). Au/s/pvalue resolves through the interface port map, a port number through the singleu/s/numberinterface, thenbp_index. Unresolved values stay as reported.
TP-Link VLAN Port Table (vlanPortConfigTable, vlanConfigTable)
- $tplink->i_vlan()
-
Returns reference to hash. PVID per ifIndex from
tp_vlan_port_pvid. When that column is empty, the VLAN a port is untagged in, for ports untagged in exactly one VLAN. - $tplink->i_vlan_membership()
-
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs (sorted, no repeats) from the tagged and untagged port lists. Tokens the parser does not know, such as
Tunnel1, are skipped. Q-BRIDGE is not polled. - $tplink->i_vlan_membership_untagged()
-
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs from the untagged port lists only.
- $tplink->tp_vlan_port_pvid()
-
Returns reference to hash. PVID per ifIndex. netdisco-mibs names column 2
vlanPortTypewith enumerated labels, so the device may returntrunkfor VLAN 1;munge_tp_pvidmaps the label back. It is polled by number (netdisco/netdisco-mibs#281).(
vlanPortPvid, .1.3.6.1.4.1.11863.6.14.1.1.1.1.2) - $tplink->tp_vlan_tagged()
-
Returns reference to hash. Tagged member port list per VLAN ID, as text such as
1/0/15-18,LAG1.(
vlanTagPortMemberAdd) - $tplink->tp_vlan_untagged()
-
Returns reference to hash. Untagged member port list per VLAN ID, as text.
(
vlanUntagPortMemberAdd)
Power Over Ethernet Port Table
These methods emulate the POWER-ETHERNET-MIB Power Source Entity (PSE) Port Table pethPsePortTable methods using the TPLINK-POWER-OVER-ETHERNET-MIB PoE Port Configuration Table tpPoePortConfigTable. Entries are keyed unit.port with unit 1; ports without a matching interface are omitted.
- $tplink->peth_port_ifindex()
-
Returns reference to hash. Maps
unit.portto ifIndex for every port intp_peth_port_adminthat has an interface. - $tplink->peth_port_admin()
-
Administrative status: is this port permitted to deliver power?
trueorfalse, fromtp_peth_port_admin. - $tplink->peth_port_status()
-
Current status, from
tp_peth_port_status:onisdeliveringPower;offandturning-onaresearching;overload,short,voltage-high,voltage-low,hardware-faultandovertemperaturearefault; anything else isotherFault. A port withtp_peth_port_admindisableisdisabled. - $tplink->peth_port_class()
-
Device class as the device reports it, for example
class3, fromtp_peth_port_class. - $tplink->peth_port_power()
-
The power, in milliwatts, that the port is delivering, from
tp_peth_port_power. - $tplink->peth_power_watts()
-
The PoE power budget, in watts:
{1 => $watts}fromtp_power_limit, else an empty hash. - $tplink->peth_power_status()
-
The PoE module status:
{1 => 'on'}whentp_power_limitis reported, else an empty hash. - $tplink->tp_peth_port_admin()
-
Returns reference to hash. PoE enabled per port number:
disableorenable.(
tpPoePortStatus) - $tplink->tp_peth_port_status()
-
Returns reference to hash. PoE power state per port number, for example
on,offoroverload.(
tpPoePowerStatus) - $tplink->tp_peth_port_class()
-
Returns reference to hash. PoE class per port number.
(
tpPoeClass) - $tplink->tp_peth_port_power()
-
Returns reference to hash. Real time power per port number, in units of 0.1 W.
(
tpPoePower)
LLDP Neighbor Information
The neighbor source is decided once per device: LLDP-MIB when it has remote rows, in which case these methods defer to SNMP::Info::LLDP, otherwise the TPLINK-LLDPINFO-MIB lldpNeighborInfoTable, keyed ifIndex.remIdx.
- $tplink->lldp_if()
-
Returns reference to hash. Local ifIndex per neighbor. With TP-Link neighbor data, the first component of the
ifIndex.remIdxindex. With LLDP-MIB neighbors, the local port number in the index is mapped throughlldpLocPortIdto the interface whoseifDescrmatches exactly; a port with no exact match keeps the result of the inheritedlldp_if. - $tplink->lldp_rman_addr()
-
Returns reference to hash. With LLDP-MIB neighbors, the
lldpRemManAddrTablerows keyed by thelldpRemTableindex. Rows indexed withoutlldpRemTimeMark(localPort.remIndex.subtype.len.addr), as some Omada firmware returns them, take the index of the neighbor with the samelocalPort.remIndexand the newestlldpRemTimeMark; rows matching no neighbor are omitted. Otherwise the column as read.(
lldpRemManAddrIfSubtype) - $tplink->lldp_ip()
-
Returns reference to hash. Remote IPv4 management address per neighbor from
tp_lldp_rman.::a.b.c.dis returned asa.b.c.d;::and IPv6 are omitted. - $tplink->lldp_ipv6()
-
Returns reference to hash. Remote IPv6 management address per neighbor from
tp_lldp_rman, as reported.::and::a.b.c.dare omitted. - $tplink->lldp_port()
-
Returns reference to hash. Remote port per neighbor:
tp_lldp_rem_pid, elsetp_lldp_rem_desc. - $tplink->lldp_id()
-
Returns reference to hash. Remote chassis id per neighbor from
tp_lldp_rem_id, as reported. - $tplink->lldp_platform()
-
Returns reference to hash. Remote platform per neighbor:
tp_lldp_rem_sysdesc, elsetp_lldp_rem_sysname. - $tplink->lldp_cap()
-
Returns reference to hash of arrays. Remote capabilities per neighbor as LLDP-MIB names such as
bridgeandrouter, parsed from thetp_lldp_rem_cap_spttext. Unknown words are dropped. - $tplink->tp_lldp_rem_id()
-
Returns reference to hash. Remote chassis id as text, for example
48:A9:8A:C1:AC:58.(
lldpNeighborChassisId) - $tplink->tp_lldp_rem_pid()
-
Returns reference to hash. Remote port id (column 6). Column 1,
lldpNeighborPortId, is the local port.(
lldpNeighborPortIdDescr) - $tplink->tp_lldp_rem_desc()
-
Returns reference to hash. Remote port description.
(
lldpNeighborPortDescr) - $tplink->tp_lldp_rem_sysname()
-
Returns reference to hash. Remote system name.
(
lldpNeighborDeviceName) - $tplink->tp_lldp_rem_sysdesc()
-
Returns reference to hash. Remote system description.
(
lldpNeighborDeviceDescr) - $tplink->tp_lldp_rem_cap_spt()
-
Returns reference to hash. Remote capabilities as text, for example
Bridge Router.(
lldpNeighborCapAvailable) - $tplink->tp_lldp_rman()
-
Returns reference to hash. Remote management address as text, for example
::169.254.2.131.(
lldpNeighborManageIpAddr) - $tplink->tp_lldp_oper_mau()
-
Returns reference to hash. Local operational MAU per ifIndex, for example
speed(1000M)/duplex(Full). Used byi_duplexwhen EtherLike is absent.(
lldpLocalOperMau)
Spanning Tree Port Table
These methods map the TPLINK-SPANNING-TREE-MIB objects onto the SNMP::Info::Bridge spanning tree methods.
- $tplink->stp_i_root()
-
Returns reference to hash. CIST root bridge.
(
tpStpCISTRoot) - $tplink->stp_i_time()
-
Returns reference to hash. Time of the last topology change.
(
tpStpLastTopologyChangeTime) - $tplink->stp_i_root_port()
-
Returns reference to hash. Root port.
(
tpStpRootPort) - $tplink->stp_i_priority()
-
Returns reference to hash. Bridge priority in the CIST.
(
tpStpCistPriority) - $tplink->stp_p_id()
-
Returns reference to hash. Port number of the switch.
(
tpStpPortNumber) - $tplink->stp_p_priority()
-
Returns reference to hash. Port priority.
(
tpStpPortPriority) - $tplink->stp_p_state()
-
Returns reference to hash. Port state, for example
blockingorforwarding.(
tpStpPortStatus) - $tplink->stp_p_cost()
-
Returns reference to hash. Internal path cost of the port.
(
tpStpPortInPathCost) - $tplink->stp_p_role()
-
Returns reference to hash. Port role, for example
rootordesignated.(
tpStpPortRole) - $tplink->is_edgeport_admin()
-
Returns reference to hash. Edge port setting:
disableorenable.(
tpStpEdgePortStatus) - $tplink->is_edgeport_oper()
-
Returns reference to hash. Edge port status, read from the same object as
is_edgeport_admin.(
tpStpEdgePortStatus)
Port Configuration and Dynamic Address Tables
- $tplink->tp_port_config_descr()
-
Returns reference to hash. Port description, used by
i_namewhenifAliashas no rows.(
tpPortConfigDescription) - $tplink->tpl2BridgeManageDynMac()
-
Returns reference to hash. Dynamic MAC address, indexed
mac.vlan.(
tpl2BridgeManageDynMac) - $tplink->tpl2BridgeManageDynVlanId()
-
Returns reference to hash. VLAN ID of the dynamic MAC address.
(
tpl2BridgeManageDynVlanId) - $tplink->tpl2BridgeManageDynPort()
-
Returns reference to hash. Port of the dynamic MAC address, as a
u/s/pname or a port number. Used byqb_fw_portwhen Q-BRIDGE is absent.(
tpl2BridgeManageDynPort)
Table Methods imported from SNMP::Info::EtherLike
See "TABLE METHODS" in SNMP::Info::EtherLike for details.
Table Methods imported from SNMP::Info::Layer2
See "TABLE METHODS" in SNMP::Info::Layer2 for details.