#!/usr/bin/env python3 """Example script for: Standalone Cross-Platform Wheels: Zero External Deps in ezsnmp Source: https://carlkidcrypto.github.io/blog/ezsnmp-standalone-cross-platform-wheels.html """ from importlib.metadata import version from ezsnmp import Session from ezsnmp.exceptions import ConnectionError, GenericError, TimeoutError print(f"ezsnmp version: {version('ezsnmp')}") # Standalone wheels bundle Net-SNMP 5.10 libraries internally with Session( hostname="127.0.0.1", community="public", version=2, timeout=2, retries=1, set_max_repeaters_to_num=25, ) as session: try: uptime = session.get("sysUpTime.0")[0] print(f"sysUpTime ({uptime.type}): {uptime.value}") except (TimeoutError, ConnectionError, GenericError) as err: print(f"Target unreachable: {err}")