Self-Healing

Component Agent lifecycle scripts and CPU/memory self-healing thresholds.

3 min read Updated SS

The agents' folder post-installation contains the following scripts:

  • start.sh: It starts a process if it is not running.
  • stop.sh: It stops a process if it is running.
  • restart.sh: It starts a process if it is not running. If a process is running, it first stops the process and then starts it.
  • status.sh: It checks the status of the process, whether it is running or stopped.
  • selfheal.sh: It acts as a self-healing operation on applications. It automatically detects, diagnoses, and repairs issues.

The selfhealconfig file resides inside the agent's folder. In this file, you can configure CPU or memory thresholds for both host and process. Process threshold values can be assigned with global or local values (individual sets of values).

<Path>/<Agent>/<selfheal>/<external_command> folder contains the following additional self-heal check scripts:

  • Pre_Load_Average_Check.sh
  • Pre_Disk_Space_Check.sh
  • Pre_Process_Count_Check.sh
  • Post_Load_Average.sh
  • Post_Disk_Space_Check.sh
  • Post_Process_Count_Check.sh

Scripts starting with the prefix Pre_ get executed before starting the agent.

Scripts starting with the prefix Post_ get executed when the agent is running.

Load_Average_Check: It finds the number of cores on the machine and finds the current load average. It calculates the percentage and checks against the configured threshold.

For example:

Number of cores = 8

Current load average = 6

Load_Average percentage = 6/8 * 100 = 75%

Note:
If you configure the load average percentage, then you need not configure the exact load average value on each machine.

  • Disk_Space_Check: It gets the disk usage percentage for the configured partition (preferably on which the agent runs) and checks against the configured threshold.
  • Process_Count_Check: It gets the process count for the configured pattern. If the pattern is configured to All, then it gets the total process count on the Host and checks against the configured threshold.

selfheal.sh starts and does the primary validations for CPU and memory for both Host and Process. After this, selfheal.sh invokes the above scripts and checks on the return value of these scripts. 

If the return value of the execution is 0, selfheal.sh proceeds to execute the next script. If the return value of the execution is non-zero, selfheal.sh performs the self-heal action.

i) If an agent is already running, then the selfheal.sh script checks CPU or Memory thresholds for both the Host and Process every time it is invoked. It also checks for the load average, disc space, and process count thresholds.

selfheal.sh script stops the agent in case any of the thresholds are breached.

ii) If an agent is stopped or not running, then the selfheal.sh script checks CPU or Memory thresholds only for the Host in the next invocation of the script. It also checks for the load average, disc space, and process count thresholds.

The selfheal.sh script starts the agent in case any of the thresholds are below the configured thresholds.

Self-Healing Flowchart

The supervisor receives commands from the supervisor controller and executes the scripts based on the command.

Scripts display output in the following format:

STATUS="Running/Stopped"#@#HEAL_NEWLINE#@#

MESSAGE="A short description of script activity and the reason behind status"

For example: If the start script is executed, the output is

STATUS="Running"#@#HEAL_NEWLINE#@#

MESSAGE="Process started successfully"

Supervisor Script Flow