Top
PRIMECLUSTER  Installation and Administration Guide 4.5
FUJITSU Software

6.11.2 Notes When Creating Scripts

This section describes notes when creating scripts.

6.11.2.1 start and stop Scripts

6.11.2.1.1 Examples of start and stop Scripts

Examples of the Start and Stop scripts other than Hot-standby operation are as follows.
The script $FULL_PATH/script.sample is an example when the following operations and settings are assumed.

[Setting]
[Attribute]
[Operation]

Below is an example when assuming the operation is the same for standby and operational systems by following "Table 6.3 The Cmdline resource in other than Hot-standby operation." The same processing is executed in the lines where Start script is described. The same processing is also executed in the lines where Stop script is described.

When assuming operations other than the above, refer to the environment variable and attribute to change them.

Figure 6.5 Start script and Stop script other than Hot-standby operation

Moreover, below is an example when assuming that the operation of the following sample $FULL_PATH/Script is corresponding Hot-standby operation.

[Setting]
[Attribute]
[Operation]

Below is an example of the Start script when the status is transited from Offline to Standby and also from Offline to Online. The transitions are distinguished as "Table 6.4 The Cmdline resource in Hot-standby operation."
In addition to that, another example that the Stop script distinguishes when the status is transited from Standby to Offline and also from Online to Offline is as follows.

When assuming operations other than the above, refer to the environment variable and attribute to change them.

Figure 6.6 Start script and Stop scripts with Hot-standby operation

6.11.2.1.2 Environment Variables can be referred to within the Start and Stop Scripts

When executing the Start script and Stop script, the following environment variables are set. You can refer to those environment variables within the scripts.
Table 3.4 indicates the environment variables set in the scripts.


Table 6.5 Environment variables can be referred to within the Start and Stop scripts

Environment variables

Outline

HV_APPLICATION

This variable sets the userApplication name that the resource belongs to.

Example) app1

HV_AUTORECOVER

The value of this variable indicates whether the script is triggered by

AutoRecover or not.

0: Not triggered by AutoRecover that is executed with the Online processing
1: Triggered by AutoRecover

HV_FORCED_REQUEST

This variable sets a value that indicates whether or not forced failover was requested by operator intervention.

0: Forced failover was not requested.
1: Forced failover was requested.

HV_NODENAME

This variable sets the resource name.

Example) ManageProgram000_Cmd_APP1, RunScriptsAlways000_Cmd_APP1

HV_OFFLINE_REASON

This variable sets the trigger for bringing the resource Offline.

SWITCH: The resource was set to Offline because of a userApplication switchover request (hvswitch)
STOP: The resource was set to Offline because of a userApplication stop request (hvutil -f)
FAULT: The resource was set to Offline because of a resource fault.
DEACT: The resource was set to Offline because of a userApplication deactivate request (hvutil -d)
SHUT: The resource was set to Offline because of an RMS stop request (hvshut)

HV_SCRIPT_TYPE

This variable sets the type of script that was executed.

Online: Online script
Offline: Offline script

HV_LAST_DET_REPORT

This variable sets the state of the current resources just before execution of the Start/Stop script.

Online: Online state
Offline: Offline state
Standby: Standby state
Faulted: Faulted state

HV_INTENDED_STATE

This variable sets the resource state that is expected after state transition is completed.

Online: Online state
Offline: Offline state
Standby: Standby state
Faulted: Faulted state
Warning: Warning state

NODE_SCRIPTS_TIME_OUT

This variable sets the timeout duration (seconds) of the script.

Example) 300

RMS has other environment variables.

See

  • For details on the RMS environment variables, see "Appendix E Environment variables" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."

6.11.2.1.3 Exit Code of Start and Stop Scripts

The state transition operation of a userApplication varies depending on the exit code of the Start and Stop script: Below indicates the operations of the exit code and the state transition.

0: Normal exit

The system assumes that the state transition of the Cmdline resource was processed normally, and state transition processing of the userApplication continues. If all the resources of the userApplication are processed normally, the state transition of the

userApplication is also processed normally

Other than 0: Abnormal exit

The system assumes that an error occurred during the state transition of the Cmdline resources and interrupts state transition processing of the userApplication.

6.11.2.1.4 Notes When Setting the NULLDETECTOR Flag

RMS does not monitor the state of the Cmdline resource when the NULLDETECTOR flag is enabled. In this case, Online script may be executed when the resource is already started or Offline script may be executed when the resource is already stopped. To prevent Online or Offline processing to be terminated with error, be sure to add following tasks to Online script and Offline script of the Cmdline resource when the NULLDETECTOR flag is enabled.

Note

If the userApplication state before the maintenance mode is started is Online, the Online script of Cmdline resource where the NULLDETECTOR flag is set is executed.

6.11.2.1.5 Timeout of Scripts

If the Start or Stop script processing is not completed within the specified time, a timeout occurs. Then, the script processing is interrupted by the SIGTERM signal and state transition ends with an error.
The timeout value can be specified with the TIMEOUT flag value of the Cmdline resources. The default value is 300 seconds.

When creating the Cmdline resource, you need to calculate the maximum processing time for each script and set a value with enough time. If a timeout occurs when the Cmdline resource is used (any one of the following messages is output: (DET, 5), (DET, 6), or (DET, 24)), change the timeout value to an appropriate value according to each operating system being used.

Select "Application-Edit" from the Main configuration menu to change the Flag of the Cmdline resource.
For details, see "10.3 Changing a Cluster Application."

Note

The processing time for each script needs to be shorter than the TIMEOUT attribute value of attribute that users have set.
If the processing time of scripts exceeds the TIMEOUT attribute value, PRIMECLUSTER determines it is a resource error and stop the startup and stop processings.

6.11.2.2 Check Script

6.11.2.2.1 Example of the Check Script

An example of the Check script other than Hot-standby operation indicates as follows.
The following example assumes that the setting has already described in 6.11.2.1.1 Examples of start and stop Scripts."


Figure 6.7 The Check script other than Hot-standby operation

If performing Hot-standby operation in the Cmdline resource, describe the Check script, which is similar to the start and stop scripts, corresponding to Hot-standby operation

Below is an example of the Check script corresponding to Hot-standby operation.
The following example assumes that the setting has already described in 6.11.2.1.1 Examples of start and stop Scripts."


Figure 6.8 The Check script with Hot-standby operation

6.11.2.2.2 Environment Variables that can be referred to within the Check Scripts

The following environment variables are set when executing the Check script. These environment variables can be referred to within the script.

See

For outlines on these environment variables, see "Table 6.5 Environment variables that can be referred to within the Start and Stop scripts."

And, for details on the RMS environment variables, see "Appendix E Environment variables" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."

6.11.2.2.3 Check Script Exit Code

The exit codes of the Check script vary depending on whether performing Hot-standby operation or not.

Not performing Hot-standby operation

Use any one of the following exit codes.

Table 6.6 The exit codes other than Hot-standby operation

Exit code

Meaning

0

Online state. If a target to be monitored has started, use this exit code.

Other than 0

Offline state. If a target to be monitored has stopped, use an exit code other than 0. If it completes in Offline after it has become Online, a switchover is performed.

Performing Hot-standby operation

Use any one of the following exit codes.

Table 6.7 The exit codes for Hot-standby operation

Exit code

Meaning

0

Online state. If a target to be monitored has started, use this exit code.

1

Offline state. If a target to be monitored has stopped, use this exit code. If it completes in Offline after it has become Online, a switchover is performed.

2

Faulted state. If a target to be monitored has faulted, use this exit code. If it completes in Faulted after it has become Online, a switchover is performed.

4

Standby state. If a target to be monitored has been Standby state, use this exit code.

Note

Since the exit codes other than the above indicate the specific status, use these codes only when applicable products are specified in the environment that uses PRIMECLUSTER products.

6.11.2.2.4 Timeout of Check Script

If the cluster application needs to be switched due to a resource error when the Check script processing is not completed within the specified time, set the CheckCommandTimeouts attribute of the Cmdline resource. Specify the time to determine a resource error if the Check script processing is not completed in seconds. By default, "none" is set, which means that a resource error does not occur.

The settable value is "none" or in the range of 45 seconds to 3600 seconds.