# zabbix_agent.conf 에 아래 내용 추가
AllowRoot=1 추가
# cat /etc/zabbix/zabbix_agentd.d/userparameter_redis_lld_plus.conf
# zabbix server version >= 3.4
# Need command: telnet,ss
UserParameter=redis.port.discovery,ss -4lpn|grep redis-server|awk -F: '{print $2}'|awk '{print $1}'| awk NF | sed -e s/^/'{"{#REDIS_PORT}": "'/g -e s/'$'/'"},'/g | tr -d \\n | sed -e s/^/'{"data":['/g -e s/',$'/]}/g
UserParameter=redis.port.ping[*],(echo auth $2; echo ping ;sleep 0.1) |telnet 127.0.0.1 $1 2>/dev/null |grep 'PONG'|wc -l
UserParameter=redis.info.json[*],(echo auth $2; echo info ; sleep 0.1)| telnet 127.0.0.1 $1 2>/dev/null | grep ':'| grep -v ^# | grep -v ^db | awk NF | sed -e s/:ok$/:yes/g -e s/^/'"'/g -e s/'$'/'",'/g -e s/':'/'":"'/g | tr -d \\n | sed -e s/^/'{"redis_info":{'/g -e s/',$'/}}/g
UserParameter=redis.config.json[*],(echo auth $2; echo "config get *" ; sleep 0.1)| telnet 127.0.0.1 $1 2>/dev/null|sed -e '0,/^\$[0-9]/d'|sed -e '/^\$[0-9]/d'|awk '{print $NF}'|sed -e 's/^/"&/g' -e 's/$/&"/g'|sed 'N;s/\n/:/g' |sed -e s/'$'/','/g| tr -d \\n | sed -e s/^/'{"redis_config":{'/g -e s/',$'/}}/g
#discovery slave
UserParameter=redis.repl.discovery,ss -4lpn|grep redis-server|awk -F: '{print $2}'|awk '{print $1}'| awk NF|while read line; do role=`(echo info ; sleep 0.1)|telnet 127.0.0.1 $line 2>/dev/null|grep 'role:slave'|awk -F ':' '{print $2}'`;if [ "$role" == "slave" ] ;then echo "SLAVE:$line"|sed -e s/^/'{"{#REDIS_PORT_'/g -e s/'$'/'"},'/g -e s/':'/'}": "'/g ; fi;done| tr -d \\n | sed -e s/^/'{"data":['/g -e s/',$'/]}/g
UserParameter=redis.slaveinfo.json[*],(echo auth $2; echo info Replication; sleep 0.1)| telnet 127.0.0.1 $1 2>/dev/null | grep ':'| grep -v ^# | grep -v ^db | awk NF | sed -e s/:ok$/:yes/g -e s/^/'"'/g -e s/'$'/'",'/g -e s/':'/'":"'/g | tr -d \\n | sed -e s/^/'{"redis_slaveinfo":{'/g -e s/',$'/}}/g
|
# zabbix agent 실행권한 변경
# mkdir /etc/systemd/system/zabbix-agent.service.d
# vi /etc/systemd/system/zabbix-agent.service.d/override.conf
[Service]
User=root
Group=root
# systemctl daemon-reload
# systemctl restart zabbix-agent.service
|
# template
'Zabbix' 카테고리의 다른 글
zabbix에서 docker network interface 제외하는 방법 (0) | 2019.11.29 |
---|---|
[zabbix] TCP 모니터링 하는 법 (0) | 2019.11.26 |
[Zabbix] 디스크 모니터링 하는 방법 (0) | 2019.09.10 |