Module: check_mk
Branch: master
Commit: d9016eb92f8826d2c65a652eda1cab690dbc846f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9016eb92f8826…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 9 14:17:13 2014 +0100
#1734 check_sql: Added support for DB2 (thanks to Troels Arvin)
---
.werks/1734 | 9 +++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_sql | 19 ++++++++++++++++++-
web/plugins/wato/active_checks.py | 9 +++++----
4 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/.werks/1734 b/.werks/1734
new file mode 100644
index 0000000..c70c517
--- /dev/null
+++ b/.werks/1734
@@ -0,0 +1,9 @@
+Title: check_sql: Added support for DB2 (thanks to Troels Arvin)
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1418130932
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index effd197..0a08068 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -64,6 +64,7 @@
* 1684 cisco_vpn_tunnel: Now supporting VPN 3000 Conncentrator devices
* 1685 enterasys_*: Now supporting device C2G124-48 (Rev 05.02.18.0002)
* 1694 cisco_wlc/cisco_wlc_clients: Added support for Cisco AIR-CT2504-K9
+ * 1734 check_sql: Added support for DB2 (thanks to Troels Arvin)
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support
it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors,
dell_om_sensors: detect more devices...
diff --git a/doc/treasures/active_checks/check_sql
b/doc/treasures/active_checks/check_sql
index 51b7aa3..c2aa87a 100755
--- a/doc/treasures/active_checks/check_sql
+++ b/doc/treasures/active_checks/check_sql
@@ -24,6 +24,10 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# DB2 support requires installation of the IBM Data Server Client:
+#
http://www-01.ibm.com/support/docview.wss?uid=swg27016878
+# as well as the ibm_db2 Python DBI driver for DB2:
+#
https://pypi.python.org/pypi/ibm_db
import sys, getopt
@@ -48,7 +52,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', 'mssql' and 'oracle'
+ 'mysql', 'mssql', 'oracle' and
'db2'
-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
@@ -179,6 +183,19 @@ try:
opt_port=1521
cstring =
opt_user+"/"+opt_password+"@"+opt_hostname+":"+str(opt_port)+"/"+opt_name
db_connection = db.connect(cstring)
+
+ elif opt_dbms == "db2":
+ import ibm_db # IBM data server driver
+ import ibm_db_dbi
+ db = ibm_db
+ if opt_port == None:
+ opt_port=50000
+ cstring = 'DRIVER={IBM DB2 ODBC DRIVER};DATABASE='+opt_name+ \
+
';HOSTNAME='+opt_hostname+';PORT='+str(opt_port)+';PROTOCOL=TCPIP;'+
\
+ 'UID='+opt_user+';PWD='+opt_password+';'
+ ibm_db_conn = db.connect(cstring,'','')
+ db_connection = ibm_db_dbi.Connection(ibm_db_conn)
+
else:
print "UNKNOWN - dbms not found"
sys.exit(3)
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 1b5497b..31083e7 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -256,10 +256,11 @@ register_rule(group,
DropdownChoice(
title = _("Type of Database"),
choices = [
- ( "mysql", _("MySQL") ),
- ( "postgres", _("PostgreSQL") ),
- ( "mssql", _("MSSQL") ),
- ( "oracle", _("Oracle") ),
+ ("mysql", _("MySQL")),
+ ("postgres", _("PostgreSQL")),
+ ("mssql", _("MSSQL")),
+ ("oracle", _("Oracle")),
+ ("db2", _("DB2")),
],
default_value = "postgres",
),