Module: check_mk
Branch: master
Commit: 43fe6d227ef3fbf6ce0895665398cddc8eb2b031
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=43fe6d227ef3fb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 25 14:42:32 2016 +0200
3736 New option for discontinuing counting on open event after configured time
In the {{Counting}} section of a rule the Event Console has now a new option
{{Discontinue counting after time as elapsed}}. Normally new messages matching
an existing open event that is configured for counting will simply increase
the counter and not open a new event.
When you activate the new option you can limit this phase to a certain
duration, e.g. to 10 minutes. Any messages arriving 10 minutes after the
first matching message will then open a new event instead of just increasing
the counter of the existing one.
---
.werks/3736 | 17 +++++++++++++++++
ChangeLog | 1 +
bin/mkeventd | 4 ++++
web/plugins/wato/mkeventd.py | 12 ++++++++++++
4 files changed, 34 insertions(+)
diff --git a/.werks/3736 b/.werks/3736
new file mode 100644
index 0000000..01f07d1
--- /dev/null
+++ b/.werks/3736
@@ -0,0 +1,17 @@
+Title: New option for discontinuing counting on open event after configured time
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.4.0i1
+Date: 1469449843
+Class: feature
+
+In the {{Counting}} section of a rule the Event Console has now a new option
+{{Discontinue counting after time as elapsed}}. Normally new messages matching
+an existing open event that is configured for counting will simply increase
+the counter and not open a new event.
+
+When you activate the new option you can limit this phase to a certain
+duration, e.g. to 10 minutes. Any messages arriving 10 minutes after the
+first matching message will then open a new event instead of just increasing
+the counter of the existing one.
diff --git a/ChangeLog b/ChangeLog
index e0025af..b2882a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -553,6 +553,7 @@
* 3716 New sites now have a default rule pack from the start
* 3717 Added search to EC settings and structured the options in multiple settings
* 3720 The Event Console views are now supporting distributed setups...
+ * 3736 New option for discontinuing counting on open event after configured time...
* 3058 FIX: Event Console is now allowing non loadable MIB modules on startup...
* 3097 FIX: mkeventd: fixed crash with non-descriptive error message if mibs couldn't be loaded
* 3335 FIX: Improved error handling when requested rule pack does not exist
diff --git a/bin/mkeventd b/bin/mkeventd
index c0f73c6..0be8705 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -3349,6 +3349,10 @@ class EventStatus():
if count["separate_match_groups"] and ev["match_groups"] != event["match_groups"]:
continue
+ if count.get("count_duration") != None and ev["first"] + count["count_duration"] < event["time"]:
+ # Counting has been discontinued on this event after a certain time
+ continue
+
found = ev
self.count_event_up(found, event)
break
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index 19b8131..20dcf0d 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -397,6 +397,18 @@ vs_mkeventd_rule = Dictionary(
],
default_value = "interval")
),
+ ( "count_duration",
+ Optional(
+ Age(
+ label = _("Count only for"),
+ help = _("When the event is in the state <i>open</i> for that time span "
+ "then no further messages of the same time will be added to the "
+ "event. It will stay open, but the count does not increase anymore. "
+ "Any further matching message will create a new event."),
+ ),
+ label = _("Discontinue counting after time as elapsed"),
+ none_label = _("Bar"),
+ )),
( "count_ack",
Checkbox(
label = _("Continue counting when event is <b>acknowledged</b>"),
Module: check_mk
Branch: master
Commit: e2e0110d78605c435d589b8c8bd1c77630c0cac4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2e0110d78605c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 25 13:53:05 2016 +0200
Function has been renamed
---
modules/automation.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/automation.py b/modules/automation.py
index 5b98d83..c44b3bd 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -1090,7 +1090,7 @@ def load_resource_file(macros):
# here. We could read the Nagios resource.cfg file, but we do not
# know for sure the place of that either.
def replace_core_macros(hostname, commandline):
- macros = get_basic_host_macros_from_attributes(hostname, get_host_attributes(hostname))
+ macros = get_host_macros_from_attributes(hostname, get_host_attributes(hostname))
load_resource_file(macros)
for varname, value in macros.items():
commandline = commandline.replace(varname, str(value))
Module: check_mk
Branch: master
Commit: 15315aed635b1a56f314e9da0ce249dc15f2b4b6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15315aed635b1a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 25 12:50:54 2016 +0200
3721 Host macros are now replaced in datasource program command lines
You can now use all host macros including custom variables in the command line of
datasource programs, just like for active checks.
---
.werks/3721 | 10 +++++++
ChangeLog | 1 +
modules/check_mk.py | 44 ++++++++++++++++++++++++++-----
web/htdocs/wato.py | 15 +++++++++++
web/plugins/wato/active_checks.py | 17 +++---------
web/plugins/wato/datasource_programs.py | 3 +--
6 files changed, 69 insertions(+), 21 deletions(-)
diff --git a/.werks/3721 b/.werks/3721
new file mode 100644
index 0000000..f2b2d83
--- /dev/null
+++ b/.werks/3721
@@ -0,0 +1,10 @@
+Title: Host macros are now replaced in datasource program command lines
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i1
+Date: 1469443786
+Class: feature
+
+You can now use all host macros including custom variables in the command line of
+datasource programs, just like for active checks.
diff --git a/ChangeLog b/ChangeLog
index 9284fb8..e0025af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
* 3531 Reduced Check_MK helper size for certain dists/python versions...
* 3580 The macro $HOSTNAME$ is now available for host checks which are based on service states
* 3155 implemented dual monitoring for systems with management boards (like HP iLO)
+ * 3721 Host macros are now replaced in datasource program command lines...
* 3193 FIX: Fixed fake check results for hosts...
* 3214 FIX: Removing SNMP checks for non SNMP hosts and agent based checks for non agent hosts...
* 3220 FIX: Check_MK HW/SW Inventory is now always disabled for "No Agent" hosts
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 3261a82..7bc9c7c 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2142,18 +2142,31 @@ def get_datasource_program(hostname, ipaddress):
path = local_special_agents_dir + "/agent_" + agentname
else:
path = special_agents_dir + "/agent_" + agentname
- return replace_datasource_program_macros(path + " " + cmd_arguments)
+ return replace_datasource_program_macros(hostname, ipaddress,
+ path + " " + cmd_arguments)
programs = host_extra_conf(hostname, datasource_programs)
if not programs:
return None
else:
- return replace_datasource_program_macros(
- programs[0].replace("<IP>", ipaddress).replace("<HOST>", hostname))
+ return replace_datasource_program_macros(hostname, ipaddress, programs[0])
-def replace_datasource_program_macros(cmd):
- return cmd
+def replace_datasource_program_macros(hostname, ipaddress, cmd):
+ # Make "legacy" translation. The users should use the $...$ macros in future
+ cmd = cmd.replace("<IP>", ipaddress).replace("<HOST>", hostname)
+
+ is_clust = is_cluster(hostname)
+
+ tags = tags_of_host(hostname)
+ attrs = get_host_attributes(hostname, tags)
+ if is_cluster(hostname):
+ parents_list = get_cluster_nodes_for_config(hostname)
+ attrs.setdefault("alias", "cluster of %s" % ", ".join(parents_list))
+ attrs.update(get_cluster_attributes(hostname, parents_list))
+
+ macros = get_host_macros_from_attributes(hostname, attrs)
+ return replace_macros(cmd, macros)
# Variables needed during the renaming of hosts (see automation.py)
@@ -3393,7 +3406,7 @@ def get_cluster_nodes_for_config(hostname):
return nodes
-def get_basic_host_macros_from_attributes(hostname, attrs):
+def get_host_macros_from_attributes(hostname, attrs):
macros = {
"$HOSTNAME$" : hostname,
"$HOSTADDRESS$" : attrs['address'],
@@ -3517,6 +3530,25 @@ def fallback_ip_for(hostname, family=None):
return "::"
+def replace_macros(s, macros):
+ for key, value in macros.items():
+ if type(value) in (int, long, float):
+ value = str(value) # e.g. in _EC_SL (service level)
+
+ # TODO: Clean this up
+ try:
+ s = s.replace(key, value)
+ except: # Might have failed due to binary UTF-8 encoding in value
+ try:
+ s = s.replace(key, value.decode("utf-8"))
+ except:
+ # If this does not help, do not replace
+ if opt_debug:
+ raise
+
+ return s
+
+
#.
# .--Main Functions------------------------------------------------------.
# | __ __ _ _____ _ _ |
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 95185c4..2095ba9 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -16511,6 +16511,21 @@ def some_host_hasnt_set(folder, attrname):
return False
+def monitoring_macro_help():
+ return " " + _("You can use monitoring macros here. The most important are: "
+ "<ul>"
+ "<li><tt>$HOSTADDRESS$</tt>: The IP address of the host</li>"
+ "<li><tt>$HOSTNAME$</tt>: The name of the host</li>"
+ "<li><tt>$USER1$</tt>: user macro 1 (usually path to shipped plugins)</li>"
+ "<li><tt>$USER2$</tt>: user marco 2 (usually path to your own plugins)</li>"
+ "<li><tt>$_HOSTTAGS$</tt>: List of host tags</li>"
+ "<li><tt>$_HOSTADDRESS_4$</tt>: The IPv4 address of the host</li>"
+ "<li><tt>$_HOSTADDRESS_6$</tt>: The IPv6 address of the host</li>"
+ "<li><tt>$_HOSTADDRESS_FAMILY$</tt>: The primary address family of the host</li>"
+ "</ul>"
+ "All custom variables defined for the host are available as <tt>$_HOST[VARNAME]$</tt>.")
+
+
#.
# .--Plugins-------------------------------------------------------------.
# | ____ _ _ |
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 8de8bfc..8abc66e 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -1421,19 +1421,10 @@ register_rule(group,
def PluginCommandLine(addhelp = ""):
return TextAscii(
title = _("Command line"),
- help = _("Please enter the complete shell command including "
- "path name and arguments to execute. You can use monitoring "
- "macros here. The most important are:<ul>"
- "<li><tt>$HOSTADDRESS$</tt>: The IP address of the host</li>"
- "<li><tt>$HOSTNAME$</tt>: The name of the host</li>"
- "<li><tt>$USER1$</tt>: user macro 1 (usually path to shipped plugins)</li>"
- "<li><tt>$USER2$</tt>: user marco 2 (usually path to your own plugins)</li>"
- "</ul>"
- "If you are using OMD, you can omit the path and just specify "
- "the command (e.g. <tt>check_foobar</tt>). This command will be "
- "searched first in the local plugins directory "
- "(<tt>~/local/lib/nagios/plugins</tt>) and then in the shipped plugins "
- "directory (<tt>~/lib/nagios/plugins</tt>) within your site directory."),
+ help = _("Please enter the complete shell command including path name and arguments to execute. "
+ "If the plugin you like to execute is located in either <tt>~/local/lib/nagios/plugins</tt> "
+ "or <tt>~/lib/nagios/plugins</tt> within your site directory, you can strip the path name and "
+ "just configure the plugin file name as command <tt>check_foobar</tt>.") + monitoring_macro_help(),
size = "max",
)
diff --git a/web/plugins/wato/datasource_programs.py b/web/plugins/wato/datasource_programs.py
index 0d55a62..cd6c249 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -37,8 +37,7 @@ register_rule(group,
"program that should be called by Check_MK instead of connecting the agent "
"via TCP. That program must output the agent's data on standard output in "
"the same format the agent would do. This is for example useful for monitoring "
- "via SSH. The command line may contain the placeholders <tt><IP></tt> and "
- "<tt><HOST></tt>."),
+ "via SSH.") + monitoring_macro_help(),
label = _("Command line to execute"),
empty_text = _("Access Check_MK Agent via TCP"),
size = 80,
Module: check_mk
Branch: master
Commit: 1218e3c48444619d9e99603819cfff74bb793bf0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1218e3c4844461…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 25 12:21:44 2016 +0200
3622 FIX Fix labelling of V-Achsis on graphs with very large numbers
If you create an own check that outputs very large metrics then the
labelling of the vertical axis in a graph would try to display numbers
like 1000000000000, with the problem that the prefix 1000... is not
visible.
Number larger than 99999 are now being displayed in exponential
syntax, e.g. 1.0e6 and are thus correctly being displayed.
---
.werks/3622 | 17 +++++++++++++++++
ChangeLog | 1 +
web/htdocs/lib.py | 9 +++++++++
web/plugins/metrics/check_mk.py | 2 +-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/3622 b/.werks/3622
new file mode 100644
index 0000000..7411638
--- /dev/null
+++ b/.werks/3622
@@ -0,0 +1,17 @@
+Title: Fix labelling of V-Achsis on graphs with very large numbers
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1469441963
+
+If you create an own check that outputs very large metrics then the
+labelling of the vertical axis in a graph would try to display numbers
+like 1000000000000, with the problem that the prefix 1000... is not
+visible.
+
+Number larger than 99999 are now being displayed in exponential
+syntax, e.g. 1.0e6 and are thus correctly being displayed.
+
diff --git a/ChangeLog b/ChangeLog
index fabe220..9284fb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -403,6 +403,7 @@
* 3668 FIX: Fixed slow loading of GUI pages when using a localized GUI
* 3669 FIX: LDAP: Fixed very long running LDAP sync when using group based sync plugins
* 3670 FIX: Fixed empty AV PDF report when exporting it from a quicksearch result view
+ * 3622 FIX: Fix labelling of V-Achsis on graphs with very large numbers...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node selection...
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index a737416..79c77f4 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -484,6 +484,13 @@ def frexp10(x):
return frexpb(x, 10)
+def render_scientific(v, precision=3):
+ mantissa, exponent = frexp10(float(v))
+ # Render small numbers without exponent
+ if exponent >= -3 and exponent <= 4:
+ return "%%.%df" % max(0, precision - exponent) % v
+
+ return "%%.%dfe%%d" % precision % (mantissa, exponent)
# Render a physical value witha precision of p
@@ -624,6 +631,8 @@ def render_float_with_precision(value, precision):
return "%%.%df" % digits % value
+
+
def number_human_readable(n, precision=1, unit="B"):
base = 1024.0
if unit == "Bit":
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 4eec359..27a6ab4 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -65,7 +65,7 @@ unit_info[""] = {
"title" : "",
"description" : _("Floating point number"),
"symbol" : "",
- "render" : lambda v: render_float_with_precision(v, 3),
+ "render" : lambda v: render_scientific(v, 2),
}
unit_info["count"] = {