Module: check_mk
Branch: master
Commit: 2f9e5107cb9b7702f92a399ccdb402b6aa07429c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2f9e5107cb9b77…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Nov 11 18:32:36 2013 +0100
check_sql: support for mssql databases included
---
.werks/68 | 8 ++++++++
ChangeLog | 1 +
checkman/check_sql | 4 ++--
doc/treasures/active_checks/check_sql | 24 +++++++++++++++---------
web/plugins/wato/active_checks.py | 3 ++-
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/.werks/68 b/.werks/68
new file mode 100644
index 0000000..b0bafb9
--- /dev/null
+++ b/.werks/68
@@ -0,0 +1,8 @@
+Title: check_sql: support for mssql databases included
+Level: 1
+Component: checks
+Version: 1.2.3i7
+Date: 1384191118
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 834def4..c68d710 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
* 0090 apc_ats_status: New Check for monitoring APC Automatic Transfer Switches
* 0080 Added new checks for Brocade NetIron MLX switching / routing devices...
* 0091 apc_ats_output: new check for output measurements on APC ATS devices
+ * 0068 check_sql: support for mssql databases included
* 0024 FIX: cisco_wlc: removed configuration parameter ap_model
* 0065 FIX: veeam_client: check behaviour improved when backup is in progress
* 0066 FIX: veeam_jobs: check behaviour improved when backup is in progress
diff --git a/checkman/check_sql b/checkman/check_sql
index 8591146..f969826 100644
--- a/checkman/check_sql
+++ b/checkman/check_sql
@@ -15,8 +15,8 @@ description:
Otherwise the number ist treated as a Nagios state (0,1,2,3).
State, text and the performance data are being returned.
- The check works with MySQL, Postgresql and Oracle databases using the
- python drivers MySQLdb, psycopg2 and cx_Oracle. For cx_Oracle the
+ The check works with MySQL, Postgresql, MSSQL and Oracle databases using the
+ python drivers MySQLdb, psycopg2, pymssqlm and cx_Oracle. For cx_Oracle the
Oracle instantclient needs to be installed as well, and the
LD_LIBRARY_PATH needs to be modified to point to the libclntsh.so of
that package.
diff --git a/doc/treasures/active_checks/check_sql
b/doc/treasures/active_checks/check_sql
index ac384d5..95a5464 100755
--- a/doc/treasures/active_checks/check_sql
+++ b/doc/treasures/active_checks/check_sql
@@ -48,7 +48,7 @@ OPTIONS:
-p PASS, --password PASS Password for database access
-d DBMS, --dbms DBMS Name of the database management system.
Default is 'postgres', other valid values are
- 'mysql' and 'oracle'
+ 'mysql', 'mssql' and 'oracle'
-H HOST, --hostname HOST Hostname or IP-Address where the database lives. Default
is '127.0.0.1'
-P PORT, --port PORT Port used to connect to the database
-n NAME, --name NAME Name of the database on the DBMS
@@ -162,6 +162,14 @@ try:
db_connection = db.connect(host=opt_hostname, port=opt_port, \
db=opt_name, user=opt_user, passwd=opt_password )
+ elif opt_dbms == "mssql":
+ import pymssql # mssql driver
+ db = pymssql
+ if opt_port == None:
+ opt_port=1433
+ db_connection = db.connect(host=opt_hostname+":"+opt_port, \
+ database=opt_name, user=opt_user, passwd=opt_password )
+
elif opt_dbms == "oracle":
sys.path.append('/usr/lib/python2.7/site-packages')
import cx_Oracle
@@ -197,10 +205,11 @@ try:
outvar = cursor.var(cx_Oracle.STRING)
#opt_input.append("outvar")
cursor.callproc(opt_sql, (outvar,))
- result = outvar.getvalue()
+ res = outvar.getvalue()
+ result = res[0].split(",")
else:
cursor.execute(opt_sql)
- result = cursor.fetchmany(2)
+ result = cursor.fetchone()
cursor.close()
db_connection.close()
@@ -227,14 +236,11 @@ try:
print "UNKNOWN - SQL statement/procedure returned no data"
sys.exit(3)
- #row = result[0]
- row = result[0].split(",")
- number = float(row[0])
- text = str(row[1])
+ number = float(result[0])
+ text = str(result[1])
try:
- perf = row[2]
- perf = "|"+row[2]
+ perf = "|"+str(result[2])
except IndexError:
if opt_debug:
raise
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 4b1ccb9..85e09d8 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -248,9 +248,10 @@ register_rule(group,
choices = [
( "mysql", _("MySQL") ),
( "postgres", _("PostgreSQL") ),
+ ( "mssql", _("MSSQL") ),
( "oracle", _("Oracle") ),
],
- default_value = "mysql",
+ default_value = "postgres",
),
),
( "port",