不用网上流传的pl和php插件,利用redis本身的redis-cli命令来监控。
#!/bin/bash redis_bin=‘/home/app/redis/src‘ redis_ip=(192.168.1.161 192.168.1.162 192.168.1.163 192.168.1.164) redis_master_port=‘6379‘ redis_slave_port=‘6380‘ for (( i = 0; i < 1; i++ )); do ALIVE_master=‘‘$redis_bin‘/redis-cli -h ‘${redis_ip[$i]}‘ -p ‘$redis_master_port‘ ping‘ ALIVE_slave=‘‘$redis_bin‘/redis-cli -h ‘${redis_ip[$i]}‘ -p ‘$redis_slave_port‘ ping‘ if [ `$ALIVE_master` == "PONG" ] && [ `$ALIVE_slave` == "PONG" ]; then echo "redis ${redis_ip[$i]} is healthy." exit 0 else echo "the redis ${redis_ip[$i]} 6379 or 6380 is down." exit 1 fi done
本文出自 “echo xiayun” 博客,请务必保留此出处http://linuxerxy.blog.51cto.com/10707334/1895741
原文地址:http://linuxerxy.blog.51cto.com/10707334/1895741