diff --git a/doc/treasures/active_checks/check_sql b/doc/treasures/active_checks/check_sql index 846085e..d4ae70a 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' + 'db2', '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 @@ -141,6 +145,7 @@ except Exception, e: sys.exit(3) + # # database connection # @@ -154,6 +159,18 @@ try: db_connection = db.connect(host=opt_hostname, port=opt_port, \ database=opt_name, user=opt_user, password=opt_password ) + 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) + elif opt_dbms == "mysql": import MySQLdb # mysql driver db = MySQLdb @@ -226,7 +243,7 @@ except Exception, e: sys.exit(3) if opt_verbose: - sys.stderr.write("\nSQL Result:\n %s\n\n" % result) + sys.stderr.write("\nSQL Result:\n %s\n\n" % str(result)) # # processing of result