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-7/

IPv6 Network Device Monitor

Overview

Build a network monitoring tool that queries SNMP-enabled devices over IPv6 networks. The tool should perform basic SNMP GET operations to retrieve system information from remote devices using IPv6 addresses.

Requirements

Core Functionality

  1. IPv6 SNMP Query Support

    • Connect to SNMP agents using IPv6 addresses
    • Support both full IPv6 addresses and compressed notation
    • Handle IPv6 zone IDs for link-local addresses when needed
    • Use UDP as the transport protocol
  2. System Information Retrieval

    • Query and retrieve the system description (sysDescr - OID: 1.3.6.1.2.1.1.1.0)
    • Query and retrieve the system uptime (sysUpTime - OID: 1.3.6.1.2.1.1.3.0)
    • Query and retrieve the system contact (sysContact - OID: 1.3.6.1.2.1.1.4.0)
  3. Asynchronous Operations

    • Implement queries using Python's asyncio framework
    • Support concurrent queries to multiple devices
    • Handle timeouts and connection errors gracefully
  4. Authentication

    • Support SNMPv2c with community strings
    • Accept community string as a configuration parameter (default: "public")

Implementation Details

Input Format

The tool should accept a list of target devices with the following information:

  • IPv6 address (string)
  • SNMP port (default: 161)
  • Community string (default: "public")

Output Format

For each successfully queried device, output:

  • Device IPv6 address
  • System description
  • System uptime
  • System contact

For failed queries, output:

  • Device IPv6 address
  • Error message or indication of failure

Module Structure

Create the following files:

  • ipv6_monitor.py - Main implementation with query functions
  • test_ipv6_monitor.py - Test suite

Test Cases { .tests }

Test 1: Query IPv6 Device { .test }

Description: Successfully query system information from an SNMP agent over IPv6

Setup:

  • Mock SNMP agent listening on ::1 (IPv6 localhost) port 161
  • Agent responds to GET requests for sysDescr, sysUpTime, and sysContact OIDs
  • Community string: "public"

Expected behavior:

  • Successfully retrieve all three OID values
  • Return non-empty strings/values for each OID
  • No error indications

Test 2: Handle Connection Timeout { .test }

Description: Gracefully handle timeout when SNMP agent doesn't respond

Setup:

  • Target IPv6 address points to non-responsive host
  • Short timeout configured (e.g., 1 second)

Expected behavior:

  • Query should timeout within the configured period
  • Return error indication or None values
  • Should not raise unhandled exceptions

Test 3: Query Multiple Devices Concurrently { .test }

Description: Query multiple IPv6 devices in parallel using asyncio

Setup:

  • Multiple mock SNMP agents on different IPv6 addresses
  • Each agent responds with unique system descriptions

Expected behavior:

  • All queries execute concurrently (not sequentially)
  • Results returned for all devices
  • Order may vary but all devices are queried
  • Total execution time should be close to single-query time, not sum of all queries

Dependencies { .dependencies }

pysnmp { .dependency }

Provides SNMP protocol implementation with IPv6 support.

Constraints

  • Use Python 3.8 or higher
  • Keep the implementation simple and focused on the core requirements
  • External dependencies should be limited to pysnmp and standard library modules
  • The tool should work with standard SNMP agents that support SNMPv2c

Install with Tessl CLI

npx tessl i tessl/pypi-pysnmp

tile.json