Module: check_mk
Branch: master
Commit: 42d941fd67f382a306a3e1f82accd14fe61573ca
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42d941fd67f382…
Author: Marcel Schulte <ms(a)mathias-kettner.de>
Date: Thu Feb 2 15:16:48 2017 +0100
4123 FIX active check check_sql: changed handling of query results and fixed hostname
parameter
If the used SQL query results in only one column its value is shown in check output now.
Otherwise the second column of the result is used for check output.
Also, the hostname parameter has been fixed to prevent erros like this:
Error while connecting to database: [2005] Unknown MySQL server host
"10.11.12.13"
Change-Id: Icb8f3cd8b3c568150b4d8d358892edfc545189ac
---
.werks/4123 | 13 +++++++++++++
ChangeLog | 1 +
active_checks/check_sql | 7 ++++++-
checks/check_sql | 2 +-
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/4123 b/.werks/4123
new file mode 100644
index 0000000..4059b9a
--- /dev/null
+++ b/.werks/4123
@@ -0,0 +1,13 @@
+Title: active check check_sql: changed handling of query results and fixed hostname
parameter
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i4
+Date: 1486044551
+Class: fix
+
+If the used SQL query results in only one column its value is shown in check output now.
Otherwise the second column of the result is used for check output.
+
+Also, the hostname parameter has been fixed to prevent erros like this:
+
+Error while connecting to database: [2005] Unknown MySQL server host
"10.11.12.13"
diff --git a/ChangeLog b/ChangeLog
index a999094..86d940d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -88,6 +88,7 @@
NOTE: Please refer to the migration notes!
* 4335 FIX: perle check and inventory plugins: some updates and improvements...
NOTE: Please refer to the migration notes!
+ * 4123 FIX: active check check_sql: changed handling of query results and fixed
hostname parameter...
Multisite:
* 4169 View action: Default values of sticky, notification and persistent options can
now be configured via global settings....
diff --git a/active_checks/check_sql b/active_checks/check_sql
index f93a14f..e98e7bd 100755
--- a/active_checks/check_sql
+++ b/active_checks/check_sql
@@ -255,7 +255,12 @@ try:
sys.exit(3)
number = float(result[0])
- text = "%s %s" % (number, str(result[1]))
+
+ # handle case where sql query only results in one column
+ if len(result) == 1:
+ text = "%s" % result[0]
+ else:
+ text = "%s" % result[1]
try:
perf = " | performance_data=%s" % str(result[2])
diff --git a/checks/check_sql b/checks/check_sql
index b7d2cff..d674672 100644
--- a/checks/check_sql
+++ b/checks/check_sql
@@ -36,7 +36,7 @@
def check_sql_arguments(params):
args = []
- args += [ "--hostname='$HOSTADDRESS$'" ]
+ args += [ "--hostname=$HOSTADDRESS$" ]
args += [ "--dbms=%s" % params["dbms"] ]
args += [ "--name=%s" % params["name"] ]
args += [ "--user=%s" % params["user"] ]