Appendix 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 Cosminexus HTTP Server activities when you want Cosminexus 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 Cosminexus 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 Cosminexus HTTP Server behavior. When a failure occurs in Cosminexus 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

(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 httpsd_monitor monitors whether the control process is running. The script does not monitor the behavior of the processes that handle requests.