zabbix 监控redis

redis_low_discovery.sh 内容

#!/bin/bash
#Fucation:mysql low-level discovery
#Script_name redis_low_discovery.sh
redis() {
#port=($(sudo netstat -tpln | awk -F "[ :]+" '/redis/ && /0.0.0.0/ {print $5}'))
port=('7008' '7009' '7010')
printf '{\n'
printf '\t"data":[\n'
for key in ${!port[@]}
do
if [[ "${#port[@]}" -gt 1 && "${key}" -ne "$((${#port[@]}-1))" ]];then
socket=`ps aux|grep ${port[${key}]}|grep -v grep|awk -F '=' '{print $10}'|cut -d ' ' -f 1`
printf '\t {\n'
printf "\t\t\t\"{#REDISPORT}\":\"${port[${key}]}\"},\n"
else [[ "${key}" -eq "((${#port[@]}-1))" ]]
socket=`ps aux|grep ${port[${key}]}|grep -v grep|awk -F '=' '{print $10}'|cut -d ' ' -f 1`
printf '\t {\n'
printf "\t\t\t\"{#REDISPORT}\":\"${port[${key}]}\"}\n"
fi
done
printf '\t ]\n'
printf '}\n'
}
$1

redis_stats.conf 配置内容:

UserParameter=redis.discovery,/bin/bash /etc/zabbix/scripts/redis_low_discovery.sh redis
UserParameter=redis_stats[*],(echo info; sleep 1) | telnet 127.0.0.1 $1 2>&1 |grep $2|cut -d : -f2
UserParameter=redis.ping[*],/usr/local/bin/redis-cli -h 127.0.0.1 -p $1 ping|grep -q "PONG" && echo 1|| echo 0

zabbix 监控模板 https://download.csdn.net/download/u010571301/88478506


发表评论

评论列表,共 0 条评论

    暂无评论