You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置chkservd实现Redis服务监控?

用chkservd配置Redis服务监控的问题解决

问题重现

尝试用chkservd监控Redis服务,以下三次配置均失败:

尝试1:基础端口检测配置

配置代码:

service[redis]=6379,PING,\+PONG,systemctl restart redis.service,redis,redis

错误提示:

Service check failed to completeredis: [-NOAUT != +PONG]

原因:Redis开启了密码验证,直接发送PING命令未授权,返回-NOAUTH而非预期的+PONG。

尝试2:带密码参数的redis-cli调用

配置代码:

service[redis]=6379,redis-cli -a "$password" PING,\+PONG,systemctl restart redis.service,redis,redis

错误提示:

Service check failed to completeredis: [-ERR w != +PONG]

尝试3:指定主机端口的带密码配置

配置代码:

service[redis]=6379,redis-cli -a "$password" -h 127.0.0.1 -p 6379 PING,\+PONG,systemctl restart redis.service,redis,redis

错误提示:

Service check failed to completeredis: [-ERR w != +PONG]

原因:chkservd无法正确解析变量$password,且新版Redis中-a参数可能因安全提示导致输出异常,无法匹配+PONG。

正确配置方案

方案1:明文密码直接认证(适合测试或非敏感环境)

替换your_redis_password为实际Redis密码:

service[redis]=6379,redis-cli -h 127.0.0.1 -p 6379 AUTH "your_redis_password" && redis-cli -h 127.0.0.1 -p 6379 PING,\+PONG,systemctl restart redis.service,redis,redis

方案2:使用Redis客户端配置文件(避免明文密码)

  1. 创建Redis客户端配置文件/root/.redis.conf,写入:
requirepass your_redis_password
  1. 修改chkservd配置:
service[redis]=6379,redis-cli -h 127.0.0.1 -p 6379 --config /root/.redis.conf PING,\+PONG,systemctl restart redis.service,redis,redis

方案3:管道传递认证与检测命令

service[redis]=6379,echo -e "AUTH your_redis_password\nPING" | redis-cli -h 127.0.0.1 -p 6379,\+PONG,systemctl restart redis.service,redis,redis

配置完成后,重启chkservd服务生效:

systemctl restart chkservd

内容的提问来源于stack exchange,提问作者João Wall

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 22:39:58