• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

A cPanel Tech

The Diaries of a Linux Server Administrator

  • Home
  • About
  • Privacy
You are here: Home / Control Panels / How to Monitor Services Using Chksrvd

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/cptech/public_html/wp-content/themes/genesis/lib/functions/image.php on line 116

How to Monitor Services Using Chksrvd

November 12, 2012 By admin Leave a Comment

Monitor services is one of the most important tasks of a sysadmin.  cPanel comes with a self monitoring and alerting mechanism so that is a service goes down, it will try to restart it of its own and if that fails, the corresponding server admin will be notified.

Chkservd is the driver used to determine if a process is online and whether it needs to be restarted. You can decide which services are monitored via the WHM -> Service Configuration -> Service Manager interface.

Earlier chkservd was a standalone process, but post 11.30, cPanel had combined eximstats, chchkservd, antirelayd and cpbandwd processes to one called TailWatch and thereby save a lot of resources.

Chkservd checks each service once every 5 minutes to determine if it is online. It will detail it’s findings to the chkservd log file. This file can be found at /var/log/chkservd.log

If a service is online, chkservd will move onto the next. If a service is offline, it will attempt to restart it via the cPanel restart scripts located in /usr/local/cpanel/scripts/restartsrv_*

If you so choose, you can have the results emailed to you. The results are also displayed in the WHM Service Status Panel under Server Information.

If you wish to restart the chkservd service, you need to restart the tailwatchd, instead. You do it by running this script:

/usr/local/cpanel/scripts/restartsrv_tailwatchd

The configuration file is located at /etc/chkserv.d/chkservd.conf . And if you need to add a custom service to chkservd, you need to add the service name to the configuration file and have one configuration file for the service too at /etc/chkserv.d/, which must contain the commands and port to check the service, the desired output, if the service is up, and if down, the steps to restart the service.

For example, the one to check Apache is given below.

service[httpd]=80,GET / HTTP/1.0,HTTP/1..,killall -TERM httpd;sleep 2;killall -9 httpd;/usr/local/cpanel/scripts/restartsrv_httpd ;/etc/rc.d/init.d/httpd stop; /etc/rc.d/init.d/httpd startssl;/usr/local/apache/bin/apachectl startssl;/etc/rc.d/init.d/httpd start;/usr/local/apache/bin/apachectl start

Similarly, we can add monitoring for any service that we add to the server, either through cPanel or through any third party applications.  We just need to know to which port it responds to, what should be the desired response code, and how we should fully restart the service if the desired response is not received.

Filed Under: Control Panels, cPanel, Tutorials Tagged With: chkservd, cpanel, monitoring services, service manager, whm

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Copyright 2018 CPanelTech