在没有 pidfile 的情况下监控 memcached 配置

Monit memcached config without pidfile

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

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 文件可以在另一个位置吗?

在您的监视器配置中替换

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,监视器 5.14