fix leap_status value in chrony input plugin (#1983)

This commit is contained in:
Matteo Cerutti 2016-11-03 10:46:54 +00:00 committed by Cameron Sparr
parent 137272afea
commit e43cfc2fce
2 changed files with 7 additions and 3 deletions

View File

@ -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") {

View File

@ -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
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