C.3 Creating monitoring commands
In HA monitor, a program needs to be registered that notifies HA monitor of failures of a server that does not have an interface with HA monitor. Therefore, you need to create commands to monitor HTTP Server activities when you want HTTP Server to be monitored even though it does not have interface with HA monitor. You do not need to create such commands if the server is not to be monitored.
In HTTP Server, the execution commands differ from the processes that actually provides services. For a server to be monitored by HA monitor, define commands that can actually monitor the processes.
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 processes are running.
#!/bin/sh
###############################################################
### ALL RIGHTS RESERVED. COPYRIGHT (C) 2000, 2002, HITACHI,LTD.
###############################################################
HWSIDFILE=/opt/hitachi/httpsd/logs/httpd.pid
HWSITIME=5
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.