2 Commits
0.0.2 ... 0.0.3

Author SHA1 Message Date
553648e10d value shall be string
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/tag/woodpecker Pipeline failed
2025-02-10 14:18:19 +01:00
64dba890dd adjust message and variable with snmp-mqtt
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-10 13:54:08 +01:00

View File

@ -3,6 +3,7 @@ package tsmq
import ( import (
"log" "log"
"time" "time"
"strconv"
"encoding/json" "encoding/json"
"tsm/config" "tsm/config"
@ -12,14 +13,15 @@ import (
) )
type variable_t struct { type variable_t struct {
Name string `json:"variable"` Label string `json:"label"`
Value float64 `json:"value"` Variable string `json:"variable"`
Value string `json:"value"`
Unit string `json:"unit"` Unit string `json:"unit"`
Status string `json:"status"` Status string `json:"status"`
} }
type message_t struct { type message_t struct {
Server string `json:"server"` Device string `json:"device"`
Label string `json:"label"` Label string `json:"label"`
Variables map[string]variable_t `json:"variables"` Variables map[string]variable_t `json:"variables"`
} }
@ -32,7 +34,7 @@ func Start() {
log.Println("Polling server " + server.Name) log.Println("Polling server " + server.Name)
message := message_t { message := message_t {
Server: server.Name, Device: server.Name,
Label: server.Label, Label: server.Label,
Variables: make(map[string]variable_t), Variables: make(map[string]variable_t),
} }
@ -48,8 +50,9 @@ func Start() {
} }
v := variable_t { v := variable_t {
Name: label, Label: label,
Value: value, Variable: "",
Value: strconv.FormatFloat(value, 'f', 4, 64)
Unit: "ms", Unit: "ms",
Status: status, Status: status,
} }