10 Commits
0.0.1 ... 0.0.8

Author SHA1 Message Date
aa7498d93e change cluster switch
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-05-06 19:00:13 +02:00
b5b2e3ac0d nothing
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-29 22:35:52 +01:00
ad9b3625e1 fix anno
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-26 18:28:12 +01:00
56aec29c76 add cluster switch to config
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-26 14:39:08 +01:00
85124d028d use 64bit counter
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-25 16:10:53 +01:00
4ed32f8314 fix struct
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-25 15:24:56 +01:00
4222e19573 skip diff value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-25 15:22:29 +01:00
11e63155bc diff default value
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-25 15:18:29 +01:00
353a3780c6 anno
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-25 15:00:40 +01:00
f407198c5b fix config
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-25 14:35:41 +01:00
5 changed files with 33 additions and 16 deletions

View File

@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -2,9 +2,9 @@
"mqtt": {
"broker": "mqtt://emqx01-anonymous-cluster-internal.broker.svc.cluster.local:1883",
"tlsEnable": "false",
"topicPre": "snmp"
"topic": "snmp"
},
"interval": 60,
"interval": 10,
"snmpEndpoints": [
{
"endpoint": "172.16.3.1",
@ -12,20 +12,31 @@
"community": "public",
"oidTopics": [
{
"oid": ".1.3.6.1.2.1.31.1.1.1.6.4",
"label": "wan-in"
"oid": ".1.3.6.1.2.1.31.1.1.1.6.5",
"label": "wan-in",
"diff": "true"
},
{
"oid": ".1.3.6.1.2.1.31.1.1.1.10.4",
"label": "wan-out"
"oid": ".1.3.6.1.2.1.31.1.1.1.10.5",
"label": "wan-out",
"diff": "true"
}
]
},
{
"endpoint": "172.16.3.3",
"label": "switch-cluster",
"community": "public",
"oidTopics": [
{
"oid": ".1.3.6.1.2.1.31.1.1.1.6.1",
"label": "uplink-in",
"diff": "true"
},
{
"oid": ".1.3.6.1.2.1.31.1.1.1.6.2",
"label": "lan-in"
},
{
"oid": ".1.3.6.1.2.1.31.1.1.1.10.2",
"label": "lan-out"
"oid": ".1.3.6.1.2.1.31.1.1.1.10.1",
"label": "uplink-out",
"diff": "true"
}
]
}

View File

@ -5,6 +5,8 @@ metadata:
namespace: homea
labels:
app: snmp-nmqtt
annotations:
secret.reloader.stakater.com/reload: snmp-mqtt-conf
spec:
replicas: 1
selector:

4
deployment/pushconfig.sh Executable file
View 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

View File

@ -18,7 +18,6 @@ type variable_t struct {
Label string `json:"label"`
Variable string `json:"variable"`
Value string `json:"value"`
DiffValue string `json:"diffValue"`
}
type message_t struct {
@ -114,15 +113,15 @@ func Start() {
convertedValue = fmt.Sprintf("%d", gosnmp.ToBigInt(variable.Value))
}
diffValue := "0"
if oidTopic.Diff == "true" {
log.Println("Calculate difference to last value")
key := endpoint.Endpoint + ":" + oidTopic.OID
diff, err := calculateDifference(key, convertedValue)
if err != nil {
log.Printf("Error when building difference: %v", err)
convertedValue = "-1"
} else {
diffValue = diff
convertedValue = diff
}
}
@ -131,7 +130,6 @@ func Start() {
Label: oidTopic.Label,
Variable: oidTopic.OID,
Value: convertedValue,
DiffValue: diffValue,
}
message.Variables[oidTopic.Label] = v