Skip to content
Snippets Groups Projects
Commit e43cfc2f authored by Matteo Cerutti's avatar Matteo Cerutti Committed by Cameron Sparr
Browse files

fix leap_status value in chrony input plugin (#1983)

parent 137272af
No related branches found
No related tags found
No related merge requests found
...@@ -103,9 +103,13 @@ func processChronycOutput(out string) (map[string]interface{}, map[string]string ...@@ -103,9 +103,13 @@ func processChronycOutput(out string) (map[string]interface{}, map[string]string
tags["stratum"] = valueFields[0] tags["stratum"] = valueFields[0]
continue continue
} }
if strings.Contains(strings.ToLower(name), "reference_id") {
tags["reference_id"] = valueFields[0]
continue
}
value, err := strconv.ParseFloat(valueFields[0], 64) value, err := strconv.ParseFloat(valueFields[0], 64)
if err != nil { if err != nil {
tags[name] = strings.ToLower(valueFields[0]) tags[name] = strings.ToLower(strings.Join(valueFields, " "))
continue continue
} }
if strings.Contains(stats[1], "slow") { if strings.Contains(stats[1], "slow") {
......
...@@ -27,7 +27,7 @@ func TestGather(t *testing.T) { ...@@ -27,7 +27,7 @@ func TestGather(t *testing.T) {
tags := map[string]string{ tags := map[string]string{
"reference_id": "192.168.1.22", "reference_id": "192.168.1.22",
"leap_status": "normal", "leap_status": "not synchronized",
"stratum": "3", "stratum": "3",
} }
fields := map[string]interface{}{ fields := map[string]interface{}{
...@@ -85,7 +85,7 @@ Skew : 0.006 ppm ...@@ -85,7 +85,7 @@ Skew : 0.006 ppm
Root delay : 0.001655 seconds Root delay : 0.001655 seconds
Root dispersion : 0.003307 seconds Root dispersion : 0.003307 seconds
Update interval : 507.2 seconds Update interval : 507.2 seconds
Leap status : Normal Leap status : Not synchronized
` `
args := os.Args args := os.Args
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment