Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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: file:///usr/share/snmp/mibs, https://pysnmp.github.io/mibs/asn1/@mib@
Borrow missing/failed MIBs from: http://pysnmp.github.io/json/fulltexts/@mib@
Existing/compiled MIB locations: 
Compiled MIBs destination directory: .
MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI,
RFC1158-MIB, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM
MIBs to compile: IF-MIB
Destination format: json
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: yes
Do not create/update MIBs: no
Byte-compile Python modules: no (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: yes
Keep original texts layout: no
Try various filenames while searching for MIB module: yes
Created/updated MIBs: IANAifType-MIB, IF-MIB, SNMPv2-MIB
Pre-compiled MIBs borrowed: 
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs: 
Ignored MIBs: 
Failed MIBs: 

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. Full index build over thousands of MIBs could be seen here.

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 https://pysnmp.github.io/mibs/asn1) 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysnmp_pysmi-2.0.0rc7.tar.gz (267.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysnmp_pysmi-2.0.0rc7-py3-none-any.whl (119.4 kB view details)

Uploaded Python 3

File details

Details for the file pysnmp_pysmi-2.0.0rc7.tar.gz.

File metadata

  • Download URL: pysnmp_pysmi-2.0.0rc7.tar.gz
  • Upload date:
  • Size: 267.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pysnmp_pysmi-2.0.0rc7.tar.gz
Algorithm Hash digest
SHA256 fc5ffeb2180c2ae028bdfd1b8176ff78627f6670709e26343b4abce89ef9f4d7
MD5 15eb1a3bb8f0d9dd02ab4fc5747c3439
BLAKE2b-256 05e872a507d30d10fd4c1c3e8a2ad0b108b1846e1181dd23f99ef0099de8d5df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysnmp_pysmi-2.0.0rc7.tar.gz:

Publisher: build-test-release.yml on pysnmp/pysmi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysnmp_pysmi-2.0.0rc7-py3-none-any.whl.

File metadata

  • Download URL: pysnmp_pysmi-2.0.0rc7-py3-none-any.whl
  • Upload date:
  • Size: 119.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pysnmp_pysmi-2.0.0rc7-py3-none-any.whl
Algorithm Hash digest
SHA256 6cb217ecd076dacdb8c655035f32dc01ed8eb2f3ec1e9448a8fa0fdb2b61ef7e
MD5 f6f63d39b9c6f224d6e3e6ebebeae8c0
BLAKE2b-256 29fb0b48628c5e564305be08b51dd50f503e917269810b799d4b94c31a1189bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysnmp_pysmi-2.0.0rc7-py3-none-any.whl:

Publisher: build-test-release.yml on pysnmp/pysmi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

This release

2.0.0rc7 This release

2 files

1.1.12

2 files

1.1.11

2 files

1.1.10

2 files

1.1.8

2 files

1.1.7

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.1

2 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