Module: check_mk
Branch: master
Commit: b373a3dfa47111739d860da246d4f90d250706cc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b373a3dfa47111…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Oct 29 16:05:55 2013 +0100
FIX: handling of case of no input parameters and format of output variable
---
checks/check_sql | 6 +++---
doc/treasures/active_checks/check_sql | 20 +++++++++++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/checks/check_sql b/checks/check_sql
index 0ea56c9..b20932e 100644
--- a/checks/check_sql
+++ b/checks/check_sql
@@ -39,9 +39,9 @@ def check_sql_arguments(params):
args += " --port %s" % params["port"]
if "procedure" in params:
- if params["procedure"]["useprocs"] == True:
- args += " --procedure"
- if params["procedure"]["input"]:
+ if "procedure" in params and "useprocs" in
params["procedure"]:
+ args += " --procedure"
+ if "input" in params["procedure"]:
args += " --inputvars %s" \
%
quote_shell_string(params["procedure"]["input"])
diff --git a/doc/treasures/active_checks/check_sql
b/doc/treasures/active_checks/check_sql
index 021419f..0079c44 100755
--- a/doc/treasures/active_checks/check_sql
+++ b/doc/treasures/active_checks/check_sql
@@ -55,7 +55,7 @@ OPTIONS:
-w RANGE, --warning RANGE lower and upper level for the warning state, separated by
a colon
-c RANGE, --critical RANGE lower and upper level for the critical state, separated
by a colon
-o, --procedure treat the main argument as a procedure instead of an
SQL-Statement
- -i CSV, --inputvalues CSV values of input variables if required by the procedure;
csv-list
+ -i CSV, --inputvars CSV values of input variables if required by the procedure;
csv-list
--debug Debug mode: let Python exceptions come through
-v, --verbose Verbose mode: print SQL statement and levels
@@ -73,7 +73,7 @@ def saverfloat(f):
short_options = 'hou:i:p:d:n:H:P:w:c:v'
long_options = [
'help', 'user=', 'password=', 'dbms=',
'name=', 'warning=', 'critical=', 'hostname=',
- 'port=', 'debug', 'verbose', 'procedures',
'inputvars='
+ 'port=', 'debug', 'verbose', 'procedure',
'inputvars='
]
try:
@@ -92,7 +92,7 @@ opt_password = None
opt_hostname = "127.0.0.1"
opt_port = None
opt_sql = None
-opt_input = None
+opt_input = []
opt_procedure = False
warn = [ None, None ]
crit = [ None, None ]
@@ -121,7 +121,7 @@ try:
crit = map(saverfloat,a.split(":",2))
elif o in [ '-o', '--procedure' ]:
opt_procedure = True
- elif o in [ '-I', '--inputvalues' ]:
+ elif o in [ '-i', '--inputvars' ]:
opt_input = a.split(",")
elif o in [ '-h', '--help' ]:
usage()
@@ -220,16 +220,18 @@ if opt_verbose:
# processing of result
#
try:
- if len(result) > 1:
- print "UNKNOWN - SQL statement/procedure returned more than one line"
- sys.exit(3)
- elif len(result) == 0:
+ #if len(result) > 1:
+ # print "UNKNOWN - SQL statement/procedure returned more than one line"
+ # sys.exit(3)
+ if len(result) == 0:
print "UNKNOWN - SQL statement/procedure returned no data"
sys.exit(3)
- row = result[0]
+ #row = result[0]
+ row = result.split(" ")
number = float(row[0])
text = str(row[1])
+
try:
perf = row[2]
except IndexError: