Monitor Oracle Cloud with Nagios
Published on: Author: Bouke Weinans Category: OracleFor 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:
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:
IF [ `ps -ef |grep '9000:localhost:5666 nagios@DBaaSserver' |grep -v grep|wc -l` -eq 0 ]; THEN ssh -t -t -i /home/nagios/.ssh/id_dsa -L 9000:localhost:5666 nagios@DBaaSserver 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:
[nagios@nagios ~]$ /usr/LOCAL/nagios/libexec/check_nrpe -H localhost -p 9000 NRPE v2.15 [nagios@nagios ~]$
To make it a bit easier for us, we then created a new command in the command.cfg:
# DBAAS NRPE command define command{ command_name check_dbaas_nrpe command_line $USER1$/check_nrpe -H localhost -p 9000 -c $ARG1$ }
This way we can simply define a service and use it in our configuration:
define service{ use local-service host_name DBAAS service_description U02 Disk check_command check_dbaas_nrpe!check_u02 }
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.