Skip to main content

py-snmp-sync

PyPI PyPI download month

Lightweight synchronous SNMPv1 Client implemented as a PySNMP wrapper optimized for sequential queries


Features

  • Synchronous API for straightforward SNMPv1 GET operations
  • Lightweight wrapper around PySNMP's core components
  • Can be used to interface Epson printers

Installation

pip install py-snmp-sync

Quick Start

from py_snmp_sync import (
    SyncUdpTransportTarget, sync_get_cmd, ObjectIdentity, CommunityData
)

target = SyncUdpTransportTarget(('demo.pysnmp.com', 161))
oid = ObjectIdentity('1.3.6.1.2.1.1.1.0')

# Perform SNMP GET request
error, status, index, binds = sync_get_cmd(
    CommunityData("public", mpModel=0),
    target,
    oid
)

if not error and not status:
    for name, value in binds:
        print(f"{name.prettyPrint()} = {value.prettyPrint()}")

Usage

Basic Configuration

transport = SyncUdpTransportTarget(
    (host, 161), 
    timeout=2, 
    retries=3
)
community = CommunityData("public", mpModel=0)  # SNMPv1
  • timeout: Response wait timeout (seconds)
  • retries: Number of retry attempts

Alternatively, community can be a string (e.g., "public").

oid can be an ObjectIdentity() (e.g., ObjectIdentity("SNMPv2-MIB", "sysDescr", 0) or ObjectIdentity('1.3.6.1.2.1.1.1.0')), or a string (e.g., "1.3.6.1.2.1.1.1.0").

sync_get_cmd() returns a tuple similar to pysnmp get_cmd(): (error_indication, error_status, error_index, var_binds) and supports multiple OIDs per request.

Batch operations

oids = [
    ObjectIdentity('1.3.6.1.2.1.1.1.0'),
    ObjectIdentity('1.3.6.1.2.1.1.5.0')
]

with SyncUdpTransportTarget(('device-ip', 161)) as transport:
    for oid in oids:
        error, status, _, binds = sync_get_cmd(community, transport, oid)
        # Handle response

Contributing

Contributions welcome! Please follow standard guidelines:

  • Fork the repository

  • Create a feature branch

  • Submit a Pull Request

License

EUPL-1.2 License - See LICENSE for details.

Metadata

Release files for py-snmp-sync 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-snmp-sync 1.0.1
File Size Uploaded
py_snmp_sync-1.0.1.tar.gz 8.9 kB Details

Release files / py_snmp_sync-1.0.1.tar.gz

Download URL py_snmp_sync-1.0.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
333e2d3ad72d7fd30a70fff05c13530bf6b6eaec8a71b67400c115dcc5829cab
BLAKE2b-256 checksum
How to use checksums
e58432e76190838fd5a8f18fcce1d97b38de9b85b85a64d99c8edf4180199fc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page