zabbix monitors redis shell script

#! /bin/bash
# Name: redismontior.sh
# From: [email protected] updn.cn [email protected]  <2017/11/03>
# Action: Zabbix monitoring redis plug-in

# redis connect info
REDISCLI="/opt/redis/bin/redis-cli"
CLUSTER_HOST=('192.168.10.18 3000' '192.168.10.18 3004' '192.168.10.19 3001' '192.168.10.19 3005' '192.168.10.20 3002' '192.168.10.21 3003')
#CLUSTER_HOST1=(192.168.10.18 3000)
#CLUSTER_HOST2=(192.168.10.18 3004)
#CLUSTER_HOST3=(192.168.10.19 3001)
#CLUSTER_HOST4=(192.168.10.19 3005)
#CLUSTER_HOST5=(192.168.10.20 3002)
#CLUSTER_HOST6=(192.168.10.21 3003)
PASSWD="xxxx"

# zabbix info
ZBX_CONF=/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
ZBX_SENDER=/usr/bin/zabbix_sender
function sender()
{
	$ZBX_SENDER -c $ZBX_CONF -s ${HOSTNAME} -k $1 -o $2 &>/dev/null
}

# do
function getinfo()
{
	result=`$REDISCLI -h $1 -p $2 -a $PASSWD info | grep -w "$3" | awk -F':' '{print $2}'`
	echo $result
}

if [[ $# == 1 ]];then
	for i in "${CLUSTER_HOST[@]}"
	do
		echo $i
		HOST=($i)
		getinfo ${HOST[0]} ${HOST[1]} $1
	done
else
	echo "error input"
be

 Today, I thanked a shell script to get redis information and send an alarm to zabbix

[root@tingyun-zabbix opt]# sh redismonitor.sh used_memory_human

192.168.10.18 3000

6.39

192.168.10.18 3004

3.45G

192.168.10.19 3001

7.12G

192.168.10.19 3005

3.97G

192.168.10.20 3002

6.38G

192.168.10.21 3003

6.38G

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326222291&siteId=291194637