Hitachi

uCosminexus Application Server HTTP Server User Guide


D.3 Creating a monitoring script

In MC/ServiceGuard, to enable software to be monitored, the execution command must be the same as the actual service name, and that process must be running until the service ends.

In HTTP Server, the execution commands differ from the processes that actually provides services. For a server to be monitored by MC/ServiceGuard, create a script that can actually monitor the processes.

However, if a server is not monitored, or operation is only within the local node where no process will fail over to another node, you do not need to create scripts.

The following example shows how to write a shell script for monitoring HTTP Server behavior. When a failure occurs in HTTP Server, the shell script stops the process, and terminates its execution at the same time.

(Example)

The shell script httpsd_monitor monitors the process IDs stored in the file specified with the PidFile directive, and every five seconds checks whether the process is running. Specify the PidFile directive value in the form of an absolute path as an argument.

#!/bin/sh
HWSITIME=5  
if [ $# -ne 1 ]
then
    exit 1
fi
 
HWSIDFILE=$1
 
if [ ! -e $HWSIDFILE ] 
then
    exit 1
fi
 
HWSID=`cat $HWSIDFILE`
if [ x$HWSID = "x" ]
then
    exit 1
fi
 
while true
do
   STATUS=`ps -p $HWSID | grep $HWSID | awk '{print $1}' `
   if [ x$STATUS = "x" ] 
   then
     break
   fi
   sleep $HWSITIME 
done
 
exit 0
Organization of this subsection

(1) Notes

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