基于zabbix 的memached 多实例监控

基于zabbix 的memached 多实例监控

  1. 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/',$'/]}/g

    UserParameter=memcached.server.status[*],echo -e "stats\nquit" | nc $1 $2 |grep -v END| sed -e s/STAT//g | sed -e s/[1]//g | awk '{printf ""%s":%d,",$$1,$$2}' |tr -d \n | sed -e s/^/'{"memcached":{'/g -e s/',$'/}}/g

  2. 导入模板


  1. [:space:] ↩︎

posted on 2019-04-19 18:41  非法操作  阅读(172)  评论(0编辑  收藏  举报

导航