1、下载安装包
http://central.maven.org/maven2/org/jmxtrans/jmxtrans/
在这个地址上选择自己所需要的版本,并下载rpm包,我选择jmxtrans-259.rpm
2、安装
执行命令
[root@dx3 local]# rpm -i jmxtrans-259.rpm
如果有以下错误
[root@dx3 local]# rpm -i jmxtrans-259.rpm error: Failed dependencies: java >= 1.7 is needed by jmxtrans-259-1.noarch
则执行命令
[root@dx3 local]# rpm -i jmxtrans-259.rpm --nodeps --force
3、查看安装
默认应用安装在 /usr/share/jmxtrans目录下
初始化脚本目录 /etc/init.d/jmxtrans
json文件存放位置 /var/lib/jmxtrans
4、调试,查看
将日志等级修改为DEBUG
修改配置文件/usr/share/jmxtrans/etc/wrapper.conf中的wrapper.java.additional.5=-Djmxtrans.log.level=DEBUG
日志文件目录 wrapper.java.additional.6=-Djmxtrans.log.dir=/var/log/jmxtrans
在/var/lib/jmxtrans目录下创建编写自己的查询文件(json格式)
{ "servers": [ { "host": "dx2.zdp.ol", "port": "22222", "queries": [ { "outputWriters": [ { "@class": "com.googlecode.jmxtrans.model.output.GangliaWriter", "settings": { "groupName": "jmxtrans","host": "100.100.160.200","port": "8649" } } ], "obj": "kafka.consumer:type=ConsumerFetcherManager,name=MaxLag,clientId=flume", "resultAlias": "dx2_22222.ConsumerFetcherManager.MaxLag" } ], "numQueryThreads": 2 } ] }
5、启动脚本
[root@dx2 bin]# pwd /usr/share/jmxtrans/bin [root@dx2 bin]# ./jmxtrans start /var/lib/jmxtrans/dx2_jmxtrans.json
6、查看日志文件
[root@dx2 bin]# tail -f /var/log/jmxtrans/jmxtrans.log
部分日志文件 [09 九月 2016 14:21:10] [jmxtrans-result-5] 1715596 DEBUG (com.googlecode.jmxtrans.model.output.GangliaWriter:201) - Sending Ganglia metric dx2_33334_PMSGateway.ConsumerFetcherManager.MaxLag.Value=0 [type=INT32] [09 九月 2016 14:21:10] [jmxtrans-result-5] 1715596 DEBUG (com.googlecode.jmxtrans.model.output.GangliaWriter:201) - Sending Ganglia metric dx2_33334_PMSGateway.ConsumerFetcherManager.MaxLag.Value=0 [type=INT32] [09 九月 2016 14:21:12] [ServerScheduler_Worker-6] 1717578 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:58) - +++++ Started server job: Server(pid=null, host=dx2.zdp.ol, port=33336, url=service:jmx:rmi:///jndi/rmi://dx2.zdp.ol:33336/jmxrmi, cronExpression=null, numQueryThreads=0) [09 九月 2016 14:21:12] [ServerScheduler_Worker-6] 1717578 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:58) - +++++ Started server job: Server(pid=null, host=dx2.zdp.ol, port=33336, url=service:jmx:rmi:///jndi/rmi://dx2.zdp.ol:33336/jmxrmi, cronExpression=null, numQueryThreads=0) [09 九月 2016 14:21:12] [ServerScheduler_Worker-6] 1717578 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:64) - +++++ Finished server job: Server(pid=null, host=dx2.zdp.ol, port=33336, url=service:jmx:rmi:///jndi/rmi://dx2.zdp.ol:33336/jmxrmi, cronExpression=null, numQueryThreads=0) [09 九月 2016 14:21:12] [ServerScheduler_Worker-6] 1717578 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:64) - +++++ Finished server job: Server(pid=null, host=dx2.zdp.ol, port=33336, url=service:jmx:rmi:///jndi/rmi://dx2.zdp.ol:33336/jmxrmi, cronExpression=null, numQueryThreads=0)
7、从输出端Ganglia查看效果
本文出自 “巧克力黑” 博客,请务必保留此出处http://10120275.blog.51cto.com/10110275/1851106
原文地址:http://10120275.blog.51cto.com/10110275/1851106