2. zabbix监控Flume
#JVM性能监控
Young GC counts
sudo /usr/local/jdk1.7.0_21/bin/jstat -gcutil $(pgrep java)|tail -1|awk '{print $6}'
Full GC counts
sudo /usr/local/jdk1.7.0_21/bin/jstat -gcutil $(pgrep java)|tail -1|awk '{print $8}'
JVM total memory usage
sudo /usr/local/jdk1.7.0_21/bin/jmap -histo $(pgrep java)|grep Total|awk '{print $3}'
JVM total instances usage
sudo /usr/local/jdk1.7.0_21/bin/jmap -histo $(pgrep java)|grep Total|awk '{print $2}'
#flume应用参数监控
启动时加上JSON repoting参数,这样就可以通过:34545/metrics访问
flume-ng agent -c . -f exec.conf -n a1 -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=34545
#生成一些数据
for i in {1..100};do echo "exec test$i" >> /usr/logs/log.10;echo $i;done
#通过shell脚本对JSON输出进行排版
[root@cc-staging-loginmgr2 conf]# curl :34545/metrics 2>/dev/null|sed -e 's/\([,]\)\s*/\1\n/g' -e 's/[{}]/\n/g' -e 's/[",]//g'
CHANNEL.c1:
EventPutSuccessCount:100
ChannelFillPercentage:0.0
Type:CHANNEL
StopTime:0
EventPutAttemptCount:100
ChannelSize:0
StartTime:1371709073310
EventTakeSuccessCount:100
ChannelCapacity:1000
EventTakeAttemptCount:115
#配置监控flume的脚本文件
[root@cc-staging-loginmgr2 conf]#cat /opt/scripts/monitor_flume.sh
curl :34545/metrics 2>/dev/null|sed -e 's/\([,]\)\s*/\1\n/g' -e 's/[{}]/\n/g' -e 's/[",]//g'|grep $1|awk -F: '{print $2}'
#在zabbix agent配置文件进行部署
cat /etc/zabbix/zabbix_agentd/zabbix_agentd.userparams.conf
UserParameter=ygc.counts,sudo /usr/local/jdk1.7.0_21/bin/jstat -gcutil $(pgrep java|head -1)|tail -1|awk '{print $6}'
UserParameter=fgc.counts,sudo /usr/local/jdk1.7.0_21/bin/jstat -gcutil $(pgrep java|head -1)|tail -1|awk '{print $8}'
UserParameter=jvm.memory.usage,sudo /usr/local/jdk1.7.0_21/bin/jmap -histo $(pgrep java|head -1)|grep Total|awk '{print $3}'
UserParameter=jvm.instances.usage,sudo /usr/local/jdk1.7.0_21/bin/jmap -histo $(pgrep java|head -1)|grep Total|awk '{print $2}'
UserParameter=flume.monitor[*],/bin/bash /opt/scripts/monitor_flume.sh $1