Re: tomcat jmx questions / help
Hi Chris, Am 28.03.2018 um 21:06 schrieb Christopher Schultz: Also, for some background: https://tomcat.apache.org/presentations.html Search the page for "jmx". Good stuff, thanks for the pointer! Regards, Rainer - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: tomcat jmx questions / help
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Rainer, On 3/28/18 2:49 PM, Rainer Jung wrote: > I hope my below answers are all correct, but most should be. > > Am 28.03.2018 um 20:25 schrieb Greg Kaszycki: >> Tomcat version 7.0.82 >> >> I have some questions about tomcat monitoring and jmx. The short >> version is that I am trying to get session information about >> users logged into my app. >> >> I see documentation about different ways to get to the jmx beans >> but I don't understand the relationship between them. >> >> http://localhost:8080/ takes me to the tomcat homepage and I can >> click on the manager button and get to a page with some links to >> application folders (I've set my role). Do they use jmx beans? > > No. > >> I can also do like: >> http://localhost:8080/manager/text/sessions?path=/. and it >> returns number of sessions. Is that accessing an mbean? How >> does that name relate to the folders under the tomcat manager >> folder? > > No access to mbeans. No relation to folders. URIs can either point > to static content, JSPs or to servlets( code) that dynamically > enerate the responses. Your example points to a servlet, so no > relation with folders. How does Tomcat know, which URI relates to > which servlet? That's described in the servlet specification > (standards document) and one way is declaring servlets and their > mapping path in the config file WEB-INF/web.xml inside the webapp. > >> I can also access >> http://localhost:8080/manager/jmxproxy/?get=java.lang.type=Memory =HeapMemoryUsage >> >> >> and get memory usage stats. Is that accessing an mbean? > > Yes. The same web.xml file mapps the URI /jmxproxy underneath the > manager webapp to the so called JMXProxy servlet. That servlet > typically produces all it's responses from data retrieved > internally from MBeans. In the above case you are retrieving the > attribute named HeapMemoryUsage form an MBean named > java.lang.type=Memory (I think it should be: > java.lang:type=Memory). > >> I also don't see how these names relates to going to jconsole and >> looking at the mbean tab and accessing >> Catalina/Manager/examples/localhost. The names of the attributes >> in jconsole don't seem to match the names of the beans that I can >> access like the memory example above. > > They should without your typo. In jconsole you should find a MBean > group named java.lang and if you open that patr of the MBean tree, > you will finde the Memory-MBean there. You other path > "Catalina/Manager/examples/localhost" seems to be totally unrelated > (or I have not fully understood your question). > >> I found that memory example above online, but where are these >> beans documented? The documentation in > > Some of the MBeans - for example the Memory MBean - are part of any > Java process, not just Tomcat. So expect them to be documented in > generic Java docs. Since not only Tomcat, but also applications can > create their own additional MBean, these basic Java MBeans that > always exist are also called "platform mbeans". The first hit in a > search engine points to > > https://docs.oracle.com/javase/7/docs/technotes/guides/management/mxbe ans.html > > > > which starts describing how to access mbeans for developers, but in > the second part of the document also introduces to the data > contained in some of the platform MBeans. In addition to docs, it > is always very instructive to simply use a tool like JConsole (or > more modern JVisualVM) to click through the MBean tree and observe > what's there. Start with an easy setup, where you run Tomcat and > these GUI tools on the same machine. > > The Tomcat specific MBeans are listen in > https://tomcat.apache.org/tomcat-9.0-doc/funcspecs/mbean-names.html, > but I don't know how current that document is. It also gives no > hints, what data is actually contained in those MBeans. Most of the > MBean attributes have very descriptive names, so again browsing > through the tree helps a bit. > >> https://tomcat.apache.org/tomcat-7.0-doc/monitoring.html said I >> could also access it through a url like: >> service:jmx:rmi:///jndi/rmi://localhost:8081/jmxrmi but I could >> not get that to work. Would that access the same bean(s) as the >> other examples? > > I would start interactively with JConsole or JVisualVM to get an > idea what's there. You can also get a full textual dump with > > https://tomcat.apache.org/tomcat-9.0-doc/funcspecs/mbean-names.html?qr y=*:* > > That command and some more is explained e.g. in > https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html > > Then you need to decide, via which network protocol you want to > access MBean data remotely. You could either use an agent deployed > as a webapp inside Tomcat, speak http(s) to Tomcat and the agent > retrieves the data internally via JVM and returns a textual > representation. The manager webapp JMXProxy servlet is one such > agent, but it has some deficiencies. > > You could also look at
Re: tomcat jmx questions / help
I hope my below answers are all correct, but most should be. Am 28.03.2018 um 20:25 schrieb Greg Kaszycki: Tomcat version 7.0.82 I have some questions about tomcat monitoring and jmx. The short version is that I am trying to get session information about users logged into my app. I see documentation about different ways to get to the jmx beans but I don't understand the relationship between them. http://localhost:8080/ takes me to the tomcat homepage and I can click on the manager button and get to a page with some links to application folders (I've set my role). Do they use jmx beans? No. I can also do like: http://localhost:8080/manager/text/sessions?path=/. and it returns number of sessions. Is that accessing an mbean? How does that name relate to the folders under the tomcat manager folder? No access to mbeans. No relation to folders. URIs can either point to static content, JSPs or to servlets( code) that dynamically enerate the responses. Your example points to a servlet, so no relation with folders. How does Tomcat know, which URI relates to which servlet? That's described in the servlet specification (standards document) and one way is declaring servlets and their mapping path in the config file WEB-INF/web.xml inside the webapp. I can also access http://localhost:8080/manager/jmxproxy/?get=java.lang.type=Memory=HeapMemoryUsage and get memory usage stats. Is that accessing an mbean? Yes. The same web.xml file mapps the URI /jmxproxy underneath the manager webapp to the so called JMXProxy servlet. That servlet typically produces all it's responses from data retrieved internally from MBeans. In the above case you are retrieving the attribute named HeapMemoryUsage form an MBean named java.lang.type=Memory (I think it should be: java.lang:type=Memory). I also don't see how these names relates to going to jconsole and looking at the mbean tab and accessing Catalina/Manager/examples/localhost. The names of the attributes in jconsole don't seem to match the names of the beans that I can access like the memory example above. They should without your typo. In jconsole you should find a MBean group named java.lang and if you open that patr of the MBean tree, you will finde the Memory-MBean there. You other path "Catalina/Manager/examples/localhost" seems to be totally unrelated (or I have not fully understood your question). I found that memory example above online, but where are these beans documented? The documentation in Some of the MBeans - for example the Memory MBean - are part of any Java process, not just Tomcat. So expect them to be documented in generic Java docs. Since not only Tomcat, but also applications can create their own additional MBean, these basic Java MBeans that always exist are also called "platform mbeans". The first hit in a search engine points to https://docs.oracle.com/javase/7/docs/technotes/guides/management/mxbeans.html which starts describing how to access mbeans for developers, but in the second part of the document also introduces to the data contained in some of the platform MBeans. In addition to docs, it is always very instructive to simply use a tool like JConsole (or more modern JVisualVM) to click through the MBean tree and observe what's there. Start with an easy setup, where you run Tomcat and these GUI tools on the same machine. The Tomcat specific MBeans are listen in https://tomcat.apache.org/tomcat-9.0-doc/funcspecs/mbean-names.html, but I don't know how current that document is. It also gives no hints, what data is actually contained in those MBeans. Most of the MBean attributes have very descriptive names, so again browsing through the tree helps a bit. https://tomcat.apache.org/tomcat-7.0-doc/monitoring.html said I could also access it through a url like: service:jmx:rmi:///jndi/rmi://localhost:8081/jmxrmi but I could not get that to work. Would that access the same bean(s) as the other examples? I would start interactively with JConsole or JVisualVM to get an idea what's there. You can also get a full textual dump with https://tomcat.apache.org/tomcat-9.0-doc/funcspecs/mbean-names.html?qry=*:* That command and some more is explained e.g. in https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html Then you need to decide, via which network protocol you want to access MBean data remotely. You could either use an agent deployed as a webapp inside Tomcat, speak http(s) to Tomcat and the agent retrieves the data internally via JVM and returns a textual representation. The manager webapp JMXProxy servlet is one such agent, but it has some deficiencies. You could also look at Jolokia (Open Source), which provides a more powerful other such agent. Alternatively you can also use JMX as a remote network protocol, but that is a bit more subtle to configure and get it secure etc. Your mentioned not-working URL fits into this realm. As I said, that's the harder way and you
tomcat jmx questions / help
Tomcat version 7.0.82 I have some questions about tomcat monitoring and jmx. The short version is that I am trying to get session information about users logged into my app. I see documentation about different ways to get to the jmx beans but I don't understand the relationship between them. http://localhost:8080/ takes me to the tomcat homepage and I can click on the manager button and get to a page with some links to application folders (I've set my role). Do they use jmx beans? I can also do like: http://localhost:8080/manager/text/sessions?path=/. and it returns number of sessions. Is that accessing an mbean? How does that name relate to the folders under the tomcat manager folder? I can also access http://localhost:8080/manager/jmxproxy/?get=java.lang.type=Memory=HeapMemoryUsage and get memory usage stats. Is that accessing an mbean? I also don't see how these names relates to going to jconsole and looking at the mbean tab and accessing Catalina/Manager/examples/localhost. The names of the attributes in jconsole don't seem to match the names of the beans that I can access like the memory example above. I found that memory example above online, but where are these beans documented? The documentation in https://tomcat.apache.org/tomcat-7.0-doc/monitoring.html said I could also access it through a url like: service:jmx:rmi:///jndi/rmi://localhost:8081/jmxrmi but I could not get that to work. Would that access the same bean(s) as the other examples? I can set CATALINA_OPTS to do the jmxremote enabling as described in , but what exactly is that enabling? Is that what enabled the mbeans that I accessed? Lastly, I created a listener (implements HttpSessionListener) and configured it in web.xml but when I set a breaklpoint in IDEA, it never hit it. When exactly does a session get created? when someone goes to any page on the host? When they log into the app? -- Greg Kaszycki 919-244-3789