본문 바로가기

Monitoring Tools/Zabbix

6. [zabbix agent] redis

반응형

1. zabbix_agent2.conf : agent에서 지원 됨.

... 
### Option: Plugins.Redis.Sessions.*.Password
#       Password to send to protected Redis server. "*" should be replaced with a session name.
#
# Mandatory: no
# Default:
#Plugins.Redis.Sessions.*.Password=abc@micap
Plugins.Redis.Sessions.redisserver.Uri=tcp://localhost:6379
Plugins.Redis.Sessions.redisserver.Password={redis password}
...

 

2. zabbix_agent.conf : agent에서 지원 되지 않아 UserParameter로 처리

# 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-redis.py

zabbix-redis.py
0.02MB

반응형

'Monitoring Tools > Zabbix' 카테고리의 다른 글

8. [zabbix agent] jstat  (0) 2021.03.17
7. [zabbix agent] varnish  (0) 2021.03.17
4. [오류수정] zabbix DB Replication error  (0) 2021.03.17
3. [이중화] zabbix DB replication  (0) 2021.03.17
2. zabbix Agent 환경  (0) 2021.03.17