CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pysnmp

A comprehensive Python SNMP library supporting v1/v2c/v3 with authentication and privacy protocols

84

0.94x
Overview
Eval results
Files

task.mdevals/scenario-2/

Network Device Monitor

Build a simple network device monitoring utility that can query SNMP-enabled devices on a local network. The utility should support querying devices using their hostname or IP address and handle network communication properly.

Capabilities

Device Connection

  • It successfully queries a device using an IP address @test
  • It successfully queries a device using a hostname @test
  • It handles connection timeout when device is unreachable @test

Data Retrieval

  • It retrieves system description from a device @test
  • It retrieves system uptime from a device @test

Requirements

The utility should:

  1. Accept either an IP address or hostname for the target device
  2. Use standard port 161 for SNMP communication
  3. Support a configurable timeout (default: 5 seconds)
  4. Return device information including:
    • System description (OID: 1.3.6.1.2.1.1.1.0)
    • System uptime (OID: 1.3.6.1.2.1.1.3.0)
  5. Handle network errors gracefully and return meaningful error messages

Implementation

@generates

API

def query_device(target: str, community: str = "public", timeout: int = 5) -> dict:
    """
    Query an SNMP-enabled device and retrieve basic system information.

    Args:
        target: IP address or hostname of the device
        community: SNMP community string (default: "public")
        timeout: Connection timeout in seconds (default: 5)

    Returns:
        Dictionary with keys:
            - 'description': System description string
            - 'uptime': System uptime in timeticks
            - 'error': Error message if query failed (optional)

    Raises:
        ValueError: If target is empty or invalid
    """
    pass

Dependencies { .dependencies }

pysnmp { .dependency }

Provides SNMP protocol implementation and network communication support.

Install with Tessl CLI

npx tessl i tessl/pypi-pysnmp

tile.json