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.

chkserv with one application and multiple processes

Discussion in 'cPanel Developers' started by gareth.star, Aug 9, 2016.

Tags:
  1. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Let's say I've got 3 redis servers running on 1 machine. Each runs on a different port (1111, 2222, 3333).

    I create each chkserv.d file as follows:

    Code:
        echo "service[redis_1111]=x,x,x,systemctl restart redis_1111.service,redis-server,redis_user" > /etc/chkserv.d/redis_1111
        echo "service[redis_2222]=x,x,x,systemctl restart redis_2222.service,redis-server,redis_user" > /etc/chkserv.d/redis_2222
        echo "service[redis_3333]=x,x,x,systemctl restart redis_3333.service,redis-server,redis_user" > /etc/chkserv.d/redis_3333
    
    In the above, each of the services has a different file to launch redis on its own port.

    When launched, the process list might look like:

    Code:
        /usr/local/bin/redis-server 127.0.0.1:1111
        /usr/local/bin/redis-server 127.0.0.1:2222
        /usr/local/bin/redis-server 127.0.0.1:3333
    
    Am I right in saying that if 2222 goes down, chkserv will think redis is still running becuase the process "redis-server" still appears in the process list?

    Is there a way of telling chkserv to check for redis-server and the string 2222?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You should be able to use port-based monitoring. Here's an example you can test for port 2222:

    Code:
    service[redis_2222]=2222,QUIT,220,systemctl restart redis_2222.service,redis-server,redis_user
    Thank you.
     
    gareth.star likes this.
  3. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    I can't believe it didn't occur to me to use port-based monitoring. Thanks, Michael!

    A similar question. What if sockets were used instead of ports? Would it be possible to handle that situation?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    It should work if the service names are different. Feel free to test that out and let us know the outcome.

    Thank you.
     
  5. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    I'm not using anything socket based at the moment, but when I do, I'll come back with my results :)
     
    cPanelMichael likes this.
Loading...

Share This Page