kafka lag 监控脚本

阅读更多
 
shell脚本获取lag值
 
[root@tingyun-kafka-01 zabbix]# cat kafka-lag.sh
#!/bin/sh
#power by [email protected]
zookeeper_server=192.168.110.12:2181,192.168.110.13:2181,192.168.110.14:2181,192.168.110.15:2181,192.168.110.16:2181
GROUP=$1
TOPIC=$2
cd /opt/kafka/bin/ && ./kafka-consumer-offset-checker.sh --zookeeper $zookeeper_server --topic $TOPIC --group $GROUP | grep -v 'will be dropped in releases'  | awk 'NR>1{a+=$6}END{print a}'
 
zabbix 客户端被动模式 从server端拉去客户端数据
 
[root@tingyun-kafka-01 zabbix]# cat /etc/zabbix/zabbix_agentd.
zabbix_agentd.conf  zabbix_agentd.d/   
[root@tingyun-kafka-01 zabbix]# cat /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
# For all the following commands HOME should be set to the directory that has .my.cnf file with password information.
# Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
# Key syntax is mysql.status[variable].
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
# Key syntax is mysql.size[,,].
# Database may be a database name or "all". Default is "all".
# Table may be a table name or "all". Default is "all".
# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
# Database is mandatory if a table is specified. Type may be specified always.
# Returns value in bytes.
# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V
#tingyun kafka lag
UserParameter=q-newlens-mobile-errors-persist,/opt/zabbix/kafka-lag.sh q-newlens-mobile-errors-persist mobileErrors  2>/dev/null
UserParameter=q-newlens-mobile-interaction-traces-wrappedmessages,/opt/zabbix/kafka-lag.sh q-newlens-mobile-interaction-traces-wrappedmessages mobileInteractionTracesWrappedMessages  2>/dev/null
UserParameter=q-newlens-mobile-actions-wrappedmessages,/opt/zabbix/kafka-lag.sh q-newlens-mobile-actions-wrappedmessages mobileActionsWrappedMessages  2>/dev/null
UserParameter=q-newlens-mobile-actions-wrappedmessages-alarm,/opt/zabbix/kafka-lag.sh q-newlens-mobile-actions-wrappedmessages-alarm mobileActionsWrappedMessages  2>/dev/null
UserParameter=q-newlens-mobile-crash-alarm,/opt/zabbix/kafka-lag.sh q-newlens-mobile-crash-alarm crashMessage   2>/dev/null
UserParameter=q-newlens-report-user-traces-persist,/opt/zabbix/kafka-lag.sh q-newlens-report-user-traces-persist mobileReportUsers  2>/dev/null
UserParameter=q-newlens-mobile-errors-wrappedmessages,/opt/zabbix/kafka-lag.sh q-newlens-mobile-errors-wrappedmessages mobileErrorsWrappedMessages   2>/dev/null
UserParameter=q-newlens-mobile-interaction-traces-persist,/opt/zabbix/kafka-lag.sh q-newlens-mobile-interaction-traces-persist mobileInteractionTraces   2>/dev/null
UserParameter=q-newlens-report-users-wrappedmessages,/opt/zabbix/kafka-lag.sh q-newlens-report-users-wrappedmessages mobileReportUsersWrappedMessages   2>/dev/null
UserParameter=q-newlens-appserver-metrics-persist,/opt/zabbix/kafka-lag.sh q-newlens-appserver-metrics-persist mobileActions  2>/dev/null
kafka lag 监控脚本_第1张图片
 
 
 
kafka lag 监控脚本_第2张图片
 
 
 

 
 
 
 

 
 
 
 
 
 

 
 
 
 

  • kafka lag 监控脚本_第3张图片
  • 大小: 42.6 KB
  • kafka lag 监控脚本_第4张图片
  • 大小: 44.1 KB
  • 查看图片附件

你可能感兴趣的:(kafka)