Module: check_mk
Branch: master
Commit: 1f0723f5bb2573cf481ebc30eb7a3fe4867db16d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f0723f5bb2573…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Sep 30 11:53:09 2014 +0200
#1121 FIX Rule based notifications formular: No longer raises Request-Uri-Too-Large errors
If you wanted to create/edit a rule based notifcation and the formular itself had too much
configurable host tags, contact groups, etc. there was a problem on sending this formular to the server.
The data was sent with a GET request, which only allowed a limited url length.
This formular is now sent with a POST request.
---
.werks/1121 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 2 +-
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/.werks/1121 b/.werks/1121
new file mode 100644
index 0000000..0a7d70a
--- /dev/null
+++ b/.werks/1121
@@ -0,0 +1,12 @@
+Title: Rule based notifications formular: No longer raises Request-Uri-Too-Large errors
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.5i6
+Date: 1412070448
+Class: fix
+
+If you wanted to create/edit a rule based notifcation and the formular itself had too much
+configurable host tags, contact groups, etc. there was a problem on sending this formular to the server.
+The data was sent with a GET request, which only allowed a limited url length.
+This formular is now sent with a POST request.
diff --git a/ChangeLog b/ChangeLog
index 60164b4..f837830 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -129,6 +129,7 @@
* 1396 FIX: Fix default setting of Enable sounds in views...
* 1109 FIX: WATO active checks: passwords no longer shown as plain text....
* 1119 FIX: WATO create rule: No longer raises an incorrect permission warning when creating a new rule...
+ * 1121 FIX: Rule based notifications formular: No longer raises Request-Uri-Too-Large errors...
Notifications:
* 1151 Add variables (HOST/SERVICE)ACK(AUTHOR/COMMENT) to notification context...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 12088e8..ad72b8d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9105,7 +9105,7 @@ def mode_notification_rule(phase, profilemode):
return "notifications"
- html.begin_form("rule")
+ html.begin_form("rule", method = "POST")
vs.render_input("rule", rule)
vs.set_focus("rule")
forms.end()
Module: check_mk
Branch: master
Commit: 8cf6c82df14cfe477b663a4b99a3334b26c25081
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cf6c82df14cfe…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 30 08:26:00 2014 +0200
#1409 Extended Check_MK-API: check function may return None
A check function may now return <tt>None</tt> (or simply end without
returning anything). This will no longer create an exception but return
state <tt>UNKNOWN</tt> and - depending on the type of the check -
one of the following outputs:
<tt>Item not found in SNMP data</tt>
<tt>Item not found in agent output</tt>
This means that for the typical check that loops through the agent
output looking for its item now does not need to manually do a
C+:
return 3, "Something not found in agent output"
C-:
anymore. This is now the default case. This has several advantages:
<ul>
<li>You save some code in the check implementation.</li>
<li>The output of the various checks is unified.</li>
<li>A future Check_MK version can easily have a rule for changing the state
in such cases from UNKNOWN to WARN or CRIT.</li>
</ul>
---
.werks/1409 | 32 ++++++++++++++++++++++++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 21 +++++++++++++++++++--
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/.werks/1409 b/.werks/1409
new file mode 100644
index 0000000..d6ed902
--- /dev/null
+++ b/.werks/1409
@@ -0,0 +1,32 @@
+Title: Extended Check_MK-API: check function may return None
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1412058117
+Class: feature
+
+A check function may now return <tt>None</tt> (or simply end without
+returning anything). This will no longer create an exception but return
+state <tt>UNKNOWN</tt> and - depending on the type of the check -
+one of the following outputs:
+
+<tt>Item not found in SNMP data</tt>
+
+<tt>Item not found in agent output</tt>
+
+This means that for the typical check that loops through the agent
+output looking for its item now does not need to manually do a
+
+C+:
+ return 3, "Something not found in agent output"
+C-:
+
+anymore. This is now the default case. This has several advantages:
+
+<ul>
+<li>You save some code in the check implementation.</li>
+<li>The output of the various checks is unified.</li>
+<li>A future Check_MK version can easily have a rule for changing the state
+in such cases from UNKNOWN to WARN or CRIT.</li>
+</ul>
diff --git a/ChangeLog b/ChangeLog
index 60164b4..243060e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,7 @@
NOTE: Please refer to the migration notes!
* 1117 agent_vsphere: now able to query license information from esx system...
* 1118 bluecat_dns, bluecat_dhcp: no able to run as clustered checks...
+ * 1409 Extended Check_MK-API: check function may return None...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index dfa1d03..8ebd08e 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1131,15 +1131,23 @@ def convert_check_info():
snmp_scan_functions[basename] = info["snmp_scan_function"]
-def convert_check_result(result):
+def convert_check_result(result, is_snmp):
if type(result) == tuple:
return result
+ elif result == None:
+ return item_not_found(is_snmp)
+
# The check function may either return a tuple (pair or triple) or an iterator
# (using yield). The latter one is new since version 1.2.5i5.
else: # We assume an iterator, convert to tuple
subresults = list(result)
+ # Empty list? Check returned nothing
+ if not subresults:
+ return item_not_found(is_snmp)
+
+
# Simple check with no separate subchecks (yield wouldn't have been neccessary here!)
if len(subresults) == 1:
return subresults[0]
@@ -1166,6 +1174,13 @@ def convert_check_result(result):
return status, ", ".join(infotexts), perfdata
+def item_not_found(is_snmp):
+ if is_snmp:
+ return 3, "Item not found in SNMP data"
+ else:
+ return 3, "Item not found in agent output"
+
+
# Loops over all checks for a host, gets the data, calls the check
# function that examines that data and sends the result to Nagios
def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
@@ -1232,9 +1247,11 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
try:
dont_submit = False
+ is_snmp = check_info[checkname].get("snmp_info") or \
+ ( infotype in check_info and check_info[infotype].get("snmp_info"))
# Call the actual check function
- result = convert_check_result(check_function(item, params, info))
+ result = convert_check_result(check_function(item, params, info), is_snmp)
# handle check implementations that do not yet support the