Monitor Oracle Cloud with Nagios

Monitor Oracle Cloud with Nagios

Published on: Category: Oracle

For a while now we have been testing Oracle DBaaS. For it to be a useful product in the future, it should be monitored as well. During this testing period, we looked at OEM and other products. Let’s have a quick look at how we managed to monitor our DBaaS instance with Nagios.

First of all, we installed the Nagios and NRPE plugins. This works exactly like you would normally install them.

Setup SHH tunnel

The DBaaS does not allow traffic over the default NRPE port (5666), so we needed to tunnel it using SSH. To get this going, we added the public key of the nagios user to the authorized_keys of the DBaaS server. Then you can setup the SSH tunnel with the following command:

  1. ssh -L 9000:localhost:5666 nagios@DBaaSserver

Because this process would eventually just die or with a reboot wouldn’t come back again, we made a small script that is run every minute from the crontab:

  1. IF [ `ps -ef |grep '9000:localhost:5666 nagios@DBaaSserver' |grep -v grep|wc -l` -eq 0 ]; THEN
  2. ssh -t -t -i /home/nagios/.ssh/id_dsa -L 9000:localhost:5666 nagios@DBaaSserver
  3. fi

Process? Check!

This simple script checks if there is a process and if it can’t find any, it starts a new one. As it is started from the crontab, it needs the -t -t  option to force pseudo-tty because there is no terminal and the -i to tell it which key it needs to authenticate with.

Connect: DBaaS server

Now we are able to connect to the DBaaS server and check any NRPE checks we want. Only thing that is different is that due to the SSH tunnel, you do not connect to the server itself,  but to the localhost on the earlier defined port 9000 instead of 5666:

  1. [nagios@nagios ~]$ /usr/LOCAL/nagios/libexec/check_nrpe -H localhost -p 9000
  2. NRPE v2.15
  3. [nagios@nagios ~]$

To make it a bit easier for us, we then created a new command in the command.cfg:

  1. # DBAAS NRPE command
  2. define command{
  3. command_name    check_dbaas_nrpe
  4.   command_line    $USER1$/check_nrpe -H localhost -p 9000 -c $ARG1$
  5.     }

This way we can simply define a service and use it in our configuration:

  1. define service{
  2. use                             local-service
  3. host_name                       DBAAS
  4. service_description             U02 Disk
  5. check_command                   check_dbaas_nrpe!check_u02
  6. }

And now… business as usual!

From here on, it is business as usual to configure all the checks you would like to do on the host which you would normally use NRPE for.

Bouke Weinans
About the author Bouke Weinans

More posts by Bouke Weinans