HP manual Using Serviceguard Commands in an External Script

Models: Serviceguard

1 407
Download 407 pages 39.81 Kb
Page 153
Image 153

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 while (( i < ${#SG_SERVICE_NAME[*]} ))

do

case ${SG_SERVICE_CMD[i]} in *monitor.sh*) # found our script

found=1 break

;;

*)

;;

esac

(( i = i + 1 ))

done

if (( found == 0 )) then

sg_log 0 "ERROR: monitoring service not configured!" ret=1

fi

if (( ret == 1 )) then

sg_log 0 "Script validation for $SG_PACKAGE_NAME failed!"

fi

return $ret

}

function start_command

{

sg_log 5 "start_command"

#log current PEV_MONITORING_INTERVAL value, PEV_ attribute can be changed

#while the package is running

sg_log 0 "PEV_MONITORING_INTERVAL for $SG_PACKAGE_NAME is $PEV_MONITORING_INTERVAL" return 0

}

function stop_command

{

sg_log 5 "stop_command"

#log current PEV_MONITORING_INTERVAL value, PEV_ attribute can be changed

#while the package is running

sg_log 0 "PEV_MONITORING_INTERVAL for $SG_PACKAGE_NAME is $PEV_MONITORING_INTERVAL" return 0

}

typeset -i exit_val=0 case ${1} in

start)

start_command $* exit_val=$?

;;

stop)

stop_command $* exit_val=$?

;;

validate) validate_command $* exit_val=$?

;;

*)

sg_log 0 "Unknown entry point $1"

;;

esac

exit $exit_val

Using Serviceguard Commands in an External Script

You can use Serviceguard commands (such as cmmodpkg) in an external script run from a package. These commands must not interact with that 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 script run by pkg1 does a cmmodpkg -dof pkg2, and a script run by pkg2 does a cmmodpkg -dof 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 (page 236) for all packages, especially packages that use Serviceguard

Package Configuration Planning 153

Page 153
Image 153
HP manual Using Serviceguard Commands in an External Script