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

SNMP MIB Walker with Controlled Traversal

A Python tool for walking SNMP MIB trees with fine-grained control over traversal behavior, result limits, and error handling.

Capabilities

Walk MIB subtree only

  • Walking the system subtree (OID 1.3.6.1.2.1.1) in subtree-only mode returns only OIDs that start with 1.3.6.1.2.1.1 and stops when leaving the subtree @test

Walk entire MIB tree

  • Walking from a starting OID in lexicographic mode continues retrieving all subsequent OIDs in the MIB tree, even after leaving the initial subtree @test

Limit maximum rows retrieved

  • Walking with a maximum row limit of 5 retrieves exactly 5 rows and then stops, even if more data is available @test
  • Walking with unlimited rows retrieves all available rows without limit @test

Handle non-compliant agents

  • Walking an agent that returns non-increasing OIDs with error tolerance enabled continues the walk by skipping the problematic OID @test
  • Walking an agent that returns non-increasing OIDs with strict mode enabled stops the walk when a non-increasing OID is encountered @test

Implementation

@generates

API

import asyncio
from typing import List, Dict, Any

async def walk_mib_subtree(
    host: str,
    community: str,
    oid: str,
    port: int = 161,
    lexicographic_mode: bool = False,
    max_rows: int = 0,
    ignore_non_increasing: bool = False
) -> List[Dict[str, Any]]:
    """
    Walk an SNMP MIB tree starting from the specified OID.

    Parameters:
    - host: Target SNMP agent hostname or IP address
    - community: SNMP community string for authentication
    - oid: Starting OID for the walk operation
    - port: SNMP agent port (default: 161)
    - lexicographic_mode: If True, continue beyond the initial subtree; if False, stop at subtree boundary
    - max_rows: Maximum number of rows to retrieve (0 for unlimited)
    - ignore_non_increasing: If True, skip non-increasing OID errors; if False, stop on error

    Returns:
    - List of dictionaries, each containing:
      - 'oid': The retrieved OID as a string
      - 'value': The value associated with the OID
      - 'type': The SNMP data type of the value

    Raises:
    - Exception if network errors occur during the walk
    """
    pass

Dependencies { .dependencies }

pysnmp { .dependency }

Provides SNMP protocol implementation with async/await support for walking MIB trees with advanced parameters.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-pysnmp

tile.json