Monit not working with Redis -
i configuring monit monitor redis , redis sentinel. every time monit run, logs both redis , redis sentinel not running , tries run them although both of them done. fails in starting redis processes.
whereas working system checks , nginx , other processes.
versions:
redis: redis server v=2.8.4 sha=00000000:0 malloc=jemalloc-3.4.1 bits=64 build=a44a05d76f06a5d9 monit: version 5.6
here configuration of monit redis (redis sentinel has same configuration):
# redis check process redis pidfile /var/run/redis-server.pid group cache group redis start program = "/etc/init.d/redis-server start" stop program = "/etc/init.d/redis-server stop" if failed host 127.0.0.1 port 6379 restart if totalmem > 500 mb alert if cpu > 60% 2 cycles alert if cpu > 98% 5 cycles restart if 2 restarts within 2 cycles alert depend redis_bin depend redis_rc check file redis_bin path /usr/bin/redis-server group redis include /etc/monit/templates/rootbin check file redis_rc path /etc/init.d/redis-server group redis include /etc/monit/templates/rootbin
here logs of monit:
[pkt aug 19 17:00:07] error : 'redis' process not running [pkt aug 19 17:00:07] info : 'redis' trying restart [pkt aug 19 17:00:07] info : 'redis' start: /etc/init.d/redis-server [pkt aug 19 17:00:37] error : 'redis' failed start
i think cause of issue other processes working fine owned root along directories , bin files. related redis own user "redis" group "redis". , why monit not able start or stop redis.
but have tried use adding user in start , stop settings this:
start program = "/etc/init.d/redis-server start" uid redis , gid redis stop program = "/etc/init.d/redis-server stop" uid redis , gid redis
but didn't work either.
what doing wrong here? correct way monitor redis monit?
a couple of changes made make sure monit has access start/stop service , making sure have right pid file monit checks once restarts service. in case , configuration:
# redis check process redis pidfile /var/run/redis/redis-server.pid group cache group redis start program = "/usr/sbin/service redis-server start" timeout 60 seconds stop program = "/usr/sbin/service redis-server stop" timeout 60 seconds if failed host 127.0.0.1 port 6379 restart if totalmem > 500 mb alert if cpu > 60% 2 cycles alert if cpu > 98% 5 cycles restart if 2 restarts within 2 cycles alert depend redis_bin depend redis_rc check file redis_bin path /usr/bin/redis-server group redis include /etc/monit/templates/rootbin check file redis_rc path /etc/init.d/redis-server group redis include /etc/monit/templates/rootbin
- the generated pid file path different on machine, recommend make sure right path on side.
- i gave start/stop operation 60 seconds instead of default 30 second
- a side note: used
/usr/sbin/service redis-server
instead of/etc/init.d/redis-server
shouldnt make difference, tried both of them, , both work.
monit allows before timing out, make sure has amount of time respond service.
the output is:
[est nov 30 16:25:22] error : 'redis' process not running [est nov 30 16:25:22] info : 'redis' trying restart [est nov 30 16:25:22] info : 'redis' start: /usr/sbin/service [est nov 30 16:27:22] info : 'redis' process running pid 24864
Comments
Post a Comment