From 44671ac3cd0e1a402a74fd97098685efc9fbae85 Mon Sep 17 00:00:00 2001 From: Daniel Chote Date: Tue, 15 Oct 2019 12:43:32 -0400 Subject: [PATCH] remove topic prefix --- config/config.go | 3 --- endpoints.json | 36 ++++++++++++++++++++++-------------- snmp-mqtt.go | 4 +--- snmp/snmp.go | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/config/config.go b/config/config.go index f58c2a6..fb5961f 100644 --- a/config/config.go +++ b/config/config.go @@ -37,9 +37,6 @@ var ( // ClientID is how the name of the client ClientID string - // TopicPrefix is just that, a prefix for the presented data keys - TopicPrefix string - // Interval is the poll interval in seconds Interval int ) diff --git a/endpoints.json b/endpoints.json index 3375f07..bfdebc0 100644 --- a/endpoints.json +++ b/endpoints.json @@ -6,11 +6,19 @@ "oidTopics": [ { "oid": ".1.3.6.1.2.1.31.1.1.1.6.4", - "topic": "router/bytesIn" + "topic": "network/router/interfaces/wan/bytesIn" }, { "oid": ".1.3.6.1.2.1.31.1.1.1.10.4", - "topic": "router/bytesOut" + "topic": "network/router/interfaces/wan/bytesOut" + }, + { + "oid": ".1.3.6.1.2.1.31.1.1.1.6.2", + "topic": "network/router/interfaces/lan/bytesIn" + }, + { + "oid": ".1.3.6.1.2.1.31.1.1.1.10.2", + "topic": "network/router/interfaces/lan/bytesOut" } ] }, @@ -20,11 +28,11 @@ "oidTopics": [ { "oid": ".1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1", - "topic": "rackPDU/totalLoad" + "topic": "power/rackPDU/outputCurrentX10" }, { "oid": ".1.3.6.1.4.1.318.1.1.12.1.16.0", - "topic": "rackPDU/watts" + "topic": "power/rackPDU/watts" } ] }, @@ -34,23 +42,23 @@ "oidTopics": [ { "oid": ".1.3.6.1.4.1.318.1.1.1.3.2.1.0", - "topic": "rackUPS/lineVoltage" + "topic": "power/rackUPS/lineVoltage" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.4.2.4.0", - "topic": "rackUPS/outputCurrent" + "topic": "power/rackUPS/outputCurrent" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.1.0", - "topic": "rackUPS/batteryCapacity" + "topic": "power/rackUPS/batteryCapacity" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.3.0", - "topic": "rackUPS/batteryRuntime" + "topic": "power/rackUPS/batteryRuntime" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.2.0", - "topic": "rackUPS/batteryTemperature" + "topic": "power/rackUPS/batteryTemperature" } ] }, @@ -60,23 +68,23 @@ "oidTopics": [ { "oid": ".1.3.6.1.4.1.318.1.1.1.3.2.1.0", - "topic": "printerUPS/lineVoltage" + "topic": "power/printerUPS/lineVoltage" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.4.2.4.0", - "topic": "printerUPS/outputCurrent" + "topic": "power/printerUPS/outputCurrent" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.1.0", - "topic": "printerUPS/batteryCapacity" + "topic": "power/printerUPS/batteryCapacity" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.3.0", - "topic": "printerUPS/batteryRuntime" + "topic": "power/printerUPS/batteryRuntime" }, { "oid": ".1.3.6.1.4.1.318.1.1.1.2.2.2.0", - "topic": "printerUPS/batteryTemperature" + "topic": "power/printerUPS/batteryTemperature" } ] } diff --git a/snmp-mqtt.go b/snmp-mqtt.go index f874f79..e4d74bc 100644 --- a/snmp-mqtt.go +++ b/snmp-mqtt.go @@ -25,7 +25,6 @@ Options: --endpoints_map= SNMP Endpoints Map File [default: ./endpoints.json] --server= MQTT server host/IP [default: 127.0.0.1] --port= MQTT server port [default: 1883] - --topic= MQTT topic prefix [default: snmp] --clientid= MQTT client identifier [default: snmp] --interval= Poll interval (seconds) [default: 5] -h, --help Show this screen. @@ -42,11 +41,10 @@ Options: config.Server, _ = args.String("--server") config.Port, _ = args.Int("--port") - config.TopicPrefix, _ = args.String("--topic") config.ClientID, _ = args.String("--clientid") config.Interval, _ = args.Int("--interval") - log.Printf("server: %s, port: %d, topic prefix: %s, client identifier: %s, poll interval: %d", config.Server, config.Port, config.TopicPrefix, config.ClientID, config.Interval) + log.Printf("server: %s, port: %d, client identifier: %s, poll interval: %d", config.Server, config.Port, config.ClientID, config.Interval) } // sigChannelListen basic handlers for inbound signals diff --git a/snmp/snmp.go b/snmp/snmp.go index d8dbc9f..fc446c7 100644 --- a/snmp/snmp.go +++ b/snmp/snmp.go @@ -73,7 +73,7 @@ func Init() { } log.Printf("%s = %s", oidTopic.Topic, convertedValue) - token := client.Publish(config.TopicPrefix+"/"+oidTopic.Topic, 0, false, convertedValue) + token := client.Publish(oidTopic.Topic, 0, false, convertedValue) token.Wait() if token.Error() != nil {