{"id":13606593,"url":"https://github.com/trehn/hnmp","last_synced_at":"2025-08-21T00:32:06.124Z","repository":{"id":17901965,"uuid":"20857712","full_name":"trehn/hnmp","owner":"trehn","description":"High-level Python SNMP library","archived":false,"fork":false,"pushed_at":"2021-11-28T17:29:20.000Z","size":36,"stargazers_count":49,"open_issues_count":3,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-08-20T13:54:25.431Z","etag":null,"topics":["library","python","snmp"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trehn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-15T14:53:28.000Z","updated_at":"2024-02-22T09:34:08.000Z","dependencies_parsed_at":"2022-09-02T12:30:21.548Z","dependency_job_id":null,"html_url":"https://github.com/trehn/hnmp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/trehn/hnmp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trehn%2Fhnmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trehn%2Fhnmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trehn%2Fhnmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trehn%2Fhnmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trehn","download_url":"https://codeload.github.com/trehn/hnmp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trehn%2Fhnmp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271409449,"owners_count":24754715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","python","snmp"],"created_at":"2024-08-01T19:01:10.503Z","updated_at":"2025-08-21T00:32:05.882Z","avatar_url":"https://github.com/trehn.png","language":"Python","funding_links":[],"categories":["Libraries","python"],"sub_categories":["Python"],"readme":"HNMP is a high-level Python library to ease the pain of retrieving and processing data from SNMP-capable devices such as network switches, routers, and printers. It's not meant to provide everything SNMP has to offer, but to get rid of most of the suck inherent to writing Munin or Icinga plugins that process SNMP data.\n\nHNMP is meant to be used like this:\n\n1. acquire MIB files (optional, some luck required)\n2. use a MIB browser application like [this freeish and cross-platform one](http://ireasoning.com/mibbrowser.shtml) to figure out the numeric OIDs you're interested in\n3. use HNMP to retrieve your data and do some light processing\n4. put human on Mars :rocket:\n\nUsage\n-----\n\n```python\n\u003e\u003e\u003e from hnmp import SNMP\n\u003e\u003e\u003e\n\u003e\u003e\u003e snmp = SNMP(\"example.com\", community=\"public\")  # v2c\n\u003e\u003e\u003e snmp = SNMP(\n...    \"example.com\",\n...    version=3,\n...    username=\"jdoe\",\n...    authproto=\"sha\",\n...    authkey=\"secret\",\n...    privproto=\"aes128\",\n...    privkey=\"secret\",\n... )  # v3\n\n# get a single value\n\u003e\u003e\u003e uptime = snmp.get(\"1.3.6.1.2.1.1.3.0\")\n\u003e\u003e\u003e uptime\ndatetime.timedelta(412, 29152)\n\n# build a table from MIB AIRESPACE-WIRELESS-MIB::bsnMobileStationEntry.\n\u003e\u003e\u003e bsnMobileStationEntryOID = \"1.3.6.1.4.1.14179.2.1.4.1\"\n\u003e\u003e\u003e wifi_clients = snmp.table(\n\u003e\u003e\u003e     bsnMobileStationEntryOID,\n\u003e\u003e\u003e     columns={\n\u003e\u003e\u003e         3: \"username\",\n\u003e\u003e\u003e         25: \"protocol\",\n\u003e\u003e\u003e     },\n\u003e\u003e\u003e     column_value_mapping={\n\u003e\u003e\u003e         \"protocol\": {\n\u003e\u003e\u003e             3: \"802.11g\",\n\u003e\u003e\u003e             6: \"802.11n\",\n\u003e\u003e\u003e         },\n\u003e\u003e\u003e     },\n\u003e\u003e\u003e     fetch_all_columns=False,  # fetch only named columns (useful with large tables)\n\u003e\u003e\u003e )\n\u003e\u003e\u003e\n\u003e\u003e\u003e wifi_clients.columns[\"username\"]\n(\"jdoe\", \"rms\", \"bwayne\")\n\u003e\u003e\u003e wifi_clients.columns[\"protocol\"]\n(\"802.11g\", \"802.11n\", \"802.11n\")\n\u003e\u003e\u003e wifi_clients.rows[0][\"username\"]\n\"jdoe\"\n\n# conveniently count column values\n\u003e\u003e\u003e wifi_clients.columns[\"protocol\"]\n(\"802.11g\", \"802.11n\", \"802.11n\")\n\u003e\u003e\u003e wifi_clients.columns[\"protocol\"].value_count\n{\"802.11g\": 1, \"802.11n\": 2}\n\n# helpers for converting MAC and IP addresses\n\u003e\u003e\u003e from hnmp import ipv4_address, mac_address\n\u003e\u003e\u003e raw_string = snmp.get(\"1.3.6.1.4.1.9.9.513.1.1.1.1.2.[...]\")\n\u003e\u003e\u003e raw_string\n't\u0026\\xac\\x1b\\xe7\\xa1'\n\u003e\u003e\u003e mac_address(raw_string)\n'74:26:ac:1b:e7:a1'\n\u003e\u003e\u003e ipv4_address(snmp.get(\"1.3.6.1.4.1.9.9.513.1.1.1.1.11.[...]\"))\n'10.1.2.3'\n\n# set a value\n\u003e\u003e\u003e snmp.set(\"1.2.3.4.5.6.7.8.9.0\", \"foobar\")\n\u003e\u003e\u003e snmp.set(\"1.2.3.4.5.6.7.8.9.0\", \"10.1.2.3\")  # IPv4 address is converted automatically\n\u003e\u003e\u003e snmp.set(\"1.2.3.4.5.6.7.8.9.0\", 23, value_type='Counter64')  # use explicit type\n```\n\nInstall\n-------\n\n```\npip install hnmp\n```\n\nFAQ\n---\n\n### How do the table OIDs work?\n\nQuite often you will find that you need to query a whole table instead of a single value (e.g. a list of network interfaces). This is how the OIDs are organized in a table:\n\n```\n1.3.6.1.4.1.9.9.513.1.1.1.1.11.1.2.3.4.5\n1.3.6.1.4.1.9.9.513.1.1.1.1.11.1.2.3.4.6\n1.3.6.1.4.1.9.9.513.1.1.1.1.11.1.2.3.4.7\n1.3.6.1.4.1.9.9.513.1.1.1.1.12.1.2.3.4.5\n1.3.6.1.4.1.9.9.513.1.1.1.1.12.1.2.3.4.6\n1.3.6.1.4.1.9.9.513.1.1.1.1.12.1.2.3.4.7\n\\_____________ ____________/|  \\___ ___/\n              │             │      |\n              │             │    Row ID\n              │             │\n              │          Column ID\n              │\n           Base OID\n```\n\nStarting from the base OID (`1.3.6.1.4.1.9.9.513.1.1.1.1` in this example), you will see the different column IDs (`11` and `12` in this example) repeated for every row. Row IDs consist of everything after the column ID. Sometimes these are only sequential single digits, but they can also be made up of multiple numbers. In this example, there are three rows with IDs `1.2.3.4.5`, `1.2.3.4.6`, and `1.2.3.4.7`.\n\n### Why doesn't HNMP support loading MIB files?\n\nDepending on MIB files would make the calling piece of code harder to distribute (since you need to include the MIBs, which may have some nasty non-free license attached to them). I consider MIB files a means to manually discover OIDs, nothing more. HNMP is biased towards use in scripts rather than full-blown applications. Having to use a library is bad enough for scripts, MIBs would just make your script even more unwieldy.\n\n------------------------------------------------------------------------\n\n![PyPI version](http://img.shields.io/pypi/v/hnmp.svg) \u0026nbsp; ![Python 3](http://img.shields.io/pypi/pyversions/hnmp.svg) \u0026nbsp; ![ISC license](http://img.shields.io/badge/License-ISC-red.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrehn%2Fhnmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrehn%2Fhnmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrehn%2Fhnmp/lists"}