Execute DB2 Profile before check_db2_health script

In DB2 the standard plugin used is check_db2_health of consule labs.
Our scenario:

We have 10 - 12 DBs instance on same server. Each instance may be on different version. Since the current plugin uses DBI connection and DB2:DBI library need to be compiled for specific version of DB2 this becomes roadblock when DB2 has multiple version in the same server.

So long history short what we want to do is :slight_smile:

Option 1:

  1. Capture the DB instance passed
  2. Execute the DB2 Profile for that instance - somehow in the command (but db2profile is instance specific - icinga user can execute it (Linux)) - how to dynamically build command based on different db2profile
  3. Then execute the check_db_health

Option 2
Or
Possibly in the command itself execute the script as the instance owner but again dynamically capture instance owner.
Give sudo permission to command for icinga user

sudo -u $instance$ -c “check_db2_health”

The instance should be dynamic for each DB instance passed by argument from the service.

All configuration done in Director

Regards

Hi,

in such situation I would build a wrapper script . Depending on passed arguments you load the profile and after you run the check.

you could create a second command which has a executeable /usr/bin/sudo
and inherit all from check_db2_health (no position set on check_db2_health command)

as a first argument -u $instance (position 1)
as a second argument -c check_db2_health (position 2)
and add /usr/bin/sudo -u real-instanceuser in sudoers file for nagios user