Module: check_mk
Branch: master
Commit: 95a28b6e2ca44c7cb74ffb5d6bf32652a5c78416
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=95a28b6e2ca44c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 12 08:43:53 2011 +0200
FIX: ntp: Handling large times in "poll" column correctly
---
ChangeLog | 1 +
checks/ntp | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 01db004..a53518a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
* cups_queues: Run agent part only on directly on CUPS servers,
not on clients
* FIX: mbg_lantime_state: Fixed output UOM to really be miliseconds
+ * FIX: ntp: Handling large times in "poll" column correctly
Multisite:
* FIX: fix rescheduling of host check
diff --git a/checks/ntp b/checks/ntp
index c11722d..3ae6df2 100644
--- a/checks/ntp
+++ b/checks/ntp
@@ -69,6 +69,18 @@ def inventory_ntp_summary(info):
if len(info) > 0:
return [(None, "ntp_default_levels")]
+def ntp_fmt_time(t):
+ if t == '-':
+ return 0
+ elif t[-1] == "m":
+ return int(t[:-1]) * 60
+ elif t[-1] == "h":
+ return int(t[:-1]) * 60 * 60
+ elif t[-1] == "d":
+ return int(t[:-1]) * 60 * 60 * 24
+ else:
+ return int(t)
+
# Helper function that parses the information about one
# peer and returns a tuple of
# 0. Nagios state (0, 1, 2 or 3)
@@ -83,19 +95,8 @@ def check_ntp_server_state(line, params):
offset = float(offset)
jitter = float(jitter)
- # Parse time when search was last reached
- if when == '-':
- when = 0
- elif when[-1] == "m":
- when = int(when[:-1]) * 60
- elif when[-1] == "h":
- when = int(when[:-1]) * 60 * 60
- elif when[-1] == "d":
- when = int(when[:-1]) * 60 * 60 * 24
- else:
- when = int(when)
-
- poll = int(poll)
+ when = ntp_fmt_time(when)
+ poll = ntp_fmt_time(poll)
stratum = int(stratum)
state = ntp_state_codes.get(statecode, "unknown")
infotext = "%s - stratum %d, offset %.2f ms, jitter %.2f ms" % (state,
stratum, offset, jitter)