From 0197a614ed53bcf75bf0ff6db3d93f93680928a9 Mon Sep 17 00:00:00 2001 From: JSH Date: Tue, 11 Jul 2017 17:08:40 -0400 Subject: [PATCH] Fix chrony plugin does not track system time offset (#2989) --- plugins/inputs/chrony/README.md | 3 ++- plugins/inputs/chrony/chrony.go | 2 +- plugins/inputs/chrony/chrony_test.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/chrony/README.md b/plugins/inputs/chrony/README.md index 2a810f521..aa4f84806 100644 --- a/plugins/inputs/chrony/README.md +++ b/plugins/inputs/chrony/README.md @@ -63,6 +63,7 @@ Delete second or Not synchronised. ### Measurements & Fields: - chrony + - system_time (float, seconds) - last_offset (float, seconds) - rms_offset (float, seconds) - frequency (float, ppm) @@ -84,7 +85,7 @@ Delete second or Not synchronised. ``` $ telegraf --config telegraf.conf --input-filter chrony --test * Plugin: chrony, Collection 1 -> chrony,leap_status=normal,reference_id=192.168.1.1,stratum=3 frequency=-35.657,last_offset=-0.000013616,residual_freq=-0,rms_offset=0.000027073,root_delay=0.000644,root_dispersion=0.003444,skew=0.001,update_interval=1031.2 1463750789687639161 +> chrony,leap_status=normal,reference_id=192.168.1.1,stratum=3 frequency=-35.657,system_time=0.000027073,last_offset=-0.000013616,residual_freq=-0,rms_offset=0.000027073,root_delay=0.000644,root_dispersion=0.003444,skew=0.001,update_interval=1031.2 1463750789687639161 ``` diff --git a/plugins/inputs/chrony/chrony.go b/plugins/inputs/chrony/chrony.go index f39108921..94285d249 100644 --- a/plugins/inputs/chrony/chrony.go +++ b/plugins/inputs/chrony/chrony.go @@ -92,7 +92,7 @@ func processChronycOutput(out string) (map[string]interface{}, map[string]string } name := strings.ToLower(strings.Replace(strings.TrimSpace(stats[0]), " ", "_", -1)) // ignore reference time - if strings.Contains(name, "time") { + if strings.Contains(name, "ref_time") { continue } valueFields := strings.Fields(stats[1]) diff --git a/plugins/inputs/chrony/chrony_test.go b/plugins/inputs/chrony/chrony_test.go index 496986c40..28633cd0c 100644 --- a/plugins/inputs/chrony/chrony_test.go +++ b/plugins/inputs/chrony/chrony_test.go @@ -31,6 +31,7 @@ func TestGather(t *testing.T) { "stratum": "3", } fields := map[string]interface{}{ + "system_time": 0.000020390, "last_offset": 0.000012651, "rms_offset": 0.000025577, "frequency": -16.001,