Managing HP Serviceguard A.11.20.10 for Linux, December 2012

0 - indicating success.
1 - indicating the package will be halted, and should not be restarted, as a result of failure
in this script.
2 - indicating the package will be restarted on another node, or halted if no other node is
available.
NOTE: In the case of the validate entry point, exit values 1 and 2 are treated the same; you
can use either to indicate that validation failed.
The script can make use of a standard set of environment variables (including the package name,
SG_PACKAGE, and the name of the local node, SG_NODE) exported by the package manager or
the master control script that runs the package; and can also call a function to source in a logging
function and other utility functions. One of these functions, sg_source_pkg_env(), provides
access to all the parameters configured for this package, including package-specific environment
variables configured via the pev_ parameter (page 183).
NOTE: Some variables, including SG_PACKAGE, and SG_NODE, are available only at package
run and halt time, not when the package is validated. You can use SG_PACKAGE_NAME at validation
time as a substitute for SG_PACKAGE.
For more information, see the template in $SGCONF/examples/external_script.template.
A sample script follows. It assumes there is another script called monitor.sh, which will be
configured as a Serviceguard service to monitor some application. The monitor.sh script (not
included here) uses a parameter PEV_MONITORING_INTERVAL, defined in the package
configuration file, to periodically poll the application it wants to monitor; for example:
PEV_MONITORING_INTERVAL 60
At validation time, the sample script makes sure the PEV_MONITORING_INTERVAL and the
monitoring service are configured properly; at start and stop time it prints out the interval to the
log file.
#!/bin/sh
# Source utility functions.
if [[ -z $SG_UTILS ]]
then
. $SGCONF.conf
SG_UTILS=$SGCONF/scripts/mscripts/utils.sh
fi
if [[ -f ${SG_UTILS} ]]; then
. ${SG_UTILS}
if (( $? != 0 ))
then
echo "ERROR: Unable to source package utility functions file: ${SG_UTILS}"
exit 1
fi
else
echo "ERROR: Unable to find package utility functions file: ${SG_UTILS}"
exit 1
fi
# Get the environment for this package through utility function
# sg_source_pkg_env().
sg_source_pkg_env $*
function validate_command
{
typeset -i ret=0
typeset -i i=0
typeset -i found=0
# check PEV_ attribute is configured and within limits
if [[ -z PEV_MONITORING_INTERVAL ]]
then
sg_log 0 "ERROR: PEV_MONITORING_INTERVAL attribute not configured!"
ret=1
elif (( PEV_MONITORING_INTERVAL < 1 ))
then
sg_log 0 "ERROR: PEV_MONITORING_INTERVAL value ($PEV_MONITORING_INTERVAL) not within legal limits!"
ret=1
fi
# check monitoring service we are expecting for this package is configured
4.8 Package Configuration Planning 123