A simple go app that reads SNMP values and publishes it to the specified MQTT endpoint at the specified interval.
docker build --tag="snmp-mqtt" .
docker run -d --name="snmp-mqtt" \
-v endpoints.json:/app/endpoints.json \
-v /etc/localtime:/etc/localtime:ro \
-e MQTT_USERNAME=username \
-e MQTT_PASSWORD=password \
--net=host --restart always snmp-mqtt
Usage: snmp-mqtt [options]
Options:
-endpoints_map="./endpoints.json" SNMP endpoints mapping file
-mqtt_clientid="snmp" MQTT client identifier
-mqtt_password="" MQTT authentication password
-mqtt_port=1883 MQTT server port
-mqtt_server="localhost" MQTT server hostname or IP address
-mqtt_username="" MQTT authentication username
-snmp_interval=5 SNMP polling interval (seconds)
An example endpoints.json file:
{
"snmpEndpoints": [
{
"endpoint": "172.18.0.1",
"community": "public",
"oidTopics": [
{
"oid": ".1.3.6.1.2.1.31.1.1.1.6.4",
"topic": "router/bytesIn"
},
{
"oid": ".1.3.6.1.2.1.31.1.1.1.10.4",
"topic": "router/bytesOut"
}
]
}
]
}