Featured Posts

Using DKIM with Exim and cPanel Similar to the intentions of SPF records and DomainKeys, DKIM is intended to authenticate a sender by using a public/private key pair to digitally sign email, therefore increasing deliverability. At this...

Readmore

Copy Outgoing Email on a cPanel Server with Exim A common request we get is how a user can automatically BCC outgoing email to another address. This is most often requested by law firms that need to be able to retain copies of communication. Forwarding...

Readmore

Do You Care About Your Customers' Data? I was working a case last week for a new client that's been hosting local business websites for over three years. As with all of my case studies, I did a short survey of the client's infrastructure, processes,...

Readmore

Tips to Reduce Your Customer Support Costs When hosting websites, whether as a mainstream hosting provider, a hobby, or to supplement another service, it's your job to make sure your customers have access to technical support in case they need...

Readmore

Roundcube: MySQL or SQLite? cPanel 11.25 introduces a new feature: The ability to have RoundCube use SQLite instead of MySQL. After benchmarking resource usage and performance, I've come to the conclusion that SQLite is definitely...

Readmore

The cPanel Admin Rss

Adding Services to Chksrvd for Monitoring

Posted by Vanessa | Tagged under ,,, | Posted on December 28, 2009

1

Chkservd is the service in cPanel that checks to make sure that services are running, then restarts them if necessary.  It’s also responsible for the ‘Service Manager’ section in cPanel, which is also an interface where added services can be easily checked on and off.

Service files are in /etc/chkserv.d/

To add a new service, create a line in ”’/etc/chkserv.d/chkservd.conf’” in the same format as the others:

service:1

1 means the service should be enabled, 0 means it’s off.

In ”’/etc/chkserv.d”’ each service has its own file.  Create a file called as the name of the service you are monitoring.  The contents of the file are in the format of:

#SERVICE = PORT, SEND, RESPONSE, RE-START COMMAND

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. For instance, FTP:

service[ftpd]=21,QUIT,220,/scripts/restartsrv_ftpserver

*Process-based monitoring – cPanel will check for a specific process to determine whether it is online. For instance, named:

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

After you’ve created the service’s configuration file, restart chkservd:

/etc/init.d/chkservd restart

You should then see the service listed in WebHost Manager in the ‘service manager section’

Chkservd logs are in /var/log/chkservd.log.  Checks are done every 8 minutes, and everyone 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.


Liking this article? Share it and spread the word!
  • Print
  • PDF
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts:

Comments (1)

Good write-up!

I just wanted to add a few bits of information to remove some ambiguities:
in the process-based monitoring it’s important to understand those comma delimited parameters:
service[named]=x,x,x,/scripts/restartsrvr_bind,named,named|bind

where the first three don’t apply, which is why they are “x”

#4 is the command to start the service. My personal beef with it, by the way, is that I suspect it runs under user name “cpanel” which is usually not in your normal list of sudoers – important if the command needs to be run as a different user – I’m still doing a research on this.

#5 is basically NOT not command name and rather a search term for grep (I don’t know if searchd actually uses grep but the result is the same)
so, if you are monitoring “named” but you have this command running ” pico /etc/init.d/named”, it will think “named” itself is running – have to be very careful with it, especially if the command name is rather common

#6 is also rather tricky – it is the user that runs the command given in in #5. If the command is present but it’s run by, say, “root” instead of “named”, it will NOT match, even if “named” (the command) is actually running. And the notation you have in your example means that it will match if the “named” (a command name match) is run by either “named” (the user) or “bind”

Hope that can help someone from running in circles – there is very little info on that on the Net.

If someone knows exactly how chkservd runs the commands (as “root”, as “cpanel”, how to control paths etc.), please add some info here for the full(est) coverage of this little sucker I’ve seen anywhere, including cPanel’s own documentation.

Cheers everyone, keep up great work!

Write a comment