Introduction
The chkservd driver monitors the status of services to determine if they are online or if a restart is required for the service. The chkservd driver also allows you to add your own custom service for monitoring.
Procedure
1) Add the service to the configuration
- Open
/etc/chkserv.d/chkservd.conf
via a text editor of your choice. - Add the service you wish to monitor in the following format:
$SERVICE:1
(1 indicates the service should be monitored) - Example:
ftpd:1
2) Create a service configuration file
- Inside the directory
/etc/chkserv.d/
create a service file. -
touch /etc/chkserv.d/$SERVICE
3) Configure the service file
There are 3 methods of monitoring that chksrvd can perform, so select the one that fits your custom service the best.
- Connection-based monitoring: With connection-based monitoring, the chksrvd driver will attempt to connect to the specified port and issue a command. If a proper response is received then the service is considered to be online.
Using the FTP service as an example:
service[ftpd]=21,QUIT,220,/usr/local/cpanel/scripts/restartsrv_ftpserver
ftpd
represents the service to monitor.21
represents the port through which thechkservd
driver will attempt to connect to the service.QUIT
represents the command that thechkservd
driver will send to check the service’s connection.220
represents the server’s expected response to the command./usr/local/cpanel/scripts/restartsrv_ftpserver
represents the service’s restart command.
- Process-based monitoring: With process-based monitoring, chksrvd will search for the specified process to determine if the service is online.
Using the FTP service as an example:
service[ftpd]=x,x,x,/usr/local/cpanel/scripts/restartsrv_ftpserver.service,ftpd,root
In this example the values represent the following:
-
ftpd
represents the service to monitor. -
x,x,x
directs the system to use process-based tracking. -
/usr/local/cpanel/scripts/restartsrv/ftpserver
represents the service’s restart command. To enter more than one restart command, separate each command with a semicolon (;
) in the order that thechkservd
driver will execute them. -
ftpd
represents the service to restart. -
root
represents the user who owns the monitor process. -
Make certain to separate multiple users with a pipe (
|
) character.
- Combined connection-based and process-based monitoring: This method will utilize both process and connection-based monitoring to determine the status of the service.
Using the FTP service as an example:
service[ftpd]=21,QUIT,220,/usr/local/cpanel/scripts/restartsrv_ftpserver,ftpd,root
In this example the values represent the following:
-
ftpd
represents the service to monitor. -
21
represents the port through which thechkservd
driver will attempt to connect to the service. -
QUIT
represents the command that thechkservd
driver will send to check the service’s connection. -
220
represents the server’s expected response to the command. -
/usr/local/cpanel/scripts/restartsrv_ftpserver
represents the service’s restart command. -
ftpd
represents the service to restart. -
root
represents the user who owns the monitor process. Make certain to separate multiple users with a pipe (|
) character.
4) Restart chksrvd
- After these modifications have been performed, restart the service to have your changes take effect.
-
/scripts/restartsrv_chkservd
For more information, visit our official documentation.