stratum
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Wolfgang Hottgenroth 2025-02-11 10:06:36 +01:00
parent 101072eabc
commit 38d35c1e79

View File

@ -39,24 +39,31 @@ func Start() {
Variables: make(map[string]variable_t),
}
label := "rootdisp"
status := "Ok"
value := 0.0
rootdisp := 0.0
stratum := 0
resp, err := ntp.Query(server.Name)
if err != nil {
status = "Error"
} else {
value = resp.RootDispersion.Seconds() * 1000
rootdisp = resp.RootDispersion.Seconds() * 1000
stratum = resp.Stratum()
}
v := variable_t {
Label: label,
message.Variables["rootdisp"] = variable_t {
Label: "rootdisp",
Variable: "",
Value: strconv.FormatFloat(value, 'f', 4, 64),
Value: strconv.FormatFloat(rootdisp, 'f', 4, 64),
Unit: "ms",
Status: status,
}
message.Variables["stratum"] = variable_t {
Label: "stratum",
Variable: "",
Value: strconv.FormatInt(stratum, 10),
Unit: "ms",
Status: status,
}
message.Variables[label] = v
j, err := json.Marshal(message)