chkserv with one application and multiple processes

gareth.star

Member
May 9, 2013
22
2
53
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
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.
 
  • Like
Reactions: gareth.star

gareth.star

Member
May 9, 2013
22
2
53
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
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?
It should work if the service names are different. Feel free to test that out and let us know the outcome.

Thank you.