/kafkaMonitor

kafka realtime command line monitor tools.

Primary LanguageJava

Kafka Monitor

kafka Monitor 是一个对kafka进行实时监控的命令行工具。 目前只实现了相对简单的功能。后续会随着需求增加新的监控指标。

原理是通过jmx获取响应监控值,并每隔1s打印到标准输出屏幕上。

jdk1.8 及以上:

编译方式: mvn clean package

用法:

    $ java -jar kafkaMonitor-1.0.jar
    usage: java -jar kafkaMonitor-1.0.jar  [OPTION]
        -brokerlist <arg>   The broker list string in
                            the form HOST1:PORT1
        -help               The help information
        -n <arg>            The times for monitor printout.Default 100.
        -topic <arg>        The topic you want monitor, Don't assign means
                            monitor all Topic.

输出:

不指定topic值,则监控的是所有topic的性能指标。
$ java -jar kafkaMonitor-1.0.jar -brokerlist 10.47.135.175:59092
Begin to connect:service:jmx:rmi:///jndi/rmi://10.47.135.175:59092/jmxrmi
Connection ok!
################################################
## ALL Topic Performance Info.
################################################
+-----  time  -----+------ All  Topic MPS --------+---------- Net In KB ----------+--------- Net Out KB ----------+
|                  |--msgSum--|--msg1M--|--msg5M--|--InSum(MB)--|--In1M--|--In5M--|--InSum(MB)--|--In1M--|--In5M--|
+-------------------------------------------------+-------------------------------+-------------------------------+
2017-09-19 16:11:44 274893048    177.87    178.78        464717   337.23   341.93        941970   563.28   574.69
2017-09-19 16:11:45 274893232    177.87    178.78        464718   337.23   341.93        941970   563.28   574.69
2017-09-19 16:11:46 274893392    177.87    178.78        464718   337.23   341.93        941971   563.28   574.69
2017-09-19 16:11:47 274893550    177.87    178.78        464718   337.23   341.93        941972   563.28   574.69
2017-09-19 16:11:48 274893703    176.80    178.54        464719   338.17   342.04        941972   565.26   574.91
2017-09-19 16:11:49 274893873    176.80    178.54        464719   338.17   342.04        941972   565.26   574.91
2017-09-19 16:11:50 274894061    176.80    178.54        464719   338.17   342.04        941973   565.26   574.91
2017-09-19 16:11:51 274894228    176.80    178.54        464719   338.17   342.04        941973   565.26   574.91
2017-09-19 16:11:52 274894414    176.80    178.54        464720   338.17   342.04        941974   565.26   573.38
2017-09-19 16:11:53 274894564    175.77    178.30        464720   334.39   341.20        941974   558.64   573.38
+-----  time  -----+------ All  Topic MPS --------+---------- Net In KB ----------+--------- Net Out KB ----------+
|                  |--msgSum--|--msg1M--|--msg5M--|--InSum(MB)--|--In1M--|--In5M--|--InSum(MB)--|--In1M--|--In5M--|
+-------------------------------------------------+-------------------------------+-------------------------------+
2017-09-19 16:11:54 274894746    175.77    178.30        464720   334.39   341.20        941975   558.64   573.38
2017-09-19 16:11:55 274894921    175.77    178.30        464721   334.39   341.20        941975   558.64   573.38
2017-09-19 16:11:56 274895079    175.77    178.30        464721   334.39   341.20        941976   558.64   573.38
2017-09-19 16:11:57 274895277    175.09    178.12        464722   334.69   341.15        941977   559.55   573.33
2017-09-19 16:11:58 274895579    175.09    178.12        464722   334.69   341.15        941977   559.55   573.33
2017-09-19 16:11:59 274895765    175.09    178.12        464722   334.69   341.15        941978   559.55   573.33
2017-09-19 16:12:00 274895922    175.09    178.12        464723   334.69   341.15        941978   559.55   573.33
2017-09-19 16:12:01 274896121    175.09    178.12        464723   334.69   341.15        941979   559.55   573.33
2017-09-19 16:12:02 274896316    177.51    178.57        464723   335.79   341.27        941980   559.39   573.06
2017-09-19 16:12:03 274896509    177.51    178.57        464724   335.79   341.27        941981   559.39   573.06
 
 
指定topic值,则监控的是指定topic的性能指标。
$ java -jar kafkaMonitor-1.0.jar -brokerlist 10.47.135.175:59092 -topic TopicPlatformAccessLog
Begin to connect:service:jmx:rmi:///jndi/rmi://10.47.135.175:59092/jmxrmi
Connection ok!
################################################
## Topic Name: TopicPlatformAccessLog
################################################
+-----  time  -----+------ This Topic MPS --------+---------- Net In KB ----------+---------- Net Out KB ---------+
|                  |--msgSum--|--msg1M--|--msg5M--|--InSum(MB)--|--In1M--|--In5M--|--InSum(MB)--|--In1M--|--In5M--|
+-------------------------------------------------+-------------------------------+-------------------------------+
2017-09-19 16:11:13  81216002     54.02     54.21        102740    69.53    69.79        205918    69.97    70.22
2017-09-19 16:11:14  81216071     54.02     54.21        102740    69.53    69.79        205918    69.97    70.22
2017-09-19 16:11:15  81216123     54.02     54.21        102740    69.53    69.79        205918    69.97    70.22
2017-09-19 16:11:16  81216170     54.07     54.22        102740    69.58    69.79        205918    70.01    70.23
2017-09-19 16:11:17  81216235     54.07     54.22        102740    69.58    69.79        205918    70.01    70.23
2017-09-19 16:11:18  81216277     54.07     54.22        102740    69.58    69.79        205918    70.01    70.23
2017-09-19 16:11:19  81216327     54.07     54.22        102740    69.58    69.79        205918    70.01    70.23
2017-09-19 16:11:20  81216385     54.07     54.22        102740    69.58    69.79        205918    70.01    70.23
2017-09-19 16:11:21  81216430     53.86     54.17        102740    69.30    69.73        205918    69.73    70.16
2017-09-19 16:11:22  81216488     53.86     54.17        102741    69.30    69.73        205919    69.73    70.16
+-----  time  -----+------ This Topic MPS --------+---------- Net In KB ----------+---------- Net Out KB ---------+
|                  |--msgSum--|--msg1M--|--msg5M--|--InSum(MB)--|--In1M--|--In5M--|--InSum(MB)--|--In1M--|--In5M--|
+-------------------------------------------------+-------------------------------+-------------------------------+
2017-09-19 16:11:23  81216537     53.86     54.17        102741    69.30    69.73        205919    69.73    70.16
2017-09-19 16:11:24  81216583     53.86     54.17        102741    69.30    69.73        205919    69.73    70.16
2017-09-19 16:11:25  81216641     53.86     54.17        102741    69.30    69.73        205919    69.73    70.16
2017-09-19 16:11:26  81216693     53.80     54.16        102741    69.19    69.70        205919    69.62    70.13
2017-09-19 16:11:27  81216754     53.80     54.16        102741    69.19    69.70        205919    69.62    70.13
2017-09-19 16:11:28  81216819     53.80     54.16        102741    69.19    69.70        205919    69.62    70.13
2017-09-19 16:11:29  81216860     53.80     54.16        102741    69.19    69.70        205919    69.62    70.13
2017-09-19 16:11:30  81216922     53.80     54.16        102741    69.19    69.70        205919    69.62    70.13
2017-09-19 16:11:32  81216985     53.68     54.12        102741    69.03    69.66        205919    69.46    70.09
2017-09-19 16:11:33  81217033     53.68     54.12        102741    69.03    69.66        205919    69.46    70.09