zabbix监控zookeeper
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix监控zookeeper相关的知识,希望对你有一定的参考价值。
1、下载和导入模板zbx_zookeeper_templates.xml,模板下载地址https://github.com/flaviotorres/zabbix/tree/23b005fdff7ebe962f72559105be90e457ee20e82、创建zookeeper监控脚本/home/zabbix/scripts/check_zookeeper_trapper.sh,脚本内容如下
#!/usr/bin/env bash # grab , print and send zookeeper monitoring values to zabbix via zabbix_sender # ZooKeeper Commands: The Four Letter Words in: http://zookeeper.apache.org/doc/r3.4.6/zookeeperAdmin.html # Flavio Torres, ftorres_ig.com.br # Mar, 2014 # v1, beta TMPFILE=`mktemp --suffix=-zookeeper-monitoring` TMPFILE2=`mktemp --suffix=-zookeeper-monitoring` ZABBIX=$(awk -F= '/^ServerActive/ { print $2 } ' /usr/local/zabbix/etc/zabbix_agentd.conf) trap "rm -f $TMPFILE; rm -f $TMPFILE2 ; exit" SIGHUP SIGINT SIGTERM EXIT echo "mntr" | curl -s telnet://localhost:2181 > $TMPFILE RUNNING_OK=$(echo "ruok" | curl -s telnet://localhost:2181) if [ $RUNNING_OK = 'imok' ];then echo "zk_running_ok 0" >> $TMPFILE else # NOK or with no response echo "zk_running_ok 1" >> $TMPFILE fi IFS=$'\n' for d in `cat $TMPFILE` do echo "192.168.1.32 $d" >> $TMPFILE2 done IFS="" /usr/local/zabbix/bin/zabbix_sender -z $ZABBIX -i $TMPFILE2 rm -f $TMPFILE ; rm -f $TMPFILE2
注意:需要把192.168.1.32改成相应主机的IP
3、修改zabbix agent配置文件
UnsafeUserParameters=1
UserParameter=zookeeper_collect,(/home/zabbix/scripts/check_zookeeper_trapper.sh > /dev/null; echo $?)
4、重启zabbix agent
5、将主机和模板关联起来
以上是关于zabbix监控zookeeper的主要内容,如果未能解决你的问题,请参考以下文章