Module: check_mk
Branch: master
Commit: e2fdab6ddec88ae9cb099cb9f99ce44e25359f07
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2fdab6ddec88a…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Jul 21 14:55:37 2014 +0200
First version of next yield based check api
---
checks/pdu_gude.include | 28 ++++++++++++----------------
modules/check_mk_base.py | 33 +++++++++++++++++++++++++++++++--
2 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/checks/pdu_gude.include b/checks/pdu_gude.include
index 054a7de..64fc745 100644
--- a/checks/pdu_gude.include
+++ b/checks/pdu_gude.include
@@ -38,7 +38,8 @@ def check_pdu_gude(item, params, info):
try:
values = info[item - 1]
except ValueError:
- return (3, "Item not found")
+ yield 3, "Item not found"
+ return
units = {
0 : ("kWh", 1000),
@@ -48,32 +49,27 @@ def check_pdu_gude(item, params, info):
4 : ("VA",False),
}
- message = []
- perf = []
- state = 0
for pos, data in units.items():
value = savefloat(values[pos])
unit, div = data
if div:
value = value / div
warn, crit = params.get(unit, (None, None))
- perf.append((unit, value, warn, crit))
- label = ""
+ perf = unit, value, warn, crit
+ message = "%.2f%s" % (value, unit)
if warn > crit:
if value < crit:
- state = 2
- label = "(!!)"
+ yield 2, message, perf
elif value < warn:
- state = max(state, 1)
- label = "(!)"
+ yield 1, message, perf
+ else:
+ yield 0, message, perf
else:
if crit != None and value > crit:
- state = 2
- label = "(!!)"
+ yield 2, message, perf
elif warn != None and value > warn:
- state = max(state, 1)
- label = "(!)"
- message.append("%.2f%s%s" % (value, unit, label))
+ yield 1, message, perf
+ else:
+ yield 0, message, perf
- return(state, ", ".join(message), perf)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index bfea8f7..b165056 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1179,6 +1179,35 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
try:
dont_submit = False
result = check_function(item, params, info)
+ # the new api doesen't return a tuple,
+ # it's yield based instead.
+ if type(result) != tuple:
+ messages = []
+ perf = []
+ for line in result:
+ messages.append(( line[0], line[1] ))
+ if len(line) == 3:
+ # there can be a single perf value (tuple)
+ # or a list of multiple perf values
+ if type(line[2]) == tuple:
+ perf.append(line[2])
+ elif type(line[2]) == list:
+ perf += list
+ # Check funktion returns only a single line
+ if len(messages) == 1:
+ result = messages[0][0], messages[0][1], perf
+ else:
+ # Get the overall status
+ return_states = [ x[0] for x in messages ]
+ if 3 in return_states:
+ if not 2 in return_states and not 1 in return_states:
+ status = 3
+ else:
+ status = max(return_states) - 1
+ else:
+ status = max(return_states)
+ result = status, ", ".join( x[1]+state_markers[x[0]] for x in messages )
+
# handle check implementations that do not yet support the
# handling of wrapped counters via exception. Do not submit
# any check result in that case:
@@ -1618,8 +1647,8 @@ def get_regex(pattern):
# Names of texts usually output by checks
nagios_state_names = ["OK", "WARN", "CRIT", "UNKNOWN"]
-# Symbolic representations of states
-state_markers = ["(.)", "(!)", "(!!)", "(?)"]
+# Symbolic representations of states (Needed for new 2.0 check api)
+state_markers = ["", "(!)", "(!!)", "(?)"]
# int() function that return 0 for strings the
# cannot be converted to a number
Module: check_mk
Branch: master
Commit: c9346c14c1ed50292468c77186bc12f2becf2d4d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c9346c14c1ed50…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jul 21 12:26:25 2014 +0200
improved formatting
---
.werks/1085 | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/.werks/1085 b/.werks/1085
index 4cec3c9..c519807 100644
--- a/.werks/1085
+++ b/.werks/1085
@@ -5,15 +5,13 @@ Version: 1.2.5i5
Date: 1405937822
Class: feature
-When a quicksearch pattern matched multiple hosts the view hosts was shown.
-This view also displayed all services for these hosts, which could lead
-to plenty of (unwanted) output in the view.
-<br>
+When a quicksearch pattern matched multiple hosts the view <tt>hosts</tt> was shown.
+This view displayed all services for these hosts, which could lead to plenty of (unwanted) output in the view.
The quicksearch feature has been changed in the following way<br>
<ul>
-<li>If there are multiple host matches the searchhost view is displayed</li>
-<li>If there is a single match the hosts view is displayed (this view also contains the services)</li>
+<li>If there are multiple host matches the <tt>searchhost</tt> view is displayed</li>
+<li>If there is a single match the <tt>hosts</tt> view is displayed (this view also contains the services)</li>
</ul>
Note: This also applies to special search patterns like <tt>h:localhost h:otherhost</tt>
Module: check_mk
Branch: master
Commit: e18451854725a52859817147c9216a67dd182d6c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e18451854725a5…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jul 21 12:24:29 2014 +0200
quicksearch: multiple hostname matches now lead to the searchhost view instead of the hosts view
When a quicksearch pattern matched multiple hosts the view hosts was shown.
This view also displayed all services for these hosts, which could lead
to plenty of (unwanted) output in the view.
<br>
The quicksearch feature has been changed in the following way<br>
<ul>
<li>If there are multiple host matches the searchhost view is displayed</li>
<li>If there is a single match the hosts view is displayed (this view also contains the services)</li>
</ul>
Note: This also applies to special search patterns like <tt>h:localhost h:otherhost</tt>
---
.werks/1085 | 19 +++++++++++++++++++
ChangeLog | 1 +
web/htdocs/sidebar.py | 2 +-
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/.werks/1085 b/.werks/1085
new file mode 100644
index 0000000..4cec3c9
--- /dev/null
+++ b/.werks/1085
@@ -0,0 +1,19 @@
+Title: quicksearch: multiple hostname matches now lead to the searchhost view instead of the hosts view
+Level: 1
+Component: multisite
+Version: 1.2.5i5
+Date: 1405937822
+Class: feature
+
+When a quicksearch pattern matched multiple hosts the view hosts was shown.
+This view also displayed all services for these hosts, which could lead
+to plenty of (unwanted) output in the view.
+<br>
+The quicksearch feature has been changed in the following way<br>
+
+<ul>
+<li>If there are multiple host matches the searchhost view is displayed</li>
+<li>If there is a single match the hosts view is displayed (this view also contains the services)</li>
+</ul>
+
+Note: This also applies to special search patterns like <tt>h:localhost h:otherhost</tt>
diff --git a/ChangeLog b/ChangeLog
index a09e7ae..97e98c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,6 +66,7 @@
* 1033 New Mutisite filter for the number of services a host has...
* 0949 quicksearch: now able to search for multiple hosts at once...
* 1052 SEC: index start URL can not be used to redirect to absolute URLs anymore...
+ * 1085 quicksearch: multiple hostname matches now lead to the searchhost view instead of the hosts view...
* 0945 FIX: Sidebar snapin "Problem hosts": Now excludes hosts and services in downtime
* 1036 FIX: doc/treasures/downtime: fix --url option, better error output
* 1074 FIX: Fix Virtual Host Tree snapin...
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 13786b4..91ba1c1 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -769,7 +769,7 @@ def search_url_tmpl(used_filters, row, exact = True):
# Default search templates
ty = plugin.get("dftl_url_tmpl", plugin.get("id"))
if ty == 'hosts':
- return 'view.py?view_name=hosts&host=%(name)s'
+ return 'view.py?view_name=searchhost&host=%(name)s&filled_in=filter'
elif ty == 'hostgroups':
return 'view.py?view_name=hostgroups&hostgroup_name=%(name)s&site=%(site)s'
elif ty == 'servicegroups':