6.14.3 Creating a command to be executed when monitoring of the standby server is performed
HA Monitor can execute a monitoring command at regular intervals during monitoring of the standby server by creating a command that is to be executed when monitoring of the standby server is performed.
This subsection describes how to create a command that is to be executed when monitoring of the standby server is performed and when the created command is called.
- Organization of this subsection
(1) Timing at which the command to be executed when monitoring of the standby server is performed is called
If you create the command, HA Monitor executes it with the superuser permissions.
The command is called in the following cases:
-
Startup of the standby server is completed in the standby system.
-
The standby server in the standby system is ready for hot-standby switchover.
-
The standby server is in the hot-standby switchover wait state.
(2) How to create a command to be executed when monitoring of the standby server is performed
Create a command so that the following conditions are met:
-
If a particular operating environment is required for monitoring programs, set it. In RHEL7 or a later version, you can specify environment variables in the Unit settings file. However, the Unit settings file is overwritten when an overwrite installation of HA Monitor is performed. Therefore, we recommend that you specify an operating environment (environment variables) within the shell.
For details about the environment variables that are inherited when the standby server monitoring command is executed, see (2) How to create a server termination command in 6.13.2 Creating a server termination command.
-
The command must be able to receive the SIGTERM signal.
HA Monitor stops the monitoring command by sending the SIGTERM signal if a timeout occurs when the standby server is terminated normally or the monitoring command is executed. Therefore, the command must be able to receive SIGTERM.
-
Create a monitoring command so that its execution does not loop indefinitely.
If processing of the monitoring command loops indefinitely for some reason (for example, periodic monitoring is performed within the monitoring command), HA Monitor detects the loop as a slowdown or hang of the monitoring command. Therefore, HA Monitor assumes that a server failure occurred on the monitor-mode standby server.
-
The monitoring command you create must terminate with one of the EXIT codes listed in the following table according to the status of the monitoring-target job processing.
Table 6‒14: Correspondence between the statuses of monitoring-target job processing and EXIT codes No.
Status of the monitoring-target job processing
EXIT code
Description
1
Normal
0
If the monitoring target is operating normally, the command must return the EXIT code 0. HA Monitor assumes that the monitoring target is in the normal status or has been recovered from a failure.
2
Status check failed
Monitoring error
Indeterminable
1 to 9
HA Monitor re-executes the monitoring command.
HA Monitor operates as specified by the sby_ptrlcmd_ex_retry operand in the server environment definition.
The re-execution interval is the same value that is specified for the sby_ptrlcmd_ex_inter operand in the server environment definition.
Make sure that the command returns these codes when a temporary failure has occurred (for example, it is impossible to judge whether monitoring of the monitoring target failed or whether the problem that occurred pertains to the monitoring target).
3
Failure
10 to 19
HA Monitor assumes that a failure has occurred without re-executing the monitoring command.
HA Monitor operates as specified by the sby_servexec_retry operand in the server environment definition.
Make sure that the command returns these codes in such a case when HA Monitor can judge that a failure has occurred without re-executing the monitoring command.
4
20 to 29
HA Monitor judges that a server failure has occurred on the standby server without re-executing the monitoring command, and terminates the standby server.
HA Monitor immediately terminates the standby server so that hot-standby switchover does not occur, ignoring the specification of the sby_servexec_retry operand in the server environment definition.
Make sure that the command returns these codes in cases such as when HA Monitor can judge that processing cannot continue even by restarting the standby server due to a disk failure or another permanent failure.
5
--
30 to 49
Do not use these codes because they are reserved by HA Monitor.
6
Other codes
HA Monitor re-executes the monitoring command.
HA Monitor operates as specified by the sby_ptrlcmd_ex_retry operand in the server environment definition.
The re-execution interval is the same value that is specified for the sby_ptrlcmd_ex_inter operand in the server environment definition.
Make sure that the command returns these codes when a temporary failure has occurred (for example, it is impossible to judge whether monitoring of the monitoring target failed or whether the problem that occurred pertains to the monitoring target).