The zone script resource provides the ability to run commands or scripts to start, stop and probe an application within a zone. The zone script resource depends on the zone boot resource. The command or script names are passed to the zone script resource when the resource is registered and must meet with the following requirements.
The command or script must contain the fully qualified path within the zone.
The command or script must be executable by root.
The command or script must return one of the following return codes.
0 |
Successful completion |
>0 |
An error has occurred |
201 |
(Probe only) — An error has occurred that requires an immediate failover of the resource group |
>0 & !=201 |
(Probe only) — An error has occurred that requires a resource restart |
For an immediate failover of the zone script resource, you must configure the resource properties Failover_mode and Failover_enabled to meet the required behavior. Refer to the r_properties(5) man page when setting the Failover_mode property and SUNW.gds(5) man page when setting the Failover_enabled property.
This example shows a simple script to test that the Apache2 service is running, beyond the process tree existing. The script /var/tmp/probe-apache2 must exist and being executable within the zone.
# cat /var/tmp/probe-apache2 #!/usr/bin/ksh if echo "GET; exit" | mconnect -p 80 > /dev/null 2>&1 then exit 0 else exit 100 fi # chmod 755 /var/tmp/probe-apache2 |