#!/usr/bin/env python3 """Example script for: Adopting CalSemVer: ezsnmp's Transition to SemVer-Compliant CalVer Source: https://carlkidcrypto.github.io/blog/ezsnmp-calsemver-versioning-transition.html """ from importlib.metadata import version from ezsnmp import Session from ezsnmp.exceptions import ConnectionError, GenericError, TimeoutError pkg_version = version("ezsnmp") print(f"Running ezsnmp {pkg_version}") with Session( hostname="localhost", community="public", version=2, timeout=2, retries=1, set_max_repeaters_to_num=25, ) as session: try: sys_descr = session.get("sysDescr.0")[0] print(f"sysDescr ({sys_descr.type}): {sys_descr.value}") except (TimeoutError, ConnectionError, GenericError) as err: print(f"SNMP query failed: {err}")