Search code examples
tomcatget

How can I parse a tomcat status page without flooding access logs?


For a project that I am currently embarking on, I am looking to read in text from a bunch of status pages of applications that are running within tomcat.

What I am trying to do is create a conglomerated status page that will show the status of the tomcat application (online/offline).

Up until now I've created a script that will parse the status pages of the applications and format the results into a table and then write the results to an html file; thus, creating a status page for all of my applications.

I've come to realize that every time I refresh the page, I am sending more and more GET requests to these sites and thus flooding the access logs of the tomcat applications.

What I'm looking for help with is a work around to parsing these status pages without spamming GET requests... OR, a way of disabling the GET flooding in the access logs.

Thank you!


Solution

  • You did not tell how the status pages are created. But you could also get the applications states by querying JMX. Once enabled, you can get live data form your VMs. Using JMX's MBeans (which already exist for Tomcat) you could create a status page showing your applications on a single page, without parsing the former status pages and writing them to a database.

    To check wether this is an opportunity, you can just start your server and open Java Mission Control (jmc.exe in your JDK's bin folder) and connect, by clicking MBean Server below the right process. Then in the MBean Browser (tab at the bottom) you will find something like Catalina or Tomcat (according to your Tomcats service name). In a subfolder, there is a type called WebModule, showing your installed applications. It should look like this:

    enter image description here

    You can query this data at any time, to create your own status page (i.e. in a controller).