Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4ed32f8314
|
|||
4222e19573
|
|||
11e63155bc
|
|||
353a3780c6
|
@ -12,24 +12,14 @@
|
|||||||
"community": "public",
|
"community": "public",
|
||||||
"oidTopics": [
|
"oidTopics": [
|
||||||
{
|
{
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.4",
|
"oid": ".1.3.6.1.2.1.2.2.1.10.5",
|
||||||
"label": "wan-in",
|
"label": "wan-in",
|
||||||
"diff": "true"
|
"diff": "true"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.4",
|
"oid": ".1.3.6.1.2.1.2.2.1.16.5",
|
||||||
"label": "wan-out",
|
"label": "wan-out",
|
||||||
"diff": "true"
|
"diff": "true"
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.2",
|
|
||||||
"label": "lan-in",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.2",
|
|
||||||
"label": "lan-out",
|
|
||||||
"diff": "true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ metadata:
|
|||||||
namespace: homea
|
namespace: homea
|
||||||
labels:
|
labels:
|
||||||
app: snmp-nmqtt
|
app: snmp-nmqtt
|
||||||
|
annotations:
|
||||||
|
secret.reloader.stakater.com/reload: "snmp-mqtt-conf"
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
|
4
deployment/pushconfig.sh
Executable file
4
deployment/pushconfig.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
kubectl create configmap snmp-mqtt-conf --from-literal=SNMP_MQTT_CONF="`cat config.json`" --dry-run=client -o yaml --save-config | kubectl apply -f - -n homea
|
@ -18,7 +18,6 @@ type variable_t struct {
|
|||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Variable string `json:"variable"`
|
Variable string `json:"variable"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
DiffValue string `json:"diffValue"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type message_t struct {
|
type message_t struct {
|
||||||
@ -114,15 +113,15 @@ func Start() {
|
|||||||
convertedValue = fmt.Sprintf("%d", gosnmp.ToBigInt(variable.Value))
|
convertedValue = fmt.Sprintf("%d", gosnmp.ToBigInt(variable.Value))
|
||||||
}
|
}
|
||||||
|
|
||||||
diffValue := "0"
|
|
||||||
if oidTopic.Diff == "true" {
|
if oidTopic.Diff == "true" {
|
||||||
log.Println("Calculate difference to last value")
|
log.Println("Calculate difference to last value")
|
||||||
key := endpoint.Endpoint + ":" + oidTopic.OID
|
key := endpoint.Endpoint + ":" + oidTopic.OID
|
||||||
diff, err := calculateDifference(key, convertedValue)
|
diff, err := calculateDifference(key, convertedValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error when building difference: %v", err)
|
log.Printf("Error when building difference: %v", err)
|
||||||
|
convertedValue = "-1"
|
||||||
} else {
|
} else {
|
||||||
diffValue = diff
|
convertedValue = diff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +130,6 @@ func Start() {
|
|||||||
Label: oidTopic.Label,
|
Label: oidTopic.Label,
|
||||||
Variable: oidTopic.OID,
|
Variable: oidTopic.OID,
|
||||||
Value: convertedValue,
|
Value: convertedValue,
|
||||||
DiffValue: diffValue,
|
|
||||||
}
|
}
|
||||||
message.Variables[oidTopic.Label] = v
|
message.Variables[oidTopic.Label] = v
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user