rwagoner / snmp-mqtt

A simple go app that reads snmp values and publishes it to the specified MQTT endpoint at the specified interval.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snmp-mqtt

A simple go app that reads SNMP values and publishes it to the specified MQTT endpoint at the specified interval.

Docker usage

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

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"
        }
      ]
    }
 ]
}

About

A simple go app that reads snmp values and publishes it to the specified MQTT endpoint at the specified interval.

License:MIT License


Languages

Language:Go 73.3%Language:Makefile 18.1%Language:Shell 6.6%Language:Dockerfile 2.0%