From 3e01588570e3c9d03302570a53958b14b5e355c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=BD?= Date: Tue, 26 May 2020 16:57:16 +0200 Subject: [PATCH] Plugin timesync_status: Handle value 0 correctly --- plugins/systemd/timesync_status | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/systemd/timesync_status b/plugins/systemd/timesync_status index 63eb8ec8..c223d633 100755 --- a/plugins/systemd/timesync_status +++ b/plugins/systemd/timesync_status @@ -57,6 +57,10 @@ def parse_time(value): if ' ' in value: return sum(parse_time(x) for x in value.split(' ')) + # If time is exactly zero (for example Jitter), there is no unit (suffix) + if value == "0" or value == "-0": + return 0 + match = re.match(r'^([+-]?[0-9.]+)([a-z]+)$', value) if not match: raise ValueError('Invalid time ' + value)