| PyPI | Python | Release Date | Downloads |
|---|---|---|---|
| CI | License | Typed | Issues | Discussions |
|---|---|---|---|---|
A Python library that reads what your managed network switches know over SNMP: ports with link, speed and traffic, PoE, the MAC address table, LLDP neighbours, trunks and spanning tree. Across several switches it works out which device is connected to which port. It only reads and never changes a setting.
It uses standard MIBs, so it is vendor-neutral; a vendor table is read only where the standard one is missing and the table was measured on that model (temperatures of the HPE Instant On 1930). HPE OfficeConnect 1920S and HPE Instant On 1930 are the tested references. It is built as a foundation for Home Assistant, but works in any asyncio program.
Documentation: aiosnmpswitch.eize.dev
| ✅ Tested | HPE OfficeConnect 1920S (JL383A, PD.02.22), HPE Instant On 1930 (JL680A, 3.4.0.0) |
| 🟡 Expected to work | Managed switches with SNMP and the standard MIBs (IF-MIB, Q-BRIDGE-MIB, LLDP-MIB) |
| ❔ Partly | Switches without LLDP or Q-BRIDGE-MIB: fewer details, no uplink detection; PoE watts per port are not in the standard MIB |
| ❌ Not in scope | Unmanaged and "smart" switches without SNMP, changing settings |
Each getter returns an empty result when the switch lacks its MIB. How to report your model: Compatibility.
You need Python 3.12 or newer and SNMP read access to the switch: SNMPv3 (recommended) or a v2c community. To locate devices across several switches, LLDP must be on on each of them.
pip install aiosnmpswitchimport asyncio
from aiosnmpswitch import AuthProtocol, PrivProtocol, SnmpSwitch, UsmAuth
from aiosnmpswitch.helpers import SwitchData, locate_macs
async def main() -> None:
auth = UsmAuth("monitor", "auth-key", "priv-key", AuthProtocol.SHA, PrivProtocol.AES128)
async with await SnmpSwitch.connect("192.0.2.10", auth) as switch:
system = await switch.get_system()
print(system.name, system.descr)
interfaces = await switch.get_interfaces()
for port in interfaces.values():
print(port.name, port.oper_status, port.high_speed, port.alias)
data = SwitchData(
interfaces=interfaces,
bridge_ports=await switch.get_bridge_ports(),
fdb=await switch.get_fdb(),
lldp=await switch.get_lldp(),
lag_ports=await switch.get_lag_ports(),
)
for mac, where in locate_macs({"core": data}).items():
print(mac, "on port", where.port_name)
asyncio.run(main())- Getting started: install, SNMPv3 or v2c, first read
- What it can read: every getter, one per MIB group, and the helpers
- Locating devices: which device is on which port, across switches
- Errors and Diagnostics: a report to attach to an issue, without personal data
- Compatibility and Design
Planned work is grouped in milestones.
Reports with your switch model and firmware help most. See CONTRIBUTING.md; for security issues SECURITY.md.
MIT. Provided "as is", without warranty of any kind. The icon and header images are CC BY 4.0; their source is in eizedev/brand.