Skip to main content

trishul-smi

A clean, modern SNMP MIB compiler written in Python.

PyPI Python License: MIT GitHub Stars GitHub Forks GitHub Issues

trishul-smi fetches, parses, and compiles SNMP MIB definitions (SMIv1 and SMIv2) into structured JSON or pysnmp-compatible Python modules. It resolves transitive imports automatically, caches compiled modules on disk, and ships a CLI that works out-of-the-box with no SNMP toolchain required.


Features

  • Full import closure — resolves every transitive dependency automatically
  • Full OID resolution — all objects carry absolute numeric OID paths after compile
  • Two output formats — structured JSON and pysnmp-compatible Python
  • Atomic JSON modules + optional sidecars — each module JSON is usable on its own; manifest.json and oid_index.json are additive when enabled via CompilerConfig or the CLI flags --emit-manifest / --emit-oid-index
  • Versioned JSON IR metadata — module JSON and optional sidecars carry schema_version, producer_version, generated_by, and generated_at
  • Deterministic sidecars — optional manifest.json and oid_index.json describe the final emitted JSON file set, so overlapping alias inputs do not duplicate or self-poison bundle metadata
  • Real-world parser compatibility — wrapped inline comment continuations, SNMPv2-PDU compatibility forms, preserved-source SNMPv2-TC variants that import built-in ASN.1 symbols such as OCTET STRING and OBJECT IDENTIFIER, Juniper AGENT-CAPABILITIES clauses with ACCESS not-implemented, and vendor MIBs that use lowercase local type references now compile cleanly through the standard parser path
  • Tagged ASN.1 type support — explicit base MIBs such as SNMPv2-SMI compile correctly, including application-tagged types like IpAddress and Counter32
  • pysmi-parity pysnmp output — MibTableColumn detection, full TC subtypeSpec, setIndexNames, setOrganization, setRevisions, inline constraint wrappers
  • Reverse conversion — tsmi convert FILE.py converts a compiled PySNMP module back to JSON
  • Directory compile mode — tsmi compile -d /path/to/mibs auto-discovers and compiles every MIB file
  • Concurrent fetching — parallel async HTTP with retry and timeout; parse waves stay deterministic on real MIB corpora
  • Pluggable readers — FileReader, HttpReader, ZipReader, composable via ReaderChain
  • Disk cache — compiled modules cached with mtime-based TTL; atomic writes
  • Cycle detection — Kahn's algorithm with actionable error messages
  • SMIv1 + SMIv2 — separate Lark grammars, auto-detected per MIB

Installation

pip install trishul-smi

Requires Python ≥ 3.10.


Quick Start

# Compile from a local MIB directory
tsmi compile IF-MIB --mib-dir /usr/share/snmp/mibs

# Fetch from the internet and compile to JSON + pysnmp
tsmi compile IF-MIB IP-MIB -f json -f pysnmp --online -o ./out

# Emit optional bundle sidecars for downstream JSON consumers
tsmi compile IF-MIB --online --emit-manifest --emit-oid-index -o ./out

Python API:

import asyncio
from pathlib import Path
from trishul_smi.compiler import MibCompiler
from trishul_smi.config import CompilerConfig
from trishul_smi.reader import FileReader, HttpReader

async def main():
    config = CompilerConfig(output_dir=Path("./out"))
    compiler = MibCompiler(config).add_reader(FileReader("/usr/share/snmp/mibs"))
    # optionally add HTTP: async with HttpReader(*config.sources) as http: compiler.add_reader(http)
    results = await compiler.compile("IF-MIB", "IP-MIB")
    for r in results:
        print(r.name, r.status, r.output_paths)

asyncio.run(main())

Each emitted MODULE.json is a valid standalone artifact. For downstream bundle metadata, set emit_manifest=True and/or emit_oid_index=True on CompilerConfig, or use the CLI flags --emit-manifest and --emit-oid-index. When enabled, sidecars describe the final emitted JSON file set for that compile run.


Documentation

Repository


License

MIT — see LICENSE.

Metadata

Release files for trishul-smi 0.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trishul-smi 0.4.6
File Size Uploaded
trishul_smi-0.4.6.tar.gz 133.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trishul-smi 0.4.6
File Interpreter ABI Platform
trishul_smi-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 201.3 kB

Release files / trishul_smi-0.4.6.tar.gz

Download URL trishul_smi-0.4.6.tar.gz
Size 133.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9cba3f42df8442411217313588d5e40073fde610d18ac007e90faa776e3a83bf
BLAKE2b-256 checksum
How to use checksums
a71868b7e7b9e4ab0b1d884f109ef8c3e09762b304eeebaf615292105083e56f
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 Aug 5, 2026.

Transparency log

Release files / trishul_smi-0.4.6-py3-none-any.whl

Download URL trishul_smi-0.4.6-py3-none-any.whl
Size 67.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2e9b2da47fb8327ad3d2ac8605b72c8281fc9385185ed7ed1bbe3fb49719b9b
BLAKE2b-256 checksum
How to use checksums
4234517cd621f8d3814859c63bcd1a3033524797cbb8bc41a217745d7dcc9bcc
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 Aug 5, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.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