4.4.1 Server monitoring command
HA Monitor Kit provides a sample file of the server monitoring command. Copy the sample file and set it up as explained in this chapter, and customize it as needed. For the storage location and copying destination of the sample file, see 3.2.7(1) Setting up the server start, termination, and monitoring commands.
The server monitoring command sample file executes the patrol_proc() shell function that describes the process to monitor Oracle instances and Oracle listeners at the user-specified time interval.
The following figure shows the content of the server monitoring command sample file.
Figure 4-3 Content of the server monitoring command sample file
![[Figure]](figure/zu040400.gif)
Numbers 1 through 4 in the figure are explained below.
- This is the environment variable for setting up the operating environment necessary for monitoring programs.
For details about the content to be set up here, see (1) Environment variables.
- This is the Oracle instance monitoring process.
The process for executing the haorainsptl command to monitor the Oracle instance specified by the instance identifier is described here. For details about the content to be set up here, see (2) Setup method.
For details about the haorainsptl command, see haorainsptl (Checks the status of an Oracle instance) in 4.5 Commands used for setting up the server start, termination, and monitoring commands.
- This is the Oracle listener monitoring process.
The process for executing the haoralsnrptl command to monitor the Oracle listener specified by the listener name is described here. For details about the content to be set up here, see (2) Setup method.
For details about the haoralsnrptl command, see haoralsnrend (Terminates an Oracle listener) in 4.5 Commands used for setting up the server start, termination, and monitoring commands.
- This is the process executed by the patrol_proc() shell function.
To add your own process, add it inside this patrol_proc() shell function. For details about the content to be set up here, see (3) Server monitoring command customization
- Organization of this subsection
- (1) Environment variables
- (2) Setup method
- (3) Server monitoring command customization
(1) Environment variables
This subsection explains the environment variables indicated by 1 in Figure 4-3 Content of the server monitoring command sample file.
- LOGNAME
Specifies a server log file name. Specify a unique file name for each server.
We recommend that you match the server log file name to the server's server alias name. In the provided sample file, orasrv is assumed as the server alias name.
For the server log output destination, see 5.4 Checking the server logs.
- LOGSIZE
Specify an integer for the server log file size (in bytes). The default is 1048576. Under normal conditions, use this default file size. Increase the size only if the volume of output is large and may cause the log to run out of space. For details about how to calculate the server log file size, see 5.4(2) File size.
For servers in which you specified the same value for the LOGNAME environment variable, specify the same value for the LOGSIZE environment variable of the server start, termination, and monitoring commands.
- PATROL_INTERVAL
Specify a value between 1 and 3,600 (seconds) for the monitoring execution interval (the interval between the end of a monitoring process and the start of the next monitoring process). The default is 5. Normally, there is no need to change the default execution interval.
(2) Setup method
This subsection explains how to set up the monitoring processes 2 and 3 in Figure 4-3 Content of the server monitoring command sample file.
- Setting up Oracle instance monitoring process (2 in the figure)
- The provided sample file uses a setting that monitors a single Oracle instance (instance identifier: orcl1) that is associated with a server. If there is no Oracle instance that is associated with a server, comment out the code indicated by 2 in the figure, or delete it. To monitor multiple Oracle instances on a single server, duplicate the code indicated by 2 in the figure.
- In the provided sample file, orcl1 is assumed as the instance identifier. Change the underlined argument orcl1 to the instance identifier of the Oracle instance you want to monitor.
- Setting up Oracle listener monitoring process (3 in the figure)
- The provided sample file uses a setting that monitors a single Oracle listener (listener name: LISTENER) that is associated with a server. If there is no Oracle listener that is associated with a server, comment out the code indicated by 3 in the figure, or delete it. To monitor multiple Oracle listeners on a single server, duplicate code indicated by 3 in the figure.
- In the provided sample file, LISTENER is assumed as the listener name. Change the underlined argument LISTENER to the listener name of the Oracle listener you want to monitor.
To change the order for monitoring Oracle instances and Oracle listeners, change the monitoring order in the file.
(3) Server monitoring command customization
You can add non-Oracle application processes necessary for a job, and user-specific processes, to the server monitoring command. When customizing the command, note the following:
- Before adding a process, see the description under Creating a server monitoring command in the manual HA Monitor (for Linux(R)).
- Add the process in the patrol_proc() shell function inside the server monitoring command. Do not edit any items other than the patrol_proc() shell and the shell variables.
The process described here must be executed with superuser permissions. If you have changed your permissions, change them back to superuser permissions.
- Do not use the exit command inside the patrol_proc() shell function. To terminate the process, use the return command.
- If the return code of the patrol_proc() shell function is not 0, the server monitoring command terminates and HA Monitor detects a server failure. When this occurs, the return code of the patrol_proc() shell function becomes the return code of the server monitoring command.
- Be careful not to create a never-ending process, such as an endless loop, in the patrol_proc() shell function.
- For the output destination for the messages issued by the patrol_proc() shell function, see 5.4 Checking the server logs.
- Specify absolute paths for the commands and files to be input/output inside the patrol_proc() shell function. (That is, commands other than the ones provided by HA Monitor Kit.)
- Do not modify the names of the following shell variables:
- LOGNAME
- LOGSIZE
- PATROL_INTERVAL
- Before adding a shell variable, search through the command to make sure it is not already being used.