{"id":13397028,"url":"https://github.com/qmsk/snmpbot","last_synced_at":"2025-09-03T02:34:12.216Z","repository":{"id":57496589,"uuid":"111233118","full_name":"qmsk/snmpbot","owner":"qmsk","description":"Golang SNMP library + SNMP REST API","archived":false,"fork":false,"pushed_at":"2020-08-22T21:21:45.000Z","size":438,"stargazers_count":53,"open_issues_count":4,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-09T01:48:21.844Z","etag":null,"topics":["golang","json","rest-api","snmp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qmsk.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-11-18T19:30:43.000Z","updated_at":"2024-09-02T02:46:45.000Z","dependencies_parsed_at":"2022-09-02T00:23:50.741Z","dependency_job_id":null,"html_url":"https://github.com/qmsk/snmpbot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/qmsk/snmpbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qmsk%2Fsnmpbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qmsk%2Fsnmpbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qmsk%2Fsnmpbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qmsk%2Fsnmpbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qmsk","download_url":"https://codeload.github.com/qmsk/snmpbot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qmsk%2Fsnmpbot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273381315,"owners_count":25095294,"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-09-03T02:00:09.631Z","response_time":76,"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":["golang","json","rest-api","snmp"],"created_at":"2024-07-30T18:01:09.691Z","updated_at":"2025-09-03T02:34:12.172Z","avatar_url":"https://github.com/qmsk.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/qmsk/snmpbot.svg?branch=master)](https://travis-ci.com/qmsk/snmpbot)\n\n# github.com/qmsk/snmpbot\n\nSNMP client (manager) library for Go with support for SMI MIBs.\n\nREST (HTTP/JSON) API for writing SNMP applications.\n\n## Quickstart\n\nThe easiest way to run `snmpbot` is using the [pre-built Docker image](https://hub.docker.com/r/qmsk/snmpbot/):\n\n```\n$ docker run --net=host qmsk/snmpbot\nINFO mibs: Load MIBs from directory: /opt/qmsk/snmpbot/mibs\n...\nINFO web: Listen on :8286...\n```\n\nThe pre-build Docker images contain the [most common MIB definitions](https://github.com/qmsk/snmpbot-mibs).\n\n### Querying a scalar object\n\nYou can then query the API at `:8286`:\n\n#### `$ curl -s 'http://localhost:8286/api/hosts/public@localhost/objects/SNMPv2-MIB::sysDescr' | jq`\n```json\n{\n  \"ID\": \"SNMPv2-MIB::sysDescr\",\n  \"Instances\": [\n    {\n      \"HostID\": \"public@localhost\",\n      \"Value\": \"Linux tehobari 4.15.0-33-generic #36~16.04.1-Ubuntu SMP Wed Aug 15 17:21:05 UTC 2018 x86_64\"\n    }\n  ]\n}\n```\n\n### Querying multi-instance objects\n\nYou can query an object with multiple instances, and `snmpbot` will parse the OID indexes:\n\n#### `$ curl -s 'http://localhost:8286/api/hosts/public@localhost/objects/IF-MIB::ifName' | jq`\n```\n{\n  \"ID\": \"IF-MIB::ifName\",\n  \"IndexKeys\": [\n    \"IF-MIB::ifIndex\"\n  ],\n  \"Instances\": [\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 1\n      },\n      \"Value\": \"lo\"\n    },\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 2\n      },\n      \"Value\": \"enp0s31f6\"\n    },\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 4\n      },\n      \"Value\": \"wlp4s0\"\n    },\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 5\n      },\n      \"Value\": \"docker0\"\n    },\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 95\n      },\n      \"Value\": \"wwp0s20f0u3c2\"\n    }\n  ]\n}\n```\n\n### Querying tables\n\nYou can also query tables, and `snmpbot` will group the objects into entries with indexes:\n\n#### `curl -s 'http://localhost:8286/api/hosts/public@localhost/tables/IF-MIB::ifTable' | jq`\n```json\n{\n  \"ID\": \"IF-MIB::ifTable\",\n  \"IndexKeys\": [\n    \"IF-MIB::ifIndex\"\n  ],\n  \"ObjectKeys\": [\n    \"IF-MIB::ifIndex\",\n    \"IF-MIB::ifDescr\",\n    \"IF-MIB::ifType\",\n    \"IF-MIB::ifMtu\",\n    \"IF-MIB::ifSpeed\",\n    \"IF-MIB::ifPhysAddress\",\n    \"IF-MIB::ifAdminStatus\",\n    \"IF-MIB::ifOperStatus\",\n    \"IF-MIB::ifLastChange\",\n    \"IF-MIB::ifInOctets\",\n    \"IF-MIB::ifInUcastPkts\",\n    \"IF-MIB::ifInNUcastPkts\",\n    \"IF-MIB::ifInDiscards\",\n    \"IF-MIB::ifInErrors\",\n    \"IF-MIB::ifInUnknownProtos\",\n    \"IF-MIB::ifOutOctets\",\n    \"IF-MIB::ifOutUcastPkts\",\n    \"IF-MIB::ifOutNUcastPkts\",\n    \"IF-MIB::ifOutDiscards\",\n    \"IF-MIB::ifOutErrors\",\n    \"IF-MIB::ifOutQLen\",\n    \"IF-MIB::ifSpecific\"\n  ],\n  \"Entries\": [\n    {\n      \"HostID\": \"public@localhost\",\n      \"Index\": {\n        \"IF-MIB::ifIndex\": 1\n      },\n      \"Objects\": {\n        \"IF-MIB::ifAdminStatus\": \"up\",\n        \"IF-MIB::ifDescr\": \"lo\",\n        \"IF-MIB::ifInDiscards\": 0,\n        \"IF-MIB::ifInErrors\": 0,\n        \"IF-MIB::ifInNUcastPkts\": 0,\n        \"IF-MIB::ifInOctets\": 1692789727,\n        \"IF-MIB::ifInUcastPkts\": 1086499,\n        \"IF-MIB::ifInUnknownProtos\": 0,\n        \"IF-MIB::ifIndex\": 1,\n        \"IF-MIB::ifLastChange\": 0,\n        \"IF-MIB::ifMtu\": 65536,\n        \"IF-MIB::ifOperStatus\": \"up\",\n        \"IF-MIB::ifOutDiscards\": 0,\n        \"IF-MIB::ifOutErrors\": 0,\n        \"IF-MIB::ifOutNUcastPkts\": 0,\n        \"IF-MIB::ifOutOctets\": 1692789727,\n        \"IF-MIB::ifOutQLen\": 0,\n        \"IF-MIB::ifOutUcastPkts\": 1086499,\n        \"IF-MIB::ifPhysAddress\": \"\",\n        \"IF-MIB::ifSpecific\": \".0.0\",\n        \"IF-MIB::ifSpeed\": 10000000,\n        \"IF-MIB::ifType\": \"softwareLoopback\"\n      }\n    },\n    ...\n  ]\n}\n```\n\n### Advanced usage\n\nSee the remainder of the README for more advanced usage, including:\n\n* Querying multiple objects in parallel\n* Querying multiple tables in parallel\n* Configuring hosts (static TOML config file, or dynamic HTTP `POST/PUT/DELETE` API)\n* Querying multiple hosts in parallel\n\n## Requirements\n\n### Go version 1.10\n\n* [encoding/asn1: add MarshalWithParams](https://github.com/golang/go/commit/c32626a4ce9293979c407c4e6a799d1bec37aa18#diff-3c740598b49abcc8e5f74f801dc75255)\n\n### Go version 1.9\n\n* [encoding/asn1: add NullBytes and NullRawValue for working with ASN.1 NULL](https://github.com/golang/go/commit/d9b1f9e85ee097ebc95c5904cee921ba7be4f732)\n\n### SNMP MIBs\n\nSNMP MIBs must be pre-processed into a custom JSON format for use with `snmpbot`.\n\nCommon pre-processed MIBs can be found at [github.com/qmsk/snmpbot-mibs](https://github.com/qmsk/snmpbot-mibs):\n\n    git clone https://github.com/qmsk/snmpbot-mibs\n    export SNMPBOT_MIBS=$PWD/snmpbot-mibs\n\nCustom MIBs can be imported using the [`mib-import.py` script](./scripts).\n\n## Go Libraries\n\n### `github.com/qmsk/snmpbot/snmp`\n\n[![](https://godoc.org/github.com/qmsk/snmpbot/snmp?status.svg)](http://godoc.org/github.com/qmsk/snmpbot/snmp)\n\nLow-level SNMP protocol support.\n\n* Using [github.com/geoffgarside/ber](github.com/geoffgarside/ber) for BER decoding.\n\n### `github.com/qmsk/snmpbot/client`\n\n[![](https://godoc.org/github.com/qmsk/snmpbot/client?status.svg)](http://godoc.org/github.com/qmsk/snmpbot/client)\n\nSNMP client with support for UDP queries\n\n* Multiple parallel requests (goroutine-safe)\n* Request timeout and retry\n* Get request splitting (large numbers of OIDs)\n\n### `github.com/qmsk/snmpbot/mibs`\n\n[![](https://godoc.org/github.com/qmsk/snmpbot/mibs?status.svg)](http://godoc.org/github.com/qmsk/snmpbot/mibs)\n\nSMI support for MIBs\n\n* Initialize using `Load(path string)` to load the `.json` MIB files\n* Resolving strings like `\"interfaces::ifDescr\"` to `*Object`\n* Resolving OIDs like `ParseOID(\".1.3.6.1.2.1.2.2.1.2\")` to `*Object`\n* Decoding SMI object `SYNTAX` to `interface{}`, including `encoding/json` support\n* Decoding SMI table `INDEX` syntax from OIDs\n\n### `github.com/qmsk/snmpbot/server`\n\n[![](https://godoc.org/github.com/qmsk/snmpbot/server?status.svg)](http://godoc.org/github.com/qmsk/snmpbot/server)\n\nSNMP manager with REST API.\n\n## CLI Commands\n\nThese are mostly meant for testing.\n\nAll of the commands support the same common flags:\n\n```\n  -debug\n        Log debug\n  -quiet\n        Do not log warnings\n  -snmp-community string\n        Default SNMP community (default \"public\")\n  -snmp-maxvars uint\n        Maximum request VarBinds (default 10)\n  -snmp-mibs string\n        Load MIBs from path (default $SNMPBOT_MIBS)\n  -snmp-retry int\n        SNMP request retry\n  -snmp-timeout duration\n        SNMP request timeout (default 1s)\n  -snmp-udp-size uint\n        Maximum UDP recv size (default 1500)\n  -verbose\n        Log info\n```\n\nApart from the `snmpbot` command, the first argument is a SNMP address of the form `[COMMUNITY@]HOST[:PORT]`, and the remainder are SMI objects of the form `[MIB[::OBJECT]][.INDEX]`.\n\n### `github.com/qmsk/snmpbot/cmd/snmpget`\n\nTesting `GetRequest`; note that non-tabular SNMP objects cannot be fetched without the `.0` instance suffix.\n\n#### `snmpget public@edgeswitch-098730 system::sysDescr`\n```\n2017/11/18 22:02:49 VarBind[.1.3.6.1.2.1.1.1](system::sysDescr): SNMP VarBind Error: NoSuchInstance\n```\n\n#### `snmpget public@edgeswitch-098730 system::sysDescr.0`\n```\nsystem::sysDescr.0 = EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\n```\n\n### `github.com/qmsk/snmpbot/cmd/snmpwalk`\n\nTesting `GetNextRequest`\n\n#### `snmpwalk public@edgeswitch-098730 system::sysDescr.0`\n```\n```\n\nThe output is empty, because there is nothing in the `system::sysDescr` tree after `.0`.\n\n#### `snmpwalk public@edgeswitch-098730 system::sysDescr`\n```\nsystem::sysDescr.0 = EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\n```\n\n#### `snmpwalk public@edgeswitch-098730 system`\n```\nsystem::sysDescr.0 = EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\nsystem::sysObjectID.0 = .1.3.6.1.4.1.4413\nsystem::sysUpTime.0 = 2352h54m5s\nsystem::sysContact.0 =\nsystem::sysName.0 = UBNT EdgeSwitch\nsystem::sysLocation.0 =\nsystem::sysServices.0 = 6\nsystem::sysORLastChange.0 = 1m7s\n...\n```\n\n#### `snmpwalk public@edgeswitch-098730 Q-BRIDGE-MIB::dot1qVlanStaticName`\n\n```\nQ-BRIDGE-MIB::dot1qVlanStaticName[1] = default\nQ-BRIDGE-MIB::dot1qVlanStaticName[2] = wan\nQ-BRIDGE-MIB::dot1qVlanStaticName[1002] = iot\nQ-BRIDGE-MIB::dot1qVlanStaticName[1003] = guest\n```\n\nObject indexes are decoded.\n\n### `github.com/qmsk/snmpbot/cmd/snmpobject`\n\nVery similar to `snmpwalk`, but implemented slightly differently - only works for known objects, not arbitrary OIDs.\n\n#### `snmpobject public@edgeswitch-098730 system::sysDescr interfaces::ifDescr`\n\n```\nsystem::sysDescr = EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\ninterfaces::ifDescr[1] = Slot: 0 Port: 1 Gigabit - Level\ninterfaces::ifDescr[2] = Slot: 0 Port: 2 Gigabit - Level\ninterfaces::ifDescr[3] = Slot: 0 Port: 3 Gigabit - Level\ninterfaces::ifDescr[4] = Slot: 0 Port: 4 Gigabit - Level\n```\n\n#### `snmpobject public@edgeswitch-098730 Q-BRIDGE-MIB::dot1qTpFdbPort`\n```\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][44:xx:xx:xx:xx:19] = 24\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][50:xx:xx:xx:xx:b2] = 2\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][70:xx:xx:xx:xx:e4] = 23\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][ac:xx:xx:xx:xx:c9] = 6\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][f0:xx:xx:xx:xx:30] = 65\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][f0:xx:xx:xx:xx:3f] = 24\nQ-BRIDGE-MIB::dot1qTpFdbPort[1][f0:xx:xx:xx:xx:45] = 24\nQ-BRIDGE-MIB::dot1qTpFdbPort[2][00:xx:xx:xx:xx:27] = 24\nQ-BRIDGE-MIB::dot1qTpFdbPort[2][70:xx:xx:xx:xx:e4] = 23\nQ-BRIDGE-MIB::dot1qTpFdbPort[1002][74:xx:xx:xx:xx:c6] = 24\nQ-BRIDGE-MIB::dot1qTpFdbPort[1002][f0:xx:xx:xx:xx:45] = 24\n```\n\n### `github.com/qmsk/snmpbot/cmd/snmpprobe`\n\nUse `GetNextRequest` to probe the presence of subtrees, including entire MIBs or objects within MIBs\n\n#### `snmpprobe public@edgeswitch-098730 BRIDGE-MIB BRIDGE-MIB::dot1dBaseBridgeAddress BRIDGE-MIB::dot1dStpPortTable`\n```\nBRIDGE-MIB = true\nBRIDGE-MIB::dot1dBaseBridgeAddress = true\nBRIDGE-MIB::dot1dStpPortTable = false\n```\n\n### `github.com/qmsk/snmpbot/cmd/snmptable`\n\nUse `GetNextRequest` to walk and decode SMI tables\n\n#### `snmptable public@edgeswitch-098730 interfaces::ifTable`\n```\ninterfaces::ifIndex |       interfaces::ifIndex interfaces::ifDescr                interfaces::ifType interfaces::ifMtu interfaces::ifSpeed interfaces::ifPhysAddress interfaces::ifAdminStatus interfaces::ifOperStatus interfaces::ifLastChange\n---                 |       ---                 ---                                ---                ---               ---                 ---                       ---                       ---                      ---\n1                   |       1                   Slot: 0 Port: 1 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     2257h16m19s\n2                   |       2                   Slot: 0 Port: 2 Gigabit - Level    6                  1518              1000000000          f0:9f:c2:09:87:31         up                        up                       2342h30m20s\n3                   |       3                   Slot: 0 Port: 3 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     525h50m17s\n4                   |       4                   Slot: 0 Port: 4 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n5                   |       5                   Slot: 0 Port: 5 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     1200h48m53s\n6                   |       6                   Slot: 0 Port: 6 Gigabit - Level    6                  1518              100000000           f0:9f:c2:09:87:31         up                        up                       2318h40m45s\n7                   |       7                   Slot: 0 Port: 7 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n8                   |       8                   Slot: 0 Port: 8 Gigabit - Level    6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n9                   |       9                   Slot: 0 Port: 9 Gigabit - Level    6                  1518              10000000            f0:9f:c2:09:87:31         up                        up                       2331h13m45s\n10                  |       10                  Slot: 0 Port: 10 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n11                  |       11                  Slot: 0 Port: 11 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n12                  |       12                  Slot: 0 Port: 12 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n13                  |       13                  Slot: 0 Port: 13 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n14                  |       14                  Slot: 0 Port: 14 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n15                  |       15                  Slot: 0 Port: 15 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n16                  |       16                  Slot: 0 Port: 16 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n17                  |       17                  Slot: 0 Port: 17 Gigabit - Level   6                  1518              100000000           f0:9f:c2:09:87:31         up                        up                       1m17s\n18                  |       18                  Slot: 0 Port: 18 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n19                  |       19                  Slot: 0 Port: 19 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n20                  |       20                  Slot: 0 Port: 20 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n21                  |       21                  Slot: 0 Port: 21 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n22                  |       22                  Slot: 0 Port: 22 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n23                  |       23                  Slot: 0 Port: 23 Gigabit - Level   6                  1518              1000000000          f0:9f:c2:09:87:31         up                        up                       1551h25m59s\n24                  |       24                  Slot: 0 Port: 24 Gigabit - Level   6                  1518              1000000000          f0:9f:c2:09:87:31         up                        up                       382h12m33s\n25                  |       25                  Slot: 0 Port: 25 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n26                  |       26                  Slot: 0 Port: 26 Gigabit - Level   6                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n65                  |       65                   CPU Interface for Slot: 5 Port: 1 1                  1518              0                   f0:9f:c2:09:87:30         up                        up                       0s\n66                  |       66                   Link Aggregate 1                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n67                  |       67                   Link Aggregate 2                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n68                  |       68                   Link Aggregate 3                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n69                  |       69                   Link Aggregate 4                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n70                  |       70                   Link Aggregate 5                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n71                  |       71                   Link Aggregate 6                  1                  1518              0                   f0:9f:c2:09:87:31         up                        down                     0s\n```\n\n#### `snmptable public@edgeswitch-098730 LLDP-MIB::lldpRemTable`\n```\nLLDP-MIB::lldpRemTimeMark LLDP-MIB::lldpRemLocalPortNum LLDP-MIB::lldpRemIndex |       LLDP-MIB::lldpRemChassisIdSubtype LLDP-MIB::lldpRemChassisId LLDP-MIB::lldpRemPortIdSubtype LLDP-MIB::lldpRemPortId LLDP-MIB::lldpRemPortDesc LLDP-MIB::lldpRemSysName LLDP-MIB::lldpRemSysDesc\n---                       ---                           ---                    |       ---                               ---                        ---                            ---                     ---                       ---                      ---\n21h59m32.24s              24                            1                      |       macAddress                        f0 9f c2 64 6d 45          macAddress                     f0 9f c2 64 6d 45       switch0                   erx-home                 UBNT EdgeRouter X SFP 6-Port running on v1.9.1.1.4977602.170427.0113\n21h59m32.24s              24                            2                      |       macAddress                        f0 9f c2 64 6d 45          macAddress                     f0 9f c2 64 6d 3f       eth0                      erx-home                 UBNT EdgeRouter X SFP 6-Port running on v1.9.1.1.4977602.170427.0113\n```\n\n## `github.com/qmsk/snmpbot/cmd/snmpbot`\n\nThis is the command using the [`server`](#server) to provide the HTTP REST API.\n\n### Usage\n\n```\n$ $GOPATH/bin/snmpbot -help\n  -config string\n        Load TOML config\n  -debug\n        Log debug\n  -http-listen string\n        HTTP server listen: [HOST]:PORT (default \":8286\")\n  -http-static string\n        HTTP sever /static path: PATH\n  -quiet\n        Do not log warnings\n  -snmp-community string\n        Default SNMP community (default \"public\")\n  -snmp-maxvars uint\n        Maximum request VarBinds (default 10)\n  -snmp-mibs string\n        Load MIBs from path (default $SNMPBOT_MIBS)\n  -snmp-retry int\n        SNMP request retry\n  -snmp-timeout duration\n        SNMP request timeout (default 1s)\n  -snmp-udp-size uint\n        Maximum UDP recv size (default 1500)\n  -verbose\n        Log info\n```\n\nExamples:\n\n    $GOPATH/bin/snmpbot -config config.toml -http-listen :8286 -snmp-udp-size 9000 -snmp-maxvars 50\n\n## Config\n\nLoaded using `snmpbot -config`\n\n```toml\n[hosts.edgeswitch-098730]\nSNMP = \"public@edgeswitch-098730\"\nLocation = \"test\"\n\n[hosts.erx-home]\nSNMP = \"secret@erx-home\"\nLocation = \"home\"\n```\n\nThe configuration file is optional, dynamic hosts can be queried without any config, using `GET /hosts/...?snmp=community@host` (also `-snmp-community=...`).\n\n***NOTE***: The mass-querying `/objects/...` and `/tables/...` endpoints only query configured objects.\n\n## API\n\nSee the [`api`](https://godoc.org/github.com/qmsk/snmpbot/api) package docs for the exact details\n\n#### `GET /api/`\n```json\n{\n   \"Hosts\" : [\n      {\n         \"ID\" : \"edgeswitch-098730\",\n         \"SNMP\" : \"public@172.28.2.2:161\"\n      },\n      {\n         \"ID\" : \"erx-home\",\n         \"SNMP\" : \"secret@172.28.0.1:161\"\n      }\n   ],\n   \"MIBs\" : [\n      {\n         \"ID\" : \"IF-MIB\"\n      },\n      ...\n   ],\n   \"Tables\" : [\n      {\n         \"ID\" : \"Q-BRIDGE-MIB::dot1qVlanStaticTable\",\n         \"ObjectKeys\" : [\n            \"Q-BRIDGE-MIB::dot1qVlanStaticName\",\n            \"Q-BRIDGE-MIB::dot1qVlanStaticEgressPorts\",\n            \"Q-BRIDGE-MIB::dot1qVlanForbiddenEgressPorts\",\n            \"Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts\",\n            \"Q-BRIDGE-MIB::dot1qVlanStaticRowStatus\"\n         ],\n         \"IndexKeys\" : [\n            \"Q-BRIDGE-MIB::dot1qVlanIndex\"\n         ]\n      },\n      ...\n    ],\n   \"Objects\" : [\n      {\n         \"IndexKeys\" : [\n            \"interfaces::ifIndex\"\n         ],\n         \"ID\" : \"interfaces::ifDescr\"\n      },\n      {\n         \"ID\" : \"system::sysContact\"\n      },\n      ...\n   ]\n}\n```\n\n#### `GET /api/hosts/`\n\nQuery configured hosts.\n\n```json\n[\n   {\n      \"ID\" : \"edgeswitch-098730\",\n      \"SNMP\" : \"public@172.28.2.2:161\"\n   },\n   ...\n]\n```\n\n#### `POST /api/hosts/`\n\nConfigure a new host. The new host will show up in `/hosts/` and can be queried via the `/objects/...` and `/tables/...` endpoints.\n\n```json\n{\n   \"ID\" : \"edgeswitch-098730\",\n   \"SNMP\" : \"public@172.28.2.2:161\",\n   \"Online\": true,\n   ...\n}\n```\n\nResponse is as for `GET`.\n\nReturns HTTP 409 Conflict if the host is already configured. Use `PUT /v1/hosts/:id` instead.\n\n##### Request `Content-Type: application/json`\n```json\n{\n  \"ID\": \"test\",\n  \"SNMP\": \"community@test.example.com\",\n  \"Location\": \"testing\"\n}\n```\n\n##### Request `Content-Type: application/x-www-form-urlencoded`\n```\nid=test\u0026snmp=community@test.example.com\u0026location=testing\n```\n\n#### `GET /api/hosts/:id`\n\nQuery information about a specific configured host.\n\n```json\n{\n   \"ID\" : \"edgeswitch-098730\",\n   \"SNMP\" : \"public@172.28.2.2:161\",\n   \"Location\": \"testing\",\n   \"Online\": true\n}\n```\n\n***Note***: Does not return anything useful for a dynamic host.\n\n#### `PUT /api/hosts/:id`\n\nAdd or replace a configured host.\n\n```json\n{\n   \"ID\" : \"edgeswitch-098730\",\n   \"SNMP\" : \"public@172.28.2.2:161\",\n   \"Online\": true,\n   ...\n}\n```\n\nResponse is as for `GET`.\n\n##### Request `Content-Type: application/json`\n```json\n{\n  \"SNMP\": \"community@test.example.com\",\n  \"Location\": \"testing\"\n}\n```\n\n##### Request `Content-Type: application/x-www-form-urlencoded`\n```\nsnmp=community@test.example.com\u0026location=testing\n```\n\n#### `DELETE /api/hosts/:id`\n\nRemove a configured host.\n\nReturns HTTP 204 No Content.\n\n#### `GET /api/hosts/test/...?snmp=community@test.example.com`\n\nQuery a dynamic host using an arbitrary `?snmp=[\u003ccommunity\u003e \"@\"] \u003chost\u003e` target.\n\nThe `[\u003ccommunity\u003e \"@\"]` is optional, and defaults to the `-config` =\u003e `[ClientOptions] Community=` or `-snmp-community`.\n\n```json\n{\n   \"MIBs\" : [\n      {\n         \"ID\" : \"SNMPv2-MIB\"\n      },\n      ...\n   ],\n   \"ID\" : \"test\",\n   \"SNMP\" : \"community@192.0.2.1:161\"\n}\n```\n\nThe given SNMP host will be probed for supported MIBs.\n\n***NOTE***: The `?snmp=` query parameter works for all host API paths, but is ignored for configured hosts.\n\n#### `GET /api/hosts/:host/`\n\nQuery host with information about tables/objects for probed MIBs.\n\n```json\n{\n   \"ID\" : \"edgeswitch-098730\",\n   \"Objects\" : [\n      {\n         \"ID\" : \"system::sysObjectID\"\n      },\n      ...\n   ],\n   \"Tables\" : [\n      {\n         \"IndexKeys\" : [\n            \"BRIDGE-MIB::dot1dStpPort\"\n         ],\n         \"ObjectKeys\" : [\n            \"BRIDGE-MIB::dot1dStpPort\",\n            \"BRIDGE-MIB::dot1dStpPortPriority\",\n            \"BRIDGE-MIB::dot1dStpPortState\",\n            \"BRIDGE-MIB::dot1dStpPortEnable\",\n            \"BRIDGE-MIB::dot1dStpPortPathCost\",\n            \"BRIDGE-MIB::dot1dStpPortDesignatedRoot\",\n            \"BRIDGE-MIB::dot1dStpPortDesignatedCost\",\n            \"BRIDGE-MIB::dot1dStpPortDesignatedBridge\",\n            \"BRIDGE-MIB::dot1dStpPortDesignatedPort\",\n            \"BRIDGE-MIB::dot1dStpPortForwardTransitions\"\n         ],\n         \"ID\" : \"BRIDGE-MIB::dot1dStpPortTable\"\n      },\n      ...\n   ],\n   \"MIBs\" : [\n      {\n         \"ID\" : \"SNMPv2-MIB\"\n      },\n      ...\n   ],\n   \"SNMP\" : \"public@172.28.2.2:161\"\n}\n```\n\n#### `GET /api/hosts/:host/tables/LLDP-MIB::lldpRemTable`\n\nQuery a specific table for a specific host (dynamic or configured).\n\n```json\n{\n   \"ObjectKeys\" : [\n      ...\n   ],\n   \"IndexKeys\" : [\n      ...\n   ],\n   \"Entries\" : [\n      ...\n   ],\n   \"ID\" : \"LLDP-MIB::lldpRemTable\"\n}\n```\n\n***Note***: The queried table does not necessarily need to belong to a probed MIB.\n\n#### `GET /api/hosts/:host/tables/?table=LLDP-MIB::*`\n\nQuery multiple tables from probed mibs for a specific host (dynamic or configured).\n\nUse multiple `?table=A\u0026table=B` filters to query different tables.\n\nUse (multiple) `?host=test-*` query parameters to limit queried hosts.\n\n```json\n[\n   {\n      \"ObjectKeys\" : [\n         \"LLDP-MIB::lldpLocPortIdSubtype\",\n         \"LLDP-MIB::lldpLocPortId\",\n         \"LLDP-MIB::lldpLocPortDesc\"\n      ],\n      \"Entries\" : [\n         {\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Index\" : {\n               \"LLDP-MIB::lldpLocPortNum\" : 1\n            },\n            \"Objects\" : {\n               \"LLDP-MIB::lldpLocPortIdSubtype\" : \"macAddress\",\n               \"LLDP-MIB::lldpLocPortId\" : \"f0 9f c2 09 87 31\",\n               \"LLDP-MIB::lldpLocPortDesc\" : \"\"\n            }\n         },\n         ...\n      ],\n      \"ID\" : \"LLDP-MIB::lldpLocPortTable\",\n      \"IndexKeys\" : [\n         \"LLDP-MIB::lldpLocPortNum\"\n      ]\n   },\n   {\n      \"ObjectKeys\" : [\n         \"LLDP-MIB::lldpRemChassisIdSubtype\",\n         \"LLDP-MIB::lldpRemChassisId\",\n         \"LLDP-MIB::lldpRemPortIdSubtype\",\n         \"LLDP-MIB::lldpRemPortId\",\n         \"LLDP-MIB::lldpRemPortDesc\",\n         \"LLDP-MIB::lldpRemSysName\",\n         \"LLDP-MIB::lldpRemSysDesc\"\n      ],\n      \"Entries\" : [\n         {\n            \"Index\" : {\n               \"LLDP-MIB::lldpRemTimeMark\" : 79172.24,\n               \"LLDP-MIB::lldpRemLocalPortNum\" : 24,\n               \"LLDP-MIB::lldpRemIndex\" : 1\n            },\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Objects\" : {\n               \"LLDP-MIB::lldpRemChassisIdSubtype\" : \"macAddress\",\n               \"LLDP-MIB::lldpRemSysDesc\" : \"UBNT EdgeRouter X SFP 6-Port running on v1.9.1.1.4977602.170427.0113\",\n               \"LLDP-MIB::lldpRemPortDesc\" : \"switch0\",\n               \"LLDP-MIB::lldpRemSysName\" : \"erx-home\",\n               \"LLDP-MIB::lldpRemPortIdSubtype\" : \"macAddress\",\n               \"LLDP-MIB::lldpRemChassisId\" : \"f0 9f c2 64 6d 45\",\n               \"LLDP-MIB::lldpRemPortId\" : \"f0 9f c2 64 6d 45\"\n            }\n         },\n         ...\n      ],\n      \"ID\" : \"LLDP-MIB::lldpRemTable\",\n      \"IndexKeys\" : [\n         \"LLDP-MIB::lldpRemTimeMark\",\n         \"LLDP-MIB::lldpRemLocalPortNum\",\n         \"LLDP-MIB::lldpRemIndex\"\n      ]\n   }\n]\n```\n\n***Note***: The queried tables must belong to a probed MIB.\n\n#### `GET /api/hosts/:host/objects/SNMPv2-MIB::sysDescr`\n\nQuery a specific object for a specific host (configured or dynamic).\n\n```json\n{\n   \"Instances\" : [\n      {\n         \"Value\" : \"EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\",\n         \"HostID\" : \"edgeswitch-098730\"\n      }\n   ],\n   \"ID\" : \"SNMPv2-MIB::sysDescr\"\n}\n```\n\n***Note***: The queried object does not necessarily need to belong to a probed MIB.\n\n***Note***: Objects belonging to table entries will return multiple instances with different `Index` values.\n\n#### `GET /api/hosts/:host/objects/?object=SNMPv2-MIB::sys*\u0026object=IF-MIB::ifDescr`\n\nQuery matching objects from probed MIBs for a specific host (dynamic or configured).\n\nUse multiple `?object=A\u0026object=B` filters to query different objects. Use `?object=MIB::foo*` filters to query multiple matching objects.\n\nUse `?table=IF-MIB::ifTable` to query for objects belonging to matching tables. These can also be combined with `?object=` filters, e.g. `GET /api/hosts/public@localhost/objects/?table=IF-MIB::ifXTable\u0026object=*HC*Pkts` to return 64-bit per-interface packet counters as separate objects.\n\n```json\n   {\n      \"IndexKeys\" : [\n         \"interfaces::ifIndex\"\n      ],\n      \"ID\" : \"interfaces::ifDescr\",\n      \"Instances\" : [\n         {\n            \"Value\" : \"Slot: 0 Port: 1 Gigabit - Level\",\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Index\" : {\n               \"interfaces::ifIndex\" : 1\n            }\n         },\n         {\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Value\" : \"Slot: 0 Port: 2 Gigabit - Level\",\n            \"Index\" : {\n               \"interfaces::ifIndex\" : 2\n            }\n         },\n         ...\n      ]\n   },\n   {\n      \"ID\" : \"system::sysDescr\",\n      \"Instances\" : [\n         {\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Value\" : \"EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\"\n         }\n      ]\n   }\n]\n```\n\n***Note***: The queried object must belong to a probed MIB.\n\n#### `GET /api/tables/IF-MIB::ifTable?host=test-*`\n\nQuery specific table across all hosts.\n\nUse (multiple) `?host=test-*` query parameters to limit queried hosts.\n\n```json\n{\n   \"ID\" : \"IF-MIB::ifTable\",\n   \"IndexKeys\" : [\n      \"IF-MIB::ifIndex\"\n   ],\n   \"ObjectKeys\" : [\n      \"IF-MIB::ifIndex\",\n      \"IF-MIB::ifDescr\",\n      \"IF-MIB::ifType\",\n      \"IF-MIB::ifMtu\",\n      \"IF-MIB::ifSpeed\",\n      \"IF-MIB::ifPhysAddress\",\n      \"IF-MIB::ifAdminStatus\",\n      \"IF-MIB::ifOperStatus\",\n      \"IF-MIB::ifLastChange\"\n   ],\n   \"Entries\" : [\n      {\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 1\n         },\n         \"Objects\" : {\n            \"IF-MIB::ifPhysAddress\" : \"\",\n            \"IF-MIB::ifLastChange\" : 0,\n            \"IF-MIB::ifMtu\" : 65536,\n            \"IF-MIB::ifType\" : 24,\n            \"IF-MIB::ifSpeed\" : 10000000,\n            \"IF-MIB::ifIndex\" : 1,\n            \"IF-MIB::ifAdminStatus\" : \"up\",\n            \"IF-MIB::ifDescr\" : \"lo\",\n            \"IF-MIB::ifOperStatus\" : \"up\"\n         },\n         \"HostID\" : \"erx-home\"\n      },\n      ...\n      {\n         \"HostID\" : \"edgeswitch-098730\",\n         \"Objects\" : {\n            \"IF-MIB::ifMtu\" : 1518,\n            \"IF-MIB::ifLastChange\" : 8433020,\n            \"IF-MIB::ifPhysAddress\" : \"f0:9f:c2:09:87:31\",\n            \"IF-MIB::ifSpeed\" : 1000000000,\n            \"IF-MIB::ifType\" : 6,\n            \"IF-MIB::ifDescr\" : \"Slot: 0 Port: 2 Gigabit - Level\",\n            \"IF-MIB::ifAdminStatus\" : \"up\",\n            \"IF-MIB::ifIndex\" : 2,\n            \"IF-MIB::ifOperStatus\" : \"up\"\n         },\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 2\n         }\n      },\n   ]\n}\n```\n\n***Note***: Only configured hosts are queried.\n\n***Note***: The table contains entries from all hosts for that SNMP table: Different `Entries` in the same table can have different `HostID` values.\n\n#### `GET /api/tables/?table=LLDP-MIB::lldpRemTable\u0026table=Q-BRIDGE-MIB::dot1qTpFdbTable`\n\nQuery multiple tables across all hosts.\n\nUse multiple `?table=A\u0026table=B` filters to query different tables.\n\nUse (multiple) `?host=test-*` query parameters to limit queried hosts.\n\n\n```json\n[\n   {\n      \"ID\" : \"LLDP-MIB::lldpRemTable\",\n      ...\n   },\n   {\n      \"ID\" : \"Q-BRIDGE-MIB::dot1qTpFdbTable\",\n      ...\n   }\n]\n```\n\n***Note***: Only configured hosts are queried.\n\n***Note***: Each table contains entries from all hosts for that SNMP table: Different `Entries` in the same table can have different `HostID` values.\n\n#### `GET /api/objects/IF-MIB::ifDescr`\n\nQuery specific object across all hosts. Use `?host=test-*` to filter queried hosts.\n\n```json\n{\n   \"IndexKeys\" : [\n      \"IF-MIB::ifIndex\"\n   ],\n   \"ID\" : \"IF-MIB::ifDescr\",\n   \"Instances\" : [\n      {\n         \"HostID\" : \"erx-home\",\n         \"Value\" : \"lo\",\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 1\n         }\n      },\n      {\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 1\n         },\n         \"Value\" : \"Slot: 0 Port: 1 Gigabit - Level\",\n         \"HostID\" : \"edgeswitch-098730\"\n      },\n      ...\n   ]\n}\n```\n\n***Note***: Only configured hosts are queried.\n\n#### `GET /api/objects/IF-MIB::ifDescr?host=edgeswitch-*`\n\nQuery specific object across all hosts. Use `?host=...` to filter queried hosts.\n\n```json\n{\n   \"Instances\" : [\n      {\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 1\n         },\n         \"HostID\" : \"edgeswitch-098730\",\n         \"Value\" : \"Slot: 0 Port: 1 Gigabit - Level\"\n      },\n      {\n         \"HostID\" : \"edgeswitch-098730\",\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 2\n         },\n         \"Value\" : \"Slot: 0 Port: 2 Gigabit - Level\"\n      },\n      {\n         \"Value\" : \"Slot: 0 Port: 3 Gigabit - Level\",\n         \"HostID\" : \"edgeswitch-098730\",\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 3\n         }\n      },\n      ...\n      {\n         \"HostID\" : \"edgeswitch-098730\",\n         \"Index\" : {\n            \"IF-MIB::ifIndex\" : 71\n         },\n         \"Value\" : \" Link Aggregate 6\"\n      }\n   ],\n   \"ID\" : \"IF-MIB::ifDescr\",\n   \"IndexKeys\" : [\n      \"IF-MIB::ifIndex\"\n   ]\n}\n```\n\n***Note***: Only configured hosts are queried.\n\n#### `GET /api/objects/?object=SNMPv2-MIB::*`\n\nQuery multiple matching objects across all hosts.\n\nUse multiple `?object=A\u0026object=B` filters to query different objects.\n\nUse (multiple) `?host=test-*` query parameters to limit queried hosts.\n\n```json\n[\n   {\n      \"ID\" : \"SNMPv2-MIB::sysLocation\",\n      \"Instances\" : [\n         {\n            \"Value\" : \"home.qmsk.net\",\n            \"HostID\" : \"erx-home\"\n         },\n         {\n            \"Value\" : \"\",\n            \"HostID\" : \"edgeswitch-098730\"\n         }\n      ]\n   },\n   {\n      \"Instances\" : [\n         {\n            \"HostID\" : \"erx-home\",\n            \"Value\" : \"EdgeOS v1.9.1.1.4977602.170427.0113\"\n         },\n         {\n            \"HostID\" : \"edgeswitch-098730\",\n            \"Value\" : \"EdgeSwitch 24-Port Lite, 1.7.0.4922887, Linux 3.6.5-f4a26ed5, 0.0.0.0000000\"\n         }\n      ],\n      \"ID\" : \"SNMPv2-MIB::sysDescr\"\n   },\n   ...\n]\n```\n\n***Note***: Only configured hosts are queried.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqmsk%2Fsnmpbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqmsk%2Fsnmpbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqmsk%2Fsnmpbot/lists"}