26.5 Understanding the Workings of Any In-house Applications

     

My application is called clockwatch . It has a single program startup routine, the program called clockwatch . It will spawn a child process and die. The child process will wake up periodically (every 10 seconds) and write an entry into a logfile ( /tmp/watchlog ). Should the administrator wish the logfile to be located in a different directory, e.g., in a directory shared between nodes, the new directory name can be specified as a command line argument to the startup program. The clockwatch child process will create a file in the same directory as the logfile called .watchpid ; this lists the process ID of the daemon process. The content of this file should be used to kill the daemon. The correct method for killing the daemon is to send the process a SIGUSR1 signal. This signal will be trapped, and an appropriate entry entered into the logfile. Any other method for shutting down the application is unsupported and could render the application unusable. Here are some screenshots from testing the application:

 

 root@hpeos001[charlesk] #  ./clockwatch  root@hpeos001[charlesk] # Starting Clockwatch ; logfile = /tmp/watchlog root@hpeos001[charlesk] # root@hpeos001[charlesk] #  tail -1f /tmp/watchlog &  [1]     6816 root@hpeos001[charlesk] # hpeos001 08/07/103 @ 17:03:49 root@hpeos001[charlesk] # hpeos001 08/07/103 @ 17:03:59 hpeos001 08/07/103 @ 17:04:09 root@hpeos001[charlesk] #  kill $(cat /tmp/.watchpid )  root@hpeos001[charlesk] #  kill %1  [1] + Terminated                  tail -1f /tmp/watchlog & root@hpeos001[charlesk] # root@hpeos001[charlesk] #  ll /tmp/.watchpid  -rw-rw-r--   1 root       sys              5 Aug  7 17:03 /tmp/.watchpid root@hpeos001[charlesk] #  ./clockwatch  /tmp/.watchpid : Old PID file exists. Unknown problem! Exiting. root@hpeos001[charlesk] # root@hpeos001[charlesk] #  rm /tmp/.watchpid  root@hpeos001[charlesk] #  ./clockwatch  Starting Clockwatch ; logfile = /tmp/watchlog root@hpeos001[charlesk] #  tail -1f /tmp/watchlog &  [1]     6832 root@hpeos001[charlesk] # hpeos001 08/07/103 @ 17:04:43 hpeos001 08/07/103 @ 17:04:53 hpeos001 08/07/103 @ 17:05:03 root@hpeos001[charlesk] #  kill -SIGUSR1 $(cat /tmp/.watchpid )  root@hpeos001[charlesk] # EXITING (hpeos001) 08/07/2003 @ 17:05:21 root@hpeos001[charlesk] #  ll /tmp/.watchpid  /tmp/.watchpid not found root@hpeos001[charlesk] #  ./clockwatch /var/adm  Starting Clockwatch ; logfile = /var/adm/watchlog root@hpeos001[charlesk] #  tail -1f /var/adm/watchlog  hpeos001 08/07/103 @ 17:05:55 hpeos001 08/07/103 @ 17:06:05 root@hpeos001[charlesk] #  kill -SIGUSR1 $(cat /var/adm/.watchpid )  root@hpeos001[charlesk] # root@hpeos001[charlesk] #  tail /var/adm/watchlog  hpeos001 08/07/103 @ 17:05:45 hpeos001 08/07/103 @ 17:05:55 hpeos001 08/07/103 @ 17:06:05 hpeos001 08/07/103 @ 17:06:15 EXITING (hpeos001) 08/07/2003 @ 17:06:20 

If you want to use clockwatch for testing purposes, I have included the source code in Appendix B. It is a C program, so to compile it, simply create a source file, e.g., clockwatch.c , and run make clockwatch . As we can see, clockwatch is like a typical application:

  • It has a startup routine.

  • The startup routine dies, leaving the daemon running.

  • A daemon runs in the background and responds to requests .

  • It has a particular shutdown sequence.

As such, we cannot use the clockwatch startup program as the SERVICE_CMD for Serviceguard because as soon as it spawns the daemon, it dies. Serviceguard thinks the application has failed, attempts any further shutdown commands, e.g., unmount filesystems, and so on, and then attempts to restart the application in an adoptive node. This is a classic example of requiring an application monitoring script. We need to create this ourselves . This application monitoring script will be our SERVICE_CMD . Let's look at the application monitoring script that I need to create for my application.



HP-UX CSE(c) Official Study Guide and Desk Reference
HP-UX CSE(c) Official Study Guide and Desk Reference
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 434

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net