restful-snmp provides a handy way to query SNMP via a HTTP.
To install:
$ go get github.com/unprofession-al/restful-snmpTo run:
$ RS_LISTEN=0.0.0.0 RS_PORT=3030 /path/to/restful-snmpTo issue a SNMP GET, fetch the API like so:
$ curl -X GET http://server:port/[device_to_query]/?oid=[oid_to_fetch]Where [device_to_query] is an IP address or an FQDN of a device (eg. a switch, router etc.) that runs an SNMP agent and [oid_to_fetch] is the OID that should be queried.
You can specify multiple OID by chaining additionnal &oid=[oid_to_fetch] parameters.
The response in case of a successful SNMP GET query comes as a HTTP 200 containing JSON of the following schema:
[
{
"Name": ".1.3.6.1.4.1.6.3.16.1.1.1.1.4.49.51.51.52",
"Type": 4,
"Value": "1334"
}
]If you only care about the value just append value_only=true to the value string.
The community that is used by default is public. To specify an custom community specify the name via query string:
$ curl -X GET http://server:port/[device_to_query]/[oid_to_fetch]?community=[community_name]