Module: check_mk
Branch: master
Commit: 641329290cf1b4ef1e5428b0c44c525ed0dfec1e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=641329290cf1b4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 29 16:46:45 2016 +0100
#3252 FIX ntp.time: better handling of temporary synchronization loss
After a reboot of the target machine or of the NTP server the check always
go CRIT for a couple of minutes - since NTP disregarded the peers as suitable.
Now this is being tolerated for a configurable amount of time. Per default
after 5 minutes of being without a valid time source the check goes WARN
and after 60 minute CRIT - but only if before this there was a valid time.
---
.werks/3252 | 13 +++++++++
ChangeLog | 1 +
checks/ntp | 52 ++++++++++++++++++++++++++++++----
web/plugins/wato/check_parameters.py | 19 ++++++++++++-
4 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/.werks/3252 b/.werks/3252
new file mode 100644
index 0000000..68d8463
--- /dev/null
+++ b/.werks/3252
@@ -0,0 +1,13 @@
+Title: ntp.time: better handling of temporary synchronization loss
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1456760686
+Class: fix
+
+After a reboot of the target machine or of the NTP server the check always
+go CRIT for a couple of minutes - since NTP disregarded the peers as suitable.
+Now this is being tolerated for a configurable amount of time. Per default
+after 5 minutes of being without a valid time source the check goes WARN
+and after 60 minute CRIT - but only if before this there was a valid time.
diff --git a/ChangeLog b/ChangeLog
index 3d7dc78..7c50568 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,7 @@
* 3245 FIX: Fix interpretation of check levels 0.0 as "no levels"...
* 3250 FIX: cisco_mem: remove bogus memory check for "Driver text"...
* 3084 FIX: windows agent: fixed crash when specifying an invalid performance counter
+ * 3252 FIX: ntp.time: better handling of temporary synchronization loss...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/ntp b/checks/ntp
index b1dcd62..3b90f06 100644
--- a/checks/ntp
+++ b/checks/ntp
@@ -26,6 +26,11 @@
ntp_default_levels = (10, 200.0, 500.0) # stratum, ms offset
+factory_settings["ntp_time_default_levels"] = {
+ "ntp_levels" : ntp_default_levels,
+ "alert_delay" : (300, 3600),
+}
+
# Example output from agent:
# <<<ntp>>>
# - 42.202.61.100 .INIT. 16 u - 1024 0 0.000 0.000 0.000
@@ -123,6 +128,7 @@ def check_ntp_server_state(line, params):
else:
return (0, infotext, offset, jitter)
+
def check_ntp(item, params, info):
for line in info:
if line[1] == item:
@@ -139,18 +145,53 @@ def check_ntp(item, params, info):
return (3, "peer not found")
-def check_ntp_summary(item, params, info):
+
+def check_ntp_summary(_no_item, params, info):
+ if type(params) == tuple:
+ params = {
+ "ntp_levels" : params,
+ "alert_delay" : (300, 3600),
+ }
# No information at all? NTP daemon not running or timeout in ntpq -p
if len(info) == 0:
- return (3, "no information from NTP: timeout in ntpq -p or NTP daemon not running")
+ yield 3, "no information from NTP: timeout in ntpq -p or NTP daemon not running"
+ return
# We only are interested in our system peer or pulse per second source (pps)
for line in info:
if line[0] in [ "*", "o" ]:
- state, text, perfdata = check_ntp(line[1], params, [line])
+ state, text, perfdata = check_ntp(line[1], params["ntp_levels"], [line])
text += " (synchronized on %s)" % line[1]
- return (state, text, perfdata)
- return (2, "found %d peers, but none is suitable" % len(info))
+ set_item_state(None, ("sync", time.time(), state, "last successful sync")) # remember last successfull sync
+ yield state, text, perfdata
+ return
+
+ infotext = "found %d peers, but none is suitable" % len(info)
+ yield 0, infotext
+
+ # Currently no peer is suitable. But we want to tolerate that for a while.
+ entry = get_item_state(None)
+ if entry == None:
+ set_item_state(None, ("init", time.time(), 0, infotext))
+ yield 0, "just started monitoring"
+ return
+
+ how, last_successful_sync, last_state, last_infotext = entry
+ time_since_sync = time.time() - last_successful_sync
+ infotext = "this is %s since " % get_age_human_readable(time_since_sync)
+ infotext += last_infotext
+ yield last_state, infotext
+
+ warn_time, crit_time = params["alert_delay"]
+ if time_since_sync >= crit_time:
+ status = 2
+ elif time_since_sync >= warn_time:
+ status = 1
+ else:
+ status = 0
+
+ if status:
+ yield status, "(levels at %s/%s)" % (get_age_human_readable(warn_time), get_age_human_readable(crit_time))
@@ -168,4 +209,5 @@ check_info["ntp.time"] = {
'service_description': 'NTP Time',
'has_perfdata': True,
'group': 'ntp_time',
+ 'default_levels_variable': "ntp_time_default_levels",
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 6cf9cf3..7c4a2bb 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -8730,6 +8730,7 @@ register_check_parameters(
)
ntp_params = \
Tuple(
+ title = _("Thresholds for quality of time"),
elements = [
Integer(
title = _("Critical at stratum"),
@@ -8755,7 +8756,23 @@ register_check_parameters(
subgroup_os,
"ntp_time",
_("State of NTP time synchronisation"),
- ntp_params,
+ Transform(
+ Dictionary(
+ elements = [
+ ( "ntp_levels",
+ ntp_params, ),
+ ( "alert_delay",
+ Tuple(
+ title = _("Phases without synchronization"),
+ elements = [
+ Age(title=_("Warning at"), display=["hours", "minutes"], default_value = 300, ),
+ Age(title=_("Critical at"), display=["hours", "minutes"], default_value = 3600,),
+ ]
+ )),
+ ]
+ ),
+ forth = lambda params: type(params) == tuple and { "ntp_levels" : params } or params
+ ),
None,
"first"
)
Module: check_mk
Branch: master
Commit: 4b0fe79910fedb92adfff6d56d2caa8bdabc6b3a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4b0fe79910fedb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 29 14:33:52 2016 +0100
Fix Multisite profiling. It is no longer trigger by config variable
You now have to create the directory var/check_mk/profiling. If it exists, the profile will be
created in that directory
---
web/htdocs/index.py | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 37c6f6f..e35cd19 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -36,6 +36,25 @@ from html_mod_python import html_mod_python, FinalizeRequest
# Main entry point for all HTTP-requests (called directly by mod_apache)
def handler(req, fields = None, is_profiling = False):
+ if not is_profiling and os.path.exists(defaults.var_dir + "/profiling"):
+ import cProfile
+ # the profiler loses the memory about all modules. We need to hand over
+ # the request object in the apache module.
+ # Ubuntu: install python-profiler when using this feature
+ profile_file = defaults.var_dir + "/profiling/multisite.profile"
+ retcode = cProfile.runctx(
+ "import index; "
+ "index.handler(profile_req, profile_fields, is_profiling=True)",
+ {'profile_req': req, 'profile_fields': fields}, {}, profile_file)
+ file(profile_file + ".py", "w").write(
+ "#!/usr/bin/python\n"
+ "import pstats\n"
+ "stats = pstats.Stats(%r)\n"
+ "stats.sort_stats('time').print_stats()\n" % profile_file)
+ os.chmod(profile_file + ".py", 0755)
+ return apache.OK
+
+
# Create an object that contains all data about the request and
# helper functions for creating valid HTML. Parse URI and
# store results in the request object for later usage.
@@ -45,7 +64,6 @@ def handler(req, fields = None, is_profiling = False):
try:
config.load_config() # load multisite.mk etc.
html.init_modes()
- init_profiling(is_profiling)
# Make sure all plugins are avaiable as early as possible. At least
# we need the plugins (i.e. the permissions declared in these) at the
@@ -191,27 +209,6 @@ def handler(req, fields = None, is_profiling = False):
return response_code
-# Profiling of the Check_MK GUI can be enabled via global settings
-def init_profiling(is_profiling):
- if not is_profiling and config.profile:
- import cProfile
- # the profiler loses the memory about all modules. We need to hand over
- # the request object in the apache module.
- # Ubuntu: install python-profiler when using this feature
- profile_file = defaults.var_dir + "/web/multisite.profile"
- retcode = cProfile.runctx(
- "import index; "
- "index.handler(profile_req, profile_fields, is_profiling=True)",
- {'profile_req': html.req, 'profile_fields': html.fields}, {}, profile_file)
- file(profile_file + ".py", "w").write(
- "#!/usr/bin/python\n"
- "import pstats\n"
- "stats = pstats.Stats(%r)\n"
- "stats.sort_stats('time').print_stats()\n" % profile_file)
- os.chmod(profile_file + ".py", 0755)
- raise FinalizeRequest(apache.OK)
-
-
# Ajax-Functions want no HTML output in case of an error but
# just a plain server result code of 500
def fail_silently():
Module: check_mk
Branch: master
Commit: 1afa42765f95d0169dbb43b90d8495f9c745b5d5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1afa42765f95d0…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Feb 29 11:01:56 2016 +0100
#3253 FIX sms: notification script sms now handles single quotes in the message in the right way
---
.werks/3253 | 10 ++++++++++
ChangeLog | 3 +++
notifications/sms | 5 +++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/.werks/3253 b/.werks/3253
new file mode 100644
index 0000000..a3f629b
--- /dev/null
+++ b/.werks/3253
@@ -0,0 +1,10 @@
+Title: sms: notification script sms now handles single quotes in the message in the right way
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456740033
+
+
diff --git a/ChangeLog b/ChangeLog
index d2791a1..5d1f7bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,9 @@
* 2998 FIX: Fixed broken WATO rules where content is dynamically loaded...
* 3246 FIX: Fix link for editing a BI aggregation after coming back from the details of another aggregation...
+ Notifications:
+ * 3253 FIX: sms: notification script sms now handles single quotes in the message in the right way
+
BI:
* 3247 FIX: Do not allow multiple BI aggregates with the same title...
diff --git a/notifications/sms b/notifications/sms
index 20d0d01..5512028 100755
--- a/notifications/sms
+++ b/notifications/sms
@@ -87,16 +87,17 @@ elif notification_type == "CUSTOM":
message += " " + os.environ['NOTIFY_NOTIFICATIONCOMMENT']
recipient = os.environ['NOTIFY_CONTACTPAGER'].replace(" ", "")
+quoted_message = "'" + message.replace("'", "'\"'\"'") + "'"
if send_path:
- if os.system("%s %s '%s'" % (send_path, recipient, message[:160])) >> 8 != 0:
+ if os.system("%s %s %s" % (send_path, recipient, quoted_message[:160])) >> 8 != 0:
sys.exit(1)
elif spool_dir:
# On some distros, like debian, smstools does not ship with the sendsms/smssend helper
# script. On this distro, simply drop the SMS in the outgoing spool directory.
import tempfile, shutil
fd, path = tempfile.mkstemp(prefix = 'cmk_sms_')
- os.write(fd, 'To: %s\n\n%s' % (recipient, message))
+ os.write(fd, 'To: %s\n\n%s' % (recipient, quoted_message))
os.close(fd)
os.chmod(path, 0660)
filename = path.split('/')[-1]