onsdag, januari 26, 2011

Using op5 (Nagios) for Beehive Monitoring

In addition to using Enterprise Manager we also use op5, a Nagios based monitoring software. So, naturally I wanted to be able to monitor some of the Beehive services using this tool as well as Enterprise Manger. What I initially wanted to know was basically if the OC4J containers in Beehive were up and running or not. As op5 uses the standard NRPE (Nagios Remote Plugin Executor) agent in order to perform the monitoring, the task wasn't that hard to accomplish.

The first (and basically only issue) was that I couldn't find and good NRPE plugins to use to perform the monitoring with. The standard check_procs plugin couldn't be used as I did not find any ways to distinguish between the different OC4J processes using this plugin. Well, this wasn't a big issue as you basically can use any given script as a NRPE plugin. So, I quickly created a script that would allow me to count the # of processes for the different OC4J containers, not the prettiest solution, but it does the job.

Here is the script:
#!/bin/bash

OK_PROCESSES="4"
PROC_NAME="BEEAPP"

while getopts "o:N:" optionName; do
case "${optionName}" in
"o") OK_PROCESSES="${OPTARG}";;
"N") PROC_NAME="${OPTARG}";;
esac
done

CURRENT_PROCESSES=`ps -ef | grep ${PROC_NAME} | grep -v bash | grep -v grep | wc -l`

if [[ ${CURRENT_PROCESSES} -eq ${OK_PROCESSES} ]]; then
echo "${PROC_NAME} OK: ${CURRENT_PROCESSES} processes"
exit 0
else
echo "${PROC_NAME} ERROR: incorrect number of processes: ${CURRENT_PROCESSES}"
exit 2
fi

Once the script was in place I could continue to configure op5 to use these lines for the monitoring:
command[bee_core]=/opt/plugins/check_beehive -o 2 -N BEECORE
command[bee_mgmt]=/opt/plugins/check_beehive -o 1 -N BEEMGMT
command[bee_app]=/opt/plugins/check_beehive -o 4 -N BEEAPP
command[bee_client]=/opt/plugins/check_beehive -o 4 -N BEECLIENT
command[bee_soa]=/opt/plugins/check_beehive -o 1 -N oc4j_soa


And finally I just had to add these commands as services in op5 (as check_nrpe services) and the monitoring was up & running.

Inga kommentarer:

Skicka en kommentar