Skip to main content

SNMP MIB parser

Python Versions Build status Coverage Status GitHub license

PySMI is a pure-Python implementation of SNMP SMI MIB parser. This tool is designed to turn ASN.1 MIBs into various formats. As of this moment, JSON and pysnmp modules can be generated from ASN.1 MIBs.

Features

  • Understands SMIv1, SMIv2 and de-facto SMI dialects
  • Turns MIBs into pysnmp classes and JSON documents
  • Maintains an index of MIB objects over many MIB modules
  • Automatically pulls ASN.1 MIBs from local directories, ZIP archives, HTTP and FTP servers
  • 100% Python, requires Python 3.10 or newer

How to use PySMI

If you are using pysnmp, you might never notice pysmi presence - pysnmp calls pysmi for MIB download and compilation behind the scenes (you can still can do that manually by invoking mibdump tool).

To turn ASN.1 MIB into a JSON document, call mibdump tool like this:

$ mibdump --generate-mib-texts --destination-format json IF-MIB
Source MIB repositories: https://pysnmp.github.io:443/mibs/asn1/@mib@
    Borrow missing/failed MIBs from: 
    Existing/compiled MIB locations: 
    Compiled MIBs destination directory: /home/you/.pysnmp/mibs
    MIBs excluded from code generation: 
    MIBs to compile: IF-MIB
    Destination format: json
    Parser grammar cache directory: not used
    Also compile all relevant MIBs: yes
    Search pysmi's bundled base MIBs, newest revision winning: yes
    Prefer --mib-source where no revision decides: no
    Base MIBs eligible to be written out from the bundle: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM
    Rebuild MIBs regardless of age: no
    Prune stored MIBs with no remaining source: no
    Dry run mode: no
    Create/update MIBs: yes
    Byte-compile Python modules: no (optimization level no)
    Report a failed MIB as an error: yes
    Generate OID->MIB index: no
    Generate texts in MIBs: yes
    Keep original texts layout: no
    Try various file names while searching for MIB module: yes
    Created/updated MIBs: IANAifType-MIB, IF-MIB, SNMPv2-CONF, SNMPv2-MIB, SNMPv2-SMI, SNMPv2-TC
Pre-compiled MIBs borrowed: 
Up to date MIBs: 
Missing source MIBs: 
Omitted MIBs (they import a failed MIB): 
Repaired MIBs: 
MIBs found in more than one source: 
Failed MIBs: 

The Borrow missing/failed MIBs from: line is empty because there is no default borrower. Pass --mib-borrower to use the feature; the trees pysmi used to default to were compiled pysnmp modules, and those were withdrawn for the reason the MIB distribution gives.

JSON document build from IF-MIB module would hold information such as:

   {
      "ifMIB": {
          "name": "ifMIB",
          "oid": "1.3.6.1.2.1.31",
          "class": "moduleidentity",
          "revisions": [
            "2007-02-15 00:00",
            "1996-02-28 21:55",
            "1993-11-08 21:55"
          ]
        },
      ...
      "ifTestTable": {
        "name": "ifTestTable",
        "oid": "1.3.6.1.2.1.31.1.3",
        "nodetype": "table",
        "class": "objecttype",
        "maxaccess": "not-accessible"
      },
      "ifTestEntry": {
        "name": "ifTestEntry",
        "oid": "1.3.6.1.2.1.31.1.3.1",
        "nodetype": "row",
        "class": "objecttype",
        "maxaccess": "not-accessible",
        "augmention": {
          "name": "ifTestEntry",
          "module": "IF-MIB",
          "object": "ifEntry"
        }
      },
      "ifTestId": {
        "name": "ifTestId",
        "oid": "1.3.6.1.2.1.31.1.3.1.1",
        "nodetype": "column",
        "class": "objecttype",
        "syntax": {
          "type": "TestAndIncr",
          "class": "type"
        },
        "maxaccess": "read-write"
      },
      ...
   }

In general, converted MIBs capture all aspects of original (ASN.1) MIB contents and layout. The snippet above is just a partial example, but here is the complete IF-MIB.json file.

Besides one-to-one MIB conversion, PySMI library can produce JSON index to facilitate fast MIB information lookup across large collection of MIB files. For example, JSON index for IP-MIB.json, TCP-MIB.json and UDP-MIB.json modules would keep information like this:

   {
      "compliance": {
         "1.3.6.1.2.1.48.2.1.1": [
           "IP-MIB"
         ],
         "1.3.6.1.2.1.49.2.1.1": [
           "TCP-MIB"
         ],
         "1.3.6.1.2.1.50.2.1.1": [
           "UDP-MIB"
         ]
      },
      "identity": {
          "1.3.6.1.2.1.48": [
            "IP-MIB"
          ],
          "1.3.6.1.2.1.49": [
            "TCP-MIB"
          ],
          "1.3.6.1.2.1.50": [
            "UDP-MIB"
          ]
      },
      "oids": {
          "1.3.6.1.2.1.4": [
            "IP-MIB"
          ],
          "1.3.6.1.2.1.5": [
            "IP-MIB"
          ],
          "1.3.6.1.2.1.6": [
            "TCP-MIB"
          ],
          "1.3.6.1.2.1.7": [
            "UDP-MIB"
          ],
          "1.3.6.1.2.1.49": [
            "TCP-MIB"
          ],
          "1.3.6.1.2.1.50": [
            "UDP-MIB"
          ]
      }
   }

With this example, compliance and identity keys point to MODULE-COMPLIANCE and MODULE-IDENTITY MIB objects, oids list top-level OIDs branches defined in MIB modules.

The published distribution no longer carries a JSON index of its own. What it publishes is index-v2.csv, OID to module, and core.db, which answers per node rather than per module — see the MIB distribution.

The PySMI library can automatically fetch required MIBs from HTTP, FTP sites or local directories. You could configure any MIB source available to you (including the MIB distribution) for that purpose.

How to get PySMI

The pysmi package is distributed under terms and conditions of 2-clause BSD license. Source code is freely available as a GitHub repo.

Run uv add pysnmp-pysmi or pip install pysnmp-pysmi, or download it from PyPI. Note the name: pysmi is the original, unmaintained package.

To try the command-line tools without installing anything permanently:

$ uvx --from pysnmp-pysmi mibdump --help

How to develop PySMI

PySMI uses uv for dependency management, builds and releases.

$ uv sync            # create .venv and install everything, including dev tools
$ uv run pytest      # run the test suite
$ uv run mibdump --help

Linting, formatting and type checking are run through pre-commit, which is what CI checks:

$ uv run pre-commit install     # optional, to run these on every commit
$ uv run pre-commit run --all-files

That covers ruff for linting and formatting, and mypy for type checking. To build the documentation:

$ uv run sphinx-build -b html docs/source docs/build

If something does not work as expected, open an issue at GitHub or post your question on Stack Overflow.

Copyright (c) 2015-2020, Ilya Etingof. Copyright (c) 2024-2026, the PySNMP maintainers. All rights reserved.

Release files for pysnmp-pysmi 4.1.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 pysnmp-pysmi 4.1.1
File Size Uploaded
pysnmp_pysmi-4.1.1.tar.gz 4.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysnmp-pysmi 4.1.1
File Interpreter ABI Platform
pysnmp_pysmi-4.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 MB

Release files / pysnmp_pysmi-4.1.1.tar.gz

Download URL pysnmp_pysmi-4.1.1.tar.gz
Size 4.5 MB
Tags Source
SHA-256 checksum
How to use checksums
dcd364d9d1a23320ed971008c8800baf09027486f857dec2cc574a25afc9ddbf
BLAKE2b-256 checksum
How to use checksums
064ba5e9bc97a431426b27b348d36f02cc51a571570f5cc7a12b53f28b7fbaa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / pysnmp_pysmi-4.1.1-py3-none-any.whl

Download URL pysnmp_pysmi-4.1.1-py3-none-any.whl
Size 3.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
33b436c0bf8d186fb9613fc3365fe784c252b2bd22442ea16fa5d874fc14b270
BLAKE2b-256 checksum
How to use checksums
c55b94231f6aa9ee8343a5802bff43f1a41d7bae0dfc1ea8574fdc47ad305a84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

6.0.1

2 release files

6.0.0

2 release files

5.8.0

2 release files

5.7.0

2 release files

5.6.0

2 release files

5.5.0

2 release files

5.4.0

2 release files

5.3.2

2 release files

5.3.1

2 release files

5.3.0

2 release files

5.2.1

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

This release

4.1.1 This release

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.10

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.1

2 release files

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