html tool

2012年8月22日星期三

monitor-tomcat


montior-tomcat
工作原因近日要监控服务器的性能,这次的是tomcat,默认的manager提供的内容太少了,找了些三方的监控工具,总结如下:
1.Probe
来源地址:https://code.google.com/p/psi-probe/
下载:
当前看到的最新包是probe-2.3.1.zip
不过安全起,自己下载的是probe-2.3.0.zip
配置:
[参考:https://code.google.com/p/psi-probe/wiki/InstallationApacheTomcat]
关于ApacheTomcat的,wiki中看到还提供JBoss Application Server的。
官方要求的权限为:
probeuser
poweruser
poweruserplus
manager - This is the same role required by Tomcat Manager and has the highest level of privileges.[popexizhi:这个应该是tomcat原有的权限,我看了一下默认的tomcat-users.xml是有这个的不用添加的]
Note: On Tomcat 7 (or Tomcat 6.0.30 and above), you can use manager-gui instead of manager.[popexizhi:Tomcat7可以只使用manager-gui权限就可以了,好吧,我的是6.0.32,看来还是manager.]
然后就是加下文到 $CATALINA_HOME/conf/tomcat-users.xml[popexizhi:我的配置权限的文件位置没有调整,这个是可以用的,ok]


 
 
 
 

 


补充一下,原文说:
If you are not using the default configuration, add these roles as appropriate for your Realm. Some Realm configurations, such as a JNDIRealm connecting to LDAP, will not require a server restart.

如果你的默认权限配置改了,就加这个到你的Realm,好吧!我承认自己一点儿都不熟悉tomcat,不过看来可以有时间试试:),先改,后配置[next]

下面是Enable Remote JMX的,go了一下这个应该是一个远程连接使用检测资源的,所以我没去管它,mark一下以防使用[popexizhi:愈加感觉自己是个java盲了:)]

启动tomcat之后-----当然要把下载的war包放到webapps下再启动了------在http://hostname/probe/ 访问就ok了,用户名和密码是刚才设置的admin/t0psecret.

2.javamelody
来源地址:https://code.google.com/p/javamelody/wiki/UserGuide?tm=6
这个是之前测试zf时兵哥提供的,嘻嘻,这次那里就用,小谢兵哥一下。

下载地址:https://code.google.com/p/javamelody/downloads/list
这个是javamelody.jar的下载位置,

还有一个jrobm-x.jar的文件
http://javamelody.googlecode.com/files/jrobin-1.5.9.jar
也可以下载到

拷贝到要检测应用的WEB-INF/lib 下,

修改应用的 WEB-INF/web.xml 添加
      
       
                monitoring
                net.bull.javamelody.MonitoringFilter
       
       
                monitoring
                /*
       
       
                net.bull.javamelody.SessionListener
       




[popexizhi:写到这里突然感觉,这个过程很像是python中的包的__init__.py文件,:)好吧,我又臆测了]
原文中说了
If you add these lines in a Servlet API 3.0 webapp, you may also add true in the filter to support asynchronous requests.
好吧我应该没有用Servlet API 3.0 webapp吧?!我是java盲是一定的了。所以没有管这里。

启动tomcat,
http:////monitoring 中查看到了,这个不错还有中文版。:)
原文中还说:PDF report generation
To generate PDF reports as well as html reports, adding the library iText v2.1.x is required (licence LGPL or MPL, the iText jar file alone is enough, without the other dependencies like iText-rtf).

Copy the file itext-2.1.7.jar, located in the directory src/test/test-webapp/WEB-INF/lib/ of the supplied javamelody.zip file, to the WEB-INF/lib directory of the war of the webapp to monitor. The PDF link will be available at the top of the html report.
像html一样的PDF在加个jar包,好吧mark一下,以后用。

好吧总结时才发现,下文还多着呢:
5.Supplements in web.xml
6. Optional parameters
7. JDBC
8. Business facades (ejb-jar.xml file if EJB3)
9. Business facades (if Spring)
10. Business facades (if Guice)
。。。
15. Database user
。。。

看了回头可以好好研究了。

我的启动后是有数据有图像了,ok,先总结到这里,
我的两个发现吧,
1.probe可以动态调整tomcat的日志类型,我喜欢,现在调整ld的脚本可以方便了,这也是我的下一步
2.javamelody的分类太全了,好好学习,争取详细了解每个参数。


2 条评论:

  1. 补充关于PDF导出:
    原文中指定如下:
    Copy the file itext-2.1.7.jar, located in the directory src/test/test-webapp/WEB-INF/lib/ of the supplied javamelody.zip file, to the WEB-INF/lib directory of the war of the webapp to monitor. The PDF link will be available at the top of the html report.
    自己开始使用的itext的最新版本5.3.2 加载后没有什么效果,最后在http://grepcode.com/snapshot/repo1.maven.org/maven2/com.lowagie/itext/2.1.7下载了 指定的 2.1.7的版本,好吧重启后即看到上方提供的PDF导出的按钮了。

    回复删除
  2. 补充:
    http://www.blogjava.net/anchor110/articles/330055.html
    这里的 设置环境变量,获取服务器状态
    # vi /etc/profile
    JAVA_OPTS=-Dcom.sun.management.jmxremote
    export JAVA_OPTS

    我没有加入,加入了一下。但是不知道有什么特殊的位置郁闷去了

    回复删除