基于zabbix 的memached 多实例监控
-
zabbix agentd 配置文件新增配置:
UserParameter=memcached.server.discovery[*],ps uax |grep $1|grep -v grep | while read line; do if [[ -n "$line" ]]; then echo "{"; memcached_host=
echo $line |grep -Eo '\-l[[:space:]]+(([0-9]{1,3}\.){3}[0-9]{1,3})'|sed -e s/-l//g| sed -e s/[[:space:]]//g
; echo ""{#MEMCACHED_HOST}":"$memcached_host","; memcached_port=echo $line |grep -Eo '\-p[[:space:]]+[0-9]{2,7}'|sed -e s/-p//g| sed -e s/[[:space:]]//g
; echo ""{#MEMCACHED_PORT}":$memcached_port"; echo "},"; fi; done| tr -d \n| sed -e s/^/'{"data":['/g -e s/',$'/]}/gUserParameter=memcached.server.status[*],echo -e "stats\nquit" | nc $1 $2 |grep -v END| sed -e s/STAT//g | sed -e s/^[[:space:]]//g | awk '{printf ""%s":%d,",$$1,$$2}' |tr -d \n | sed -e s/^/'{"memcached":{'/g -e s/',$'/}}/g
导入模板