The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Howto monitor and restart services automatically

Discussion in 'General Discussion' started by albatroz, Feb 19, 2007.

  1. albatroz

    albatroz Well-Known Member

    Joined:
    Mar 6, 2003
    Messages:
    258
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Virtual Orbis / Peru
    cPanel Access Level:
    Root Administrator
    I wonder if someone has a script that can be linked to CRON for restarting services when
    they suddenly stop working.
     
  2. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    cpanel all ready has it is called chksrvd you can configure it with your service manager
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    cPanel and WHM actually has such a script built-in. You can add any service you want to /etc/chkserv.d/chkservd.conf

    Chkserv supports two types of monitoring:

    1 - Connection based monitoring: Chkserv will send out a request and anticipate an expected response. If it does not receive the expected response, it will attempt to restart the service. The syntax for adding this type of monitoring to chkservd.conf is as follows:

    - service[serviceName] = port,send,response,restart
    serviceName = Name of service
    response = Expected Response
    restart = Full path to restart service
    send = What data to send

    2 - Command based monitoring: Checks to see if a service (command) is running locally. If not, it attempts to restart it.
    - service[serviceName] = ,,,restart,command,owner
    command is a regular expression

    Chkservd will monitor services periodically, once every 8 minutes.
     
  4. albatroz

    albatroz Well-Known Member

    Joined:
    Mar 6, 2003
    Messages:
    258
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Virtual Orbis / Peru
    cPanel Access Level:
    Root Administrator
    In my case this is the content of chkserverd.cnf

    named:1
    named:1
    named:1


    However there are 3 other files called
    clamd
    cpsrvd
    eximstats
    named

    For instance this is the content of the clamd file
    service[clamd]=x,x,x,/scripts/restartsrv clamd,clamd,root
     
  5. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    You can easily adjust your basic services via the "service manager" in whm. Check the box on the right of the service you would like monitored.
     
Loading...

Share This Page