From 675f4bad2969bfd3e1f70ddbc6f6c933c84090c3 Mon Sep 17 00:00:00 2001 From: Leo Pempera <124032058+leo-pempera@users.noreply.github.com> Date: Fri, 3 May 2024 16:08:30 +0200 Subject: [PATCH] ntp-ntpd: Fixed unpacking of ntpq -p values (#758) When the chosen ntp Server (maked by *) has one or more whitespaces in its name, the original parsing fails with too many values to unpack. Example: '*185.232.69.65 ( 79.133.44.146 2 u 139 256 377 0.401 0.133 0.137' peer, refid, stratum, _type, when, poll, reach, delay, offset, jitter = line[1:].split() ValueError: too many values to unpack (expected 10) --- check-plugins/ntp-ntpd/ntp-ntpd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/check-plugins/ntp-ntpd/ntp-ntpd b/check-plugins/ntp-ntpd/ntp-ntpd index 7945390e..fe722450 100755 --- a/check-plugins/ntp-ntpd/ntp-ntpd +++ b/check-plugins/ntp-ntpd/ntp-ntpd @@ -102,9 +102,14 @@ def main(): peer_used = True try: # line of peer in the form [tally]remote refid st t when pool reach delay offset jitter - peer, refid, stratum, _type, when, poll, reach, delay, offset, jitter = line[1:].split() # remove '*' and split - offset = float(offset) - stratum = int(stratum) + split_line = line[1:].split() + + # Get numeric values via negativ index as there might be multiple whitespaces in remote + peer = split_line[0] + stratum = int(split_line[-8]) + delay = split_line[-3] + offset = float(split_line[-2]) + jitter = split_line[-1] except: pass