Module: check_mk
Branch: master
Commit: 2063752c337a27c60cc65955908614411c6ee50c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2063752c337a27…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 25 19:18:34 2011 +0100
systemtime: new check for Windows time precision
---
ChangeLog | 3 +-
checks/systemtime | 52 +++++++++++++++++++++++++++++++++
pnp-templates/check_mk-systemtime.php | 51 ++++++++++++++++++++++++++++++++
web/plugins/perfometer/check_mk.py | 9 +++--
4 files changed, 110 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 307a5bb..f39c5cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,8 @@
Checks & Agents:
* FIX: drbd now handles output of older version without an ep field
-
+ * systemtime: new simple check for time synchronization on Windows
+ (needs agent update)
1.1.9i9:
diff --git a/checks/systemtime b/checks/systemtime
new file mode 100644
index 0000000..471a9dd
--- /dev/null
+++ b/checks/systemtime
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+systemtime_default_values = (30, 60) # warn/crit sec. offset
+
+def inventory_systemtime(checkname, info):
+ if len(info) >= 1:
+ return [(None, "systemtime_default_values")]
+
+def check_systemtime(item, params, info):
+ if len(info) == 0:
+ return (3, "UNKNOWN - no information sent by agent")
+
+ systemtime = int(info[0][0])
+ ourtime = time.time()
+ offset = systemtime - ourtime
+ warn, crit = params
+ infotext = "Offset is %+.1f sec (levels at %d/%d sec)" % (offset, warn,
crit)
+ perfdata = [ ("offset", offset, warn, crit, 0) ]
+
+ if abs(offset) >= crit:
+ return (2, "CRIT - " + infotext, perfdata)
+ elif abs(offset) >= warn:
+ return (1, "WARN - " + infotext, perfdata)
+ else:
+ return (0, "OK - " + infotext, perfdata)
+
+check_info["systemtime"] = ( check_systemtime, "System Time", 1,
inventory_systemtime )
+
diff --git a/pnp-templates/check_mk-systemtime.php
b/pnp-templates/check_mk-systemtime.php
new file mode 100644
index 0000000..82fe70e
--- /dev/null
+++ b/pnp-templates/check_mk-systemtime.php
@@ -0,0 +1,51 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+$range = $CRIT[1];
+
+$opt[1] = "--vertical-label 'offset (s)' -l -$range -u $range --title
'$hostname: system time offset to Nagios' ";
+
+$def[1] = "DEF:offset_max=$RRDFILE[1]:$DS[1]:MAX ".
+ "DEF:offset_min=$RRDFILE[1]:$DS[1]:MIN ".
+ "DEF:offset_avg=$RRDFILE[1]:$DS[1]:AVERAGE ".
+ "CDEF:offmax=offset_max,0,MAX ".
+ "CDEF:offmin=offset_min,0,MIN ".
+ "CDEF:offsetabs_min=offset_min,ABS ".
+ "CDEF:offsetabs_max=offset_max,ABS ".
+ "CDEF:offsetabs=offset_min,offset_max,MAX ".
+ "AREA:offmax#4080ff:\"time offset \" ".
+ "AREA:offmin#4080ff ".
+ "LINE1:offmin#2060d0: ".
+ "LINE1:offmax#2060d0: ".
+ "HRULE:0#c0c0c0: ".
+ "HRULE:$WARN[1]#ffff00:\"\" ".
+ "HRULE:-$WARN[1]#ffff00:\"Warning\\: +/- $WARN[1] s \" ".
+ "HRULE:$CRIT[1]#ff0000:\"\" ".
+ "HRULE:-$CRIT[1]#ff0000:\"Critical\\: +/- $CRIT[1] s \\n\"
".
+ "GPRINT:offset_avg:LAST:\"current\: %.1lf s\" ".
+ "GPRINT:offsetabs:MAX:\"max(+/-)\: %.1lf s \" ".
+ "GPRINT:offsetabs:AVERAGE:\"avg(+/-)\: %.1lf s\" ".
+ "";
+?>
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 75dc7f2..c23ddeb 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -132,7 +132,7 @@ def perfometer_check_mk_cpu_loads(row, check_command, perf_data):
perfometers["check_mk-cpu.loads"] = perfometer_check_mk_cpu_loads
perfometers["check_mk-ucd_cpu_load"] = perfometer_check_mk_cpu_loads
-def perfometer_check_mk_ntp(row, check_command, perf_data):
+def perfometer_check_mk_ntp(row, check_command, perf_data, unit = "ms"):
offset = float(perf_data[0][1])
absoffset = abs(offset)
warn = float(perf_data[0][3])
@@ -155,10 +155,11 @@ def perfometer_check_mk_ntp(row, check_command, perf_data):
h += perfometer_td(50, "#fff")
h += '</tr></table>'
- return "%.1f ms" % offset, h
+ return "%.1f %s" % (offset, unit), h
-perfometers["check_mk-ntp"] = perfometer_check_mk_ntp
-perfometers["check_mk-ntp.time"] = perfometer_check_mk_ntp
+perfometers["check_mk-ntp"] = perfometer_check_mk_ntp
+perfometers["check_mk-ntp.time"] = perfometer_check_mk_ntp
+perfometers["check_mk-systemtime"] = lambda r, c, p: perfometer_check_mk_ntp(r,
c, p, "s")
def perfometer_check_mk_ipmi_sensors(row, check_command, perf_data):
state = row["service_state"]