没有pidfile的Monit memcached配置

时间:2016-01-29 05:25:24

标签: memcached centos7 monit

我有经典的情况。需要在CentOS7上为memcached配置monit。问题是,我可以在谷歌找到的所有配置包含这一行:

check process memcached with pidfile /var/run/memcached/memcached.pid

但是,/ var / run中没有memcached.pid文件,没有/ var / run / memcached文件夹。我已经检查了/usr/lib/systemd/system/memcached.service

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/memcached
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS

因此,没有.pid文件的路径。 问题是我可以在没有.pid文件的情况下检查memcached吗? 第二个问题 - 可以将此.pid文件放在另一个位置吗?

1 个答案:

答案 0 :(得分:12)

替换你的monit配置

check process memcached with pidfile /var/run/memcached/memcached.pid

check process memcached with match memcached

我的memcached配置:

check process memcached with match memcached
    start program = "/usr/bin/systemctl start memcached"
    stop program = "/usr/bin/systemctl stop memcached"
    if failed host 127.0.0.1 port 11211 protocol MEMCACHE then restart
    if cpu > 70% for 2 cycles then alert
    if cpu > 98% for 5 cycles then restart
    if 2 restarts within 3 cycles then timeout

Centos 7,monit 5.14