diff options
author | Dominik Schloesser <dsc@dosc.net> | 2017-09-02 13:14:06 +0200 |
---|---|---|
committer | Dominik Schloesser <dsc@dosc.net> | 2017-09-02 13:14:06 +0200 |
commit | 65ed2942ec3f302adb6520498858f7bea98d88fe (patch) | |
tree | 5ba170a02472f1f10ccf7d21371e000cbf3aee1e /python.d | |
parent | 7fbaa2e9fc6ad08d495e005e5da2210f7a12cf25 (diff) |
More checks against format-changes in chronyc, dict exception handling fixed.
Diffstat (limited to 'python.d')
-rw-r--r-- | python.d/chrony.chart.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/python.d/chrony.chart.py b/python.d/chrony.chart.py index 610395f30a..0026c0215f 100644 --- a/python.d/chrony.chart.py +++ b/python.d/chrony.chart.py @@ -81,8 +81,9 @@ class Service(ExecutableService): chrony_dict = {} for line in lines[1:]: lparts = line.split(':', 1) - value = lparts[1].strip().split(' ')[0] - chrony_dict[lparts[0].strip()] = value + if (len(lparts) > 1): + value = lparts[1].strip().split(' ')[0] + chrony_dict[lparts[0].strip()] = value return {'timediff': int(float(chrony_dict['System time']) * 1e9), 'lastoffset': int(float(chrony_dict['Last offset']) * 1e9), 'rmsoffset': int(float(chrony_dict['RMS offset']) * 1e9), @@ -95,6 +96,6 @@ class Service(ExecutableService): else: self.error("No valid chronyc output") return None - except (ValueError, AttributeError): + except (ValueError, AttributeError, KeyError): self.error("Chronyc data parser exception") return None |