Git Product home page Git Product logo

lausser / check_db2_health Goto Github PK

View Code? Open in Web Editor NEW
8.0 7.0 1.0 210 KB

A plugin (monitoring-plugin, not nagios-plugin, see also http://is.gd/PP1330) which checks various parameters of DB2 database servers. This plugin is also part of OMD, go to https://labs.consol.de/repo/, install OMD and there you have check_db2_health.

Home Page: https://omd.consol.de/docs/plugins/check_db2_health

License: GNU General Public License v2.0

Shell 12.87% Perl 81.16% Awk 0.83% Makefile 1.59% M4 3.47% Raku 0.07%
db2 icinga monitoring naemon nagios nagios-plugins

check_db2_health's Introduction

check_db2_health Nagios Plugin README
---------------------

This plugin is used to monitor a variety of db2 database metrics. 

* For instructions on installing this plugin for use with Nagios,
  see below. In addition, generic instructions for the GNU toolchain
  can be found in the INSTALL file.

* For major changes between releases, read the CHANGES file.

* For information on detailed changes that have been made,
  read the Changelog file.

* This plugin is self documenting.  All plugins that comply with
  the basic guidelines for development will provide detailed help when
  invoked with the '-h' or '--help' options.

You can check for the latest plugin at:
  http://www.consol.com/opensource/nagios/check-db2-health

The documentation in this README covers only the most common features.
To view the full documentation and examples, go to 
  http://www.consol.com/opensource/nagios/check-db2-health or
  http://www.consol.de/opensource/nagios/check-db2-health

Send mail to [email protected] for assistance.
Please include the OS type/version and the Perl DBI/DBD version
that you are using.
Also, run the plugin with the '-vvv' option and provide the resulting 
version information.  Of course, there may be additional diagnostic information
required as well.  Use good judgment.

For patch submissions and bug reports, please send me a mail. You can also find
me at http://www.nagios-portal.de




How to "compile" the check_db2_health script.
--------------------------------------------------------

1) Run the configure script to initialize variables and create a Makefile, etc.

	./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-statefiles-dir=STATE_PATH

   a) Replace BASEDIRECTORY with the path of the directory under which Nagios
      is installed (default is '/usr/local/nagios')
   b) Replace SOMEUSER with the name of a user on your system that will be
      assigned permissions to the installed plugins (default is 'nagios')
   c) Replace SOMEGRP with the name of a group on your system that will be
      assigned permissions to the installed plugins (default is 'nagios')
   d) Replace PATH_TO_PERL with the path where a perl binary can be found.
      Besides the system wide perl you might have installed a private perl
      just for the nagios plugins (default is the perl in your path).
   e) Replace STATE_PATH with the directory where you want the script to
      write state files which transport information from one run to the next.
      (default is /tmp)

   Simply running ./configure will be sufficient to create a check_db2_health
   script which you can customize later.
      

2) "Compile" the plugin with the following command:

	make

    This will produce a "check_db2_health" script. You will also find
    a "check_db2_health.pl" which you better ignore. It is the base for
    the compilation filled with placeholders. These will be replaced during
    the make process.


3) Install the compiled plugin script with the following command:

	make install

   The installation procedure will attempt to place the plugin in a 
   'libexec/' subdirectory in the base directory you specified with
   the --prefix argument to the configure script.


4) Verify that your configuration files for Nagios contains
   the correct paths to the new plugin.


Command line parameters
-----------------------

--connect=<the db2 connect string>
   This is what you would also use with tnsping and sqlplus.

--user=<username>
   This is the user which reads the system tables.

--password=<secret>
   This is the user's password.

--mode=<operation mode>
   This parameter tells the plugin what it should check.
   The list of known modes may grow frequently. Please look at 
   http://www.consol.com/opensource/nagios/check-db2-health for a list
   of features.

--tablespace=<tablespace name>
  Tablespace-related modes check all tablespaces in one run by default.
  If only a single tablespace should be checked, use this parameter.

--warning=<warning threshold>
  If the metric is out of this range, the plugin returns a warning.

--critical=<critical threshold>
  If the metric is out of this range, the plugin returns a critical.

   

How to prepare the database for monitoring
--------------------------------------

Database user:
[root@dbsrv12 ~]# groupadd nagios
[root@dbsrv12 ~]# useradd -g nagios -s /bin/false nagios 
[root@dbsrv12 ~]# passwd nagios

Grant sysmon authority:
db2inst1$ db2 update dbm cfg using sysmon_group nagios
db2inst1$ db2 grant select,update on table SYSTOOLS.STMG_DBSIZE_INFO to nagios

Switch on the performance counters:
db2 update dbm cfg using dft_mon_bufpool   on
db2 update dbm cfg using dft_mon_lock      on
db2 update dbm cfg using dft_mon_timestamp on

--------------------------------------
That's it.  If you have any problems or questions, feel free to send mail
to [email protected]

check_db2_health's People

Contributors

lausser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

angoca

check_db2_health's Issues

Hang on checking tablespace-usage

The script hang on checking tablespace-usage, i have debug it, here is the result:

main::(/usr/local/nagios/libexec/check_db2_health:3):
3:  my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );
  DB<1> b 2606
  DB<2> c
DBD::DB2::Server::Connection::Dbi::fetchall_array(/usr/local/nagios/libexec/check_db2_health:2606):
2606:       $sth = $self->{handle}->prepare($sql);
  DB<2> v
2603:     my $rows = undef;
2604:     eval {
2605:       $self->trace(sprintf "SQL:\n%s\n", $sql);
2606==>b        $sth = $self->{handle}->prepare($sql);
2607:       if (scalar(@arguments)) {
2608:         $self->trace(sprintf "ARGS:\n%s\n", Data::Dumper::Dumper(\@arguments));
2609:         $sth->execute(@arguments);
2610        } else {
2611:         $sth->execute();
2612        }
  DB<2> x $self->{handle}
0  DBI::db=HASH(0x1d14ae0)
     empty hash
  DB<3> n

Server environment

  • OS: Ubuntu 14.04.2 LTS 64bit
  • Database: DB2 Express 10.5

Client environment

  • OS: Ubuntu 14.04.2 LTS 64bit
  • dependencies: perl 5.18, DBD::DB2 1.85, IBM db2 dsdriver 10.5

DMS Tablespaces

Hello,

i have a large amount of DB2 tablespaces that are configured with:

Using automatic storage = No
Auto-resize enabled = Yes

In mode = dms-tablespace-free, all these tablespaces are still checked. I think theys should not be checked, becuase they are have auto-resize enabled.

next if ($params{mode} =~ /::dms::manual$/ && ($type ne 'dms' || $tbsp_using_auto_storage));

should be

next if ($params{mode} =~ /::dms::manual$/ && ($type ne 'dms' || $tbsp_using_auto_storage || $tbsp_auto_resize_enabled));

Regards,
Carsten

Issue with database-usage

First, thanks for writing this plugin. So far it seems very nice.

My nagios server is a linux box that I have a DB2instance installed on.
This is where check_db2_health is installed.
I am able to monitor the instance on this Linux box with check_db2_health with no issues.

Now my issue. I have a DB2 database(10.5) running on Windows 2008 R2.
I am trying to run the database-usage health check against the DB2 installed on the Windows server.

I get this:
nc9053113186:/usr/local/nagios/libexec # ./check_db2_health --hostname cognoslss --port 50000 --username Administrator --password XXXXX --database cognoscs -mode database-usage
CRITICAL - unable to aquire database info

I am able to connect to that database from the linux box using DB2 command line:
db2inst1@nc9053113186:/cognos/admin> db2 "catalog tcpip node cog remote cognoslss server 50000"
DB20000I The CATALOG TCPIP NODE command completed successfully.
DB21056W Directory changes may not be effective until the directory cache is
refreshed.
db2inst1@nc9053113186:
/cognos/admin> db2 "catalog database cognoscs at node cog"
DB20000I The CATALOG DATABASE command completed successfully.
DB21056W Directory changes may not be effective until the directory cache is
refreshed.
db2inst1@nc9053113186:~/cognos/admin> db2 attach to cog user Administrator using XXXXXX

Instance Attachment Information

Instance server = DB2/NT64 10.5.0
Authorization ID = ADMINIST...
Local instance alias = COG

db2inst1@nc9053113186:~/cognos/admin> db2 connect to cognoscs user Administrator using Hlk78tyu

Database Connection Information

Database server = DB2/NT64 10.5.0
SQL authorization ID = ADMINIST...
Local database alias = COGNOSCS

db2inst1@nc9053113186:~/cognos/admin>

So it sems that user can connect successfully.

I did run all the commands to enable monitoring on the windows DB2 server and they worked except:
C:\cognosadmin>db2 grant select,update on table SYSTOOLS.STMG_DBSIZE_INFO to Adm
inistrator
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "SYSTOOLS.STMG_DBSIZE_INFO" is an undefined name. SQLSTATE=42704

C:\cognosadmin>

Any idea what I am doing wrong here.
Thanks

Tom

Support for HADR

When using HADR, the scripts should be configured against both databases, but only one of them should reply. In the current state of this script, it is not suitable for a production environment with HA configuration. Only one database node could be configured in NAgios, and no takeover can be done silently.

Error: CRITICAL - cannot connect to XXXXXX. [IBM][CLI Driver]   SQL1776N  The command cannot be issued   on an HADR database. Reason code = "1". Command returned exit   status 2

Connection problem

Hi,

I just found your project, and it looks very interesting.

I suppose your project is a branch the original check_db2_health written in Perl.

I have also developed a project to monitor DB2 with several bash scripts (no Perl). However, I have a problem as the Perl project has, and it is the quantity of connections needed to retrieve the values.

For example, when you have a database with 10 bufferpools, 20 tablespaces, our projects need to establish 30 connections, because they do not keep the connection active.

That makes our projects very aggressive for the databases because there is a lot overhead while establishing connections. I thought about use a persistent connection.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.