Nagios: Monitor IBM DB2 database

Nagios: Monitor IBM DB2 database

Nagios: Monitor IBM DB2 database 150 150 Roderick Derks

Install perl DBI module

# perl -MCPAN -e 'install DBI'

Install the Application Development Client to be able to compile DBB:DB2 perl modules. Download it here:
http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg21256079

To Install the DB2 Application Development Client you need the library libstdc++.so.5. On my Centos 5.5 installation it was missing. I installed it like this:

# rpm -q --whatprovides libstdc++.so.5 # yum -y install compat-libstdc++-33.i386 # find /usr/ -name libstdc++* 

Download the correct DB2 "Dataserver Runtime Client" and store it in /tmp, I used v9.7:
http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217

To Install the DB2 Runtime Client you need the library libaio.so.1. On my Centos 5.5 installation it was missing. I installed it like this:

# rpm -q --whatprovides libaio.so.1 no package provides libaio.so.1 # yum -y install libaio.x86_64 # find /usr/lib64 -name libaio* # /usr/lib64/libaio.so.1
# cd /tmp # tar xvzf ibm_data_server_runtime_client_linuxx64_v97.tar.gz # cd rtcl # ./db2_install 

After the installation is finished succesfully you'll see this:

db2_install program completed successfully. 

Set environmental variable DB2_HOME:

# export DB2_HOME=/opt/IBM/db2/V9.7

Configure the DB2 Client. This step is needed to prevent error messages like:
SQL10007N Message "-1390" could not be retrieved.  Reason code: "3"
when trying to start /opt/ibm/db2/V9.7/bin/db2

# groupadd db2grp1 # groupadd db2fgrp1 # groupadd dasadm1 # useradd -g db2grp1  -m -d /home/db2inst1 db2inst1 # useradd -g db2fgrp1 -m -d /home/db2fenc1 db2fenc1 # useradd -g dasadm1  -m -d /home/dasusr1 dasusr1  # /opt/ibm/db2/V9.7/instance/db2icrt db2inst1 

Install perl DDB::DB2 module. Download the modules here: http://httpupdate37.cpanel.net/CPAN/authors/id/I/IB/IBMTORDB2/DBD-DB2-1.81.tar.gz

# cd /tmp # tar zvxf DBD-DB2-1.81.tar.gz # cd DBD-DB2-1.81 # perl Makefile.PL # make # make test # make install 

Wow, now we can connect to the database.

Get the Nagios plugin:

# cd /tmp # wget http://labs.consol.de/wp-content/uploads/2010/12/check_db2_health-1.0.3.tar.gz # tar xvzf check_db2_health-1.0.3.tar.gz # cd check_db2_health-1.0.3 # ./configure # make # make install 

Now the script is installed in the default Nagios libexec directory:

# ls /usr/local/nagios/libexec/check_db2_health 

Set the environmental setting so the library is found:

# LD_LIBRARY_PATH=/opt/ibm/db2/V9.7/lib64 

Check the database:

# check_db2_health --username=root --password=******* --hostname vcenter.r71.nl --mode=connection-time 

Make sure the database accepts connections. Login to the vCenter server using ssh and execute the following commands:

# /opt/db2/v9.7.2/adm/db2set DB2COMM=tcpip # /opt/db2/v9.7.2/bin/db2 update dbm cfg using svcename  # /opt/db2/v9.7.2/bin/db2  db2 => LIST ACTIVE DATABASES                             Active Databases  Database name                              = VCDB Applications connected currently           = 15 Database path                              = /storage/db/db2/home/db2inst1/db2inst1/NODE0000/SQL00001/

Beschikbare users:

db2 => GET CONTACTS    Name                           Type       Address                        Max Page Length  Description   ------------------------------ ---------- ------------------------------ ---------------- ------------------------------   db2inst1                       EMAIL      db2inst1@localhost                              Contact added by DB2 Setup Wizard

Login op linux als user db2inst1

~> su - db2inst1 ~> db2set DB2COMM=tcpip ~> db2 update dbm cfg using agentpri system ~> db2 force applications all ~> dbstop ~> dbstart  

Problem: when trying to connect the client to the database I get a Segmentation fault error. I'm having trouble solving this issue… Ideas are welcome!

Roderick Derks

Liefhebber van fietsen, van het oplossen van IT puzzels, en van het delen van informatie om anderen te helpen.

All stories by:Roderick Derks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Your Name (required)

    Your Email (required)

    Subject

    Your Message

      Your Name (required)

      Your Email (required)

      Subject

      Your Message