Zabbix Monitoring redis
The health status of redis is monitored by the info command of redis, and the survival status of redis is monitored by redis-cli PING command.
There is a monitoring template in the attachment. Put the monitoring script under the custom / scripts/zabbix_redis/ of the redis server:
#! / bin/bash#Name: redismontior.shREDISCLI= "/ usr/bin/redis-cli" HOST= "127.0.0.1" PORT=6379if [[$# = = 1]]; then case $1 in version) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "redis_version" | awk-redis_version'{print $2} '`echo $result Uptime) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "uptime_in_seconds" | awk-fanglu'{print $2} '`echo $result;; connected_clients) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "connected_clients" | awk-Fang Vol' {print $2} '`echo $result Blocked_clients) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "blocked_clients" | awk-fanglu'{print $2} '`echo $result;; used_memory) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_memory" | awk-Fang Vol' {print $2} '`echo $result Used_memory_rss) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_memory_rss" | awk-fanglu'{print $2} '`echo $result;; used_memory_peak) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_memory_peak" | awk-Fang Vol' {print $2} '`echo $result Used_memory_lua) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_memory_lua" | awk-fanglu'{print $2} '`echo $result;; used_cpu_sys) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_cpu_sys" | awk-Fang Vol' {print $2} '`echo $result Used_cpu_user) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_cpu_user" | awk-fanglu'{print $2} '`echo $result;; used_cpu_sys_children) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_cpu_sys_children" | awk-Fang Vol' {print $2} '`echo $result Used_cpu_user_children) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "used_cpu_user_children" | awk-faggot virtual'{print $2} '`echo $result Rdb_last_bgsave_status) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "rdb_last_bgsave_status" | awk-fagger'{print $2}'| grep-c ok` echo $result Aof_last_bgrewrite_status) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "aof_last_bgrewrite_status" | awk-fagger'{print $2}'| grep-c ok` echo $result Aof_last_write_status) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "aof_last_write_status" | awk-fagger'{print $2}'| grep-c ok` echo $result *) echo-e "\ 033 [33mUsage: $0 {connected_clients | blocked_clients | used_memory | used_memory_rss | used_memory_peak | used_memory_lua | used_cpu_sys | used_cpu_sys_children | used_cpu_user_children | rdb_last_bgsave_status | aof_last_bgrewrite_status | aof_last_write_status}\ 033 [0m";; esacelif [[$# = = 2]] Then case $2 in keys) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "$1" | grep-w "keys" | awk-fills = |,'{print $2} '``echo $result;; expires) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "$1" | grep-w "keys" | awk-fills = |,' {print $4} '`echo $result " Avg_ttl) result= `$ REDISCLI-h $HOST-p $PORT info | grep-w "$1" | grep-w "avg_ttl" | awk-filtering = |,'{print $6} '`echo $result;; *) echo-e "\ 033 [33mUsage: $0 {db0 keys | db0 expires | db0 avg_ttl}\ 033 [0m"; esacfi
Setting of parameter key for zabbix:
# cat / etc/zabbix/zabbix_agentd.d/userparameter_redis.conf UserParameter=Redis.Status, redis-cli PING | grep-c "PONG" UserParameter=Redis.Info [*], / bin/sh / scripts/zabbix_redis/zabbix_redis.sh $1
The template is attached. The two parameters passed in to the script may not be compatible with different environments. You can modify the template and script, or disable the corresponding item directly in the template.
Attachment: http://down.51cto.com/data/2366694