Managing HP Serviceguard A.12.00.00 for Linux, June 2014

sg_log 0 "Unknown entry point $1"
;;
esac
exit $exit_val
4.9.11.1 Using Serviceguard Commands in an External Script
You can use Serviceguard commands (such as cmmodpkg) in an external script. These commands
must not interact with the package itself (that is, the package that runs the external script) but can
interact with other packages. But be careful how you code these interactions.
If a Serviceguard command interacts with another package, be careful to avoid command loops.
For instance, a command loop might occur under the following circumstances. Suppose a pkg1
script does a cmmodpkg -d of pkg2, and a pkg2 script does a cmmodpkg -d of pkg1. If both
pkg1 and pkg2 start at the same time, the pkg1 script now tries to cmmodpkg pkg2. But that
cmmodpkg command has to wait for pkg2 startup to complete. The pkg2 script tries to cmmodpkg
pkg1, but pkg2 has to wait for pkg1 startup to complete, thereby causing a command loop.
To avoid this situation, it is a good idea to specify a run_script_timeout and
halt_script_timeout for all packages, especially packages that use Serviceguard commands
in their external scripts. If a timeout is not specified and your package has a command loop as
described above, inconsistent results can occur, including a hung cluster.
NOTE: cmhalt operations interact with all the packages and should not be used from external
scripts.
4.9.11.2 Determining Why a Package Has Shut Down
You can use an external script to find out why a package has shut down.
Serviceguard sets the environment variable SG_HALT_REASON in the package control script to
one of the following values when the package halts:
failure - set if the package halts because of the failure of a subnet, resource, or service it
depends on
user_halt - set if the package is halted by a cmhaltpkg or cmhaltnode command, or
by corresponding actions in Serviceguard Manager
automatic_halt - set if the package is failed over automatically because of the failure of
a package it depends on, or is failed back to its primary node automatically
(failback_policy = automatic)
You can add custom code to the package to interrogate this variable, determine why the package
halted, and take appropriate action. For modular packages, put the code in the package’s external
script (see About External Scripts” (page 135)).
For example, if a database package is being halted by an administrator (SG_HALT_REASON set
to user_halt) you would probably want the custom code to perform an orderly shutdown of the
database; on the other hand, a forced shutdown might be needed if SG_HALT_REASON is set to
failure, indicating thatthe package is halting abnormally (for example, because of the
failure of a service it depends on).
4.9.11.2.1 last_halt_failed Flag
cmviewcl -v -f line displays a last_halt_failed flag.
NOTE: last_halt_failed appears only in the line output of cmviewcl, not the default
tabular format; you must use the -f line option to see it.
The value of last_halt_failed is no if the halt script ran successfully, or has not run since the
node joined the cluster, or has not run since the package was configured to run on the node;
otherwise it is yes.
138 Planning and Documenting an HA Cluster