To test an action script, do the following:
Create an input file, such as /tmp/input, that contains expected resource names. For example, to create a file that contains the resource named disk1 do the following:
# echo "/disk1" > /tmp/input |
Create an input parameter file, such as /tmp/ipparamfile, as follows:
# echo "ClusterName web-cluster" > /tmp/ipparamfile |
Execute the action script as follows:
# ./start /tmp/input /tmp/output /tmp/ipparamfile |
Note: The use of the input parameter file is optional.
Change the log level from HA_NORMLVL to HA_DBGLVL to allow messages written with HA_DBGLOG to be printed by adding the following line after the set_global_variables statement in your script:
HA_CURRENT_LOGLEVEL=$HA_DBGLVL |
The output file will contain one of the following return values for the start, stop, monitor, and restart scripts:
HA_SUCCESS=0 HA_INVAL_ARGS=1 HA_CMD_FAILED=2 HA_NOTSUPPORTED=3 HA_NOCFGINFO=4 |
The output file will contain one of the following return values for the exclusive script:
HA_NOT_RUNNING=0 HA_RUNNING=2 |
Note: If you call the exit_script function prior to normal termination, it should be preceded by the ha_write_status_for_resource function and you should use the same return code that is logged to the output file.
Suppose you have a resource named /disk1 and the following files:
The syntax for the input file is: <resourcename>
The syntax for the output file is: <resourcename> <status>
The following example shows:
The exit status of the action script is 1
The exit status of the resource is 2
Note: The use of anonymous indicates that the script was run manually. When the script is run by Linux FailSafe, the full path to the script name is displayed.
# echo "/disk1" > /tmp/ipfile
# ./monitor /tmp/ipfile /tmp/opfile /tmp/ipparamfile
# echo $?
2
# cat /tmp/opfile
/disk1 2
# tail /var/log/failsafe/script_heb1
Tue Aug 25 11:32:57.437 <anonymous script 23787:0 Unknown:0> ./monitor:
./monitor called with /tmp/ipfile and /tmp/opfile
Tue Aug 25 11:32:58.118 <anonymous script 24556:0 Unknown:0> ./monitor:
check to see if /disk1 is mounted on /disk1
Tue Aug 25 11:32:58.433 <anonymous script 23811:0 Unknown:0> ./monitor:
/bin/mount | grep /disk1 | grep /disk1 >> /dev/null 2>&1 exited with
status 0
Tue Aug 25 11:32:58.665 <anonymous script 24124:0 Unknown:0> ./monitor:
stat mount point /disk1
Tue Aug 25 11:32:58.969 <anonymous script 23525:0 Unknown:0> ./monitor:
/bin/stat /disk1 exited with status 0
Tue Aug 25 11:32:59.258 <anonymous script 24431:0 Unknown:0> ./monitor:
check the filesystem /disk1 is exported
Tue Aug 25 11:32:59.610 <anonymous script 6982:0 Unknown:0> ./monitor:
Tue Aug 25 11:32:59.917 <anonymous script 24040:0 Unknown:0> ./monitor:
awk '{print \$1}' /var/run/failasafe/tmp/exportfs.23762 | grep /disk1 exited
with status 1
Tue Aug 25 11:33:00.131 <anonymous script 24418:0 Unknown:0> ./monitor:
echo failed to find /disk1 in exported filesystem list:-
Tue Aug 25 11:33:00.340 <anonymous script 24236:0 Unknown:0> ./monitor:
echo /disk2 |
For additional information about a script's processing, see the /var/log/failsafe/script_nodename.