Appendix E.3 Creating a monitoring script

When you want Cosminexus HTTP Server to be monitored by HACMP for AIX, you need to create a script that monitors Cosminexus HTTP Server and store it in the monitor method. This script must return 0 when Cosminexus HTTP Server is working normally and return a value other than zero when a problem is detected.

In Cosminexus HTTP Server, the execution command differs from the process that actually provides services. For the server to be monitored by HACMP for AIX, create a script that can actually monitor the process.

However, if the server is not monitored, or operation is only within the local node, you do not need to create scripts.

The following example shows how to write a shell script for monitoring Cosminexus HTTP Server behavior. The sample script returns 0 when Cosminexus HTTP Server is working normally, and returns a value other than zero when a problem is detected.

(Example)
The script returns 0 if a process ID stored in the file specified with the PidFile directive is running, and returns 1 if it is not running.

#!/bin/sh


HWSIDFILE=/opt/hitachi/httpsd/logs/httpd.pid
if [ ! -e $HWSIDFILE ]
then
       exit 1
fi

HWSID=`cat $HWSIDFILE`
if [ x$HWSID = "x" ]
then
       exit 1
fi

STATUS=`ps -p $HWSID | grep $HWSID | awk '{print $1}'`

if [ x$STATUS = "x" ]
then
       exit 1
else
       exit 0
fi

Organization of this subsection
(1) Notes

(1) Notes

Cosminexus HTTP Server provides a process that controls a group of processes that handle requests (see 4.1 Relationship between processes and directives of Cosminexus HTTP Server). In the example above, the script monitors whether the control process is running. The script does not monitor the behavior of the processes that handle requests.