From 65ed2942ec3f302adb6520498858f7bea98d88fe Mon Sep 17 00:00:00 2001 From: Dominik Schloesser Date: Sat, 2 Sep 2017 13:14:06 +0200 Subject: More checks against format-changes in chronyc, dict exception handling fixed. --- python.d/chrony.chart.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'python.d') 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 -- cgit v1.2.3