简体   繁体   English

"使用 Jolokia 监控同一 Tomcat 服务器上 webapp 的 JMX 端点"

[英]Use Jolokia to monitor JMX endpoint of webapp on same Tomcat server

Jolokia<\/a> is uncharted territory for me, and after having read the documentation, I'm still not sure if it'll work with the scenario I have in mind. Jolokia<\/a>对我来说是一个未知领域,在阅读了文档之后,我仍然不确定它是否适用于我想到的场景。

Setup:<\/strong>设置:<\/strong>

First of all, Jolokia by passes the JSR-160 connector stuff completely, so there is no need for any JMX/RMI authentication. 首先,Jolokia完全通过了JSR-160连接器,因此不需要任何JMX / RMI身份验证。 The whole purpose of Jolokia is to provide a bridge over HTTP/JSON to the internal JMX subsystem. Jolokia的全部目的是通过HTTP / JSON提供到内部 JMX子系统的桥梁。 Depending on the agent, you can secure Jolokia quite easily. 根据代理,您可以很轻松地保护Jolokia。 For the WAR agent, securing is the same as for any Java EE web app: Setup some roles and users for tomcat (eg in tomcat-users.xml ) and reference the role in the security contstraints within the jolokia.war 's /WEB-INF/web.xml . 对于WAR代理,安全性与任何Java EE Web应用程序相同:为tomcat设置一些角色和用户(例如,在tomcat-users.xml ),并在jolokia.war/WEB-INF/web.xml内的安全性约束中引用该角色。 /WEB-INF/web.xml

To your questions: 对您的问题:

  1. Yes, you can. 是的你可以。 If you don't have any specific authentication needs, simply drop the jolokia.war into tomcat's /webapps directory. 如果您没有任何特定的身份验证需求,只需将jolokia.war放到tomcat的/webapps目录中。 I suggest to try this first before adding security. 我建议在增加安全性之前先尝试一下。 For deinstalling the agent, simply remove the war. 要卸载该代理,只需删除战争。

  2. As an alternative, you could also use the JVM agent, which opens an own HTTP server on an extra port (default: 8778). 或者,您也可以使用JVM代理,该代理在额外的端口上打开自己的HTTP服务器(默认值:8778)。 More on this in the reference manual 参考手册中的更多内容

  3. There is no need for a dedicated connection to the web app since MBeans are registered globally and are accesible from anywhere in the JVM. 由于MBean是全局注册的,并且可以从JVM中的任何位置访问,因此不需要专用的Web应用程序连接。 A webapp should of course select carefully the management information it exposes. Web应用程序当然应该仔细选择它公开的管理信息。 So, there is no extra step needed and you can access the MBeans for the WEB app directly (except when it does something unusual with Java security, but I don't think so). 因此,不需要任何额外的步骤,您可以直接访问用于WEB应用程序的MBean(除非它在Java安全性方面做一些不寻常的事情,但我认为不是)。

To test the installation, simply connect to the Tomcat with your browser and the context /jolokia (eg " http://localhost:8080/jolokia "). 要测试安装,只需使用浏览器和上下文/jolokia (例如“ http:// localhost:8080 / jolokia ”)连接到Tomcat。 You should see the version information about the agent itself. 您应该看到有关代理本身的版本信息。

The next step would be to explore the JMX namespace, either with the browser (and operation "list" like in http://localhost:8080/jolokia/list , but that's tedious) or with a client like j4psh or hawt.io . 下一步将使用浏览器(和类似http:// localhost:8080 / jolokia / list的操作“列表”,但这很乏味)或使用诸如j4pshhawt.io的客户端来探索JMX命名空间。 Hopefully you will find the MBeans of your webapp you are looking for. 希望您会找到所需的Web应用程序的MBean。

I tried to follow carefully the tutorial on the Jolokia website.我尝试仔细按照 Jolokia 网站上的教程进行操作。 I put the Jolokia Agent War on the webapps folder of the Tomcat and started it.我把 Jolokia Agent War 放到 Tomcat 的 webapps 文件夹下,然后启动。 When I finally go to verify the installation, point my browser to http://localhost:8080/jolokia/version ==> I get no response on my browser : Website not accessible.当我最终验证安装时,将浏览器指向 http://localhost:8080/jolokia/version ==> 我的浏览器没有响应:网站无法访问。 When I try a curl on the same URL, I get this output :当我在同一个 URL 上尝试 curl 时,我得到以下输出:

curl http://localhost:8080/jolokia/version <!doctype html>HTTP Status 401 – UnauthorizedH1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;} curl http://localhost:8080/jolokia/version <!doctype html>HTTP 状态 401 - UnauthorizedH1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size: 22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color :white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma, Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color :黑色;}A.name {颜色:黑色;}HR {颜色:#525D76;}

HTTP Status 401 – Unauthorized HTTP 状态 401 - 未经授权

Type Status Report类型状态报告

Description The request has not been applied because it lacks valid authentication credentials for the target resource.说明该请求未应用,因为它缺少目标资源的有效身份验证凭据。

Apache Tomcat/7.0.92 Apache Tomcat/7.0.92

Any help will be much appreciated, Thanks !任何帮助将不胜感激,谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM