How to add service in chkservd monitoring
Chkservd is a driver of Tailwatchd, which is the service in cPanel that checks to make sure that services are running and restarts them if necessary. It’s also responsible for the 'Service Manager' section in cPanel, which is an interface where added services can be easily checked on and off.
Service files are located in the folder '/etc/chkserv.d/'.
This article explains the steps to enable a service in chkservd.
Step1: create a line in '/etc/chkserv.d/chkservd.conf' in the below format
service:1
Here 1 means the service should be enabled, 0 means it’s off.
Step2: Create a file in the folder '/etc/chkserv.d' with the name of the service need to monitor.
There are two ways that cPanel checks services with chkservd:
Connection-based monitoring: By default, cPanel will try to connect to the service’s specified port, issue a command, and if a response is received within 10 seconds it will consider the service to be online.
Syntax: #SERVICE = PORT, SEND, RESPONSE, RE-START COMMAND
Example: service[ftpd]=21,QUIT,220,/scripts/restartsrv_ftpserver
Process-based monitoring: cPanel will check for a specific process to determine whether it is online.
Syntax: #SERVICE = PORT, SEND, RESPONSE, RE-START COMMAND
Example: service[named]=x,x,x,/scripts/restartsrvr_bind,named,named|bind
If you have more than one restart command, you can separate them with semicolons in order of preference that they should be run. Output of these commands will be logged to the chkservd.log
Step3: Restart chkservd service
#/scripts/restartsrv_chkservd
The service will be listed in WHM in the 'service manager section'
Chkservd logs are in /var/log/chkservd.log. Checks are done every 8 minutes (though this is configurable in WHM -> Tweak Settings), and every online service gets a +, offline services get a -. If the service is determined to be offline, the restart command(s) specified in that service’s chkservd configuration file is issued and the output is logged.