Creating Custom Tools for Monitoring Apache Tomcat, Apache Tomcat Admin

posted by MSacks on May 17, 2010 03:07 PM

Often times a developer or operations professional needs access to monitor a Tomcat instance for purposes of capacity planning, troubleshooting, and performance tuning. There are many tools available already for Tomcat, some of them open source, and others paid for. Some tools are simple and others are complex management suites.

There are comprehensive monitoring suites available that monitor and manage Tomcat, and do it well; however, there is always a benefit to being able to create your own custom Tomcat/application management tools. The first advantage is that you get exactly what you want out of your utility. In my example, I wanted to have a way to browse a Tomcat server’s Java Management Extensions’ MBeans with a hierarchical, bash-like navigation. This allows me to quickly find and diagnose problems with my Tomcat server or custom applications running within Tomcat, and is more precise than trending those MBeans over time using a more comprehensive monitoring suite. I liken it to purchasing a ready-made suit, or having one custom tailored to your exact specification. It just feels better sometimes, and other times it is not practical.

Why Create Your Own Custom Tools

Many utilities will not provide the specific feature that you need. There are usually a host of open source or commercial utilities for anything that one goal any developer or operations professional may want to achieve; however, often times that utility will not integrate well into their existing infrastructure, or not play well with automated processes that are pre-existing in the enterprise. In such cases, a custom utility can come in handy. Writing your own tools from scratch is a quick solution to a specific problem, and cuts out a lot of the fat. For simple tools, the complexity risk argument just isn't there, and in the time it takes to write a simple custom application.

The Jython JMX Client

The application is a very simple command line JMX Client, and by no means a perfect implementation. JConsole, or VisualVM is typically the method of choice for viewing and manipulating MBeans amongst Java Developers. The only problem with these graphical utilities is that they are not automatable and cannot query hundreds or thousands of MBeanServers. Enter the jythonJMXClient.

I created the jythonJMXClient primarily for demonstrating why writing custom tools for monitoring Tomcat is a useful practice. It is simple in design, and only performs a few set functions. It is easily extensible, and by maintaining it's simplicity and only focusing on a few set functions, it enables the user to perform easily mold the application to their needs.

I chose to write my application in Jython, which is an implementation of Python on the Java platform. It allows me to utilize the rapid development abilities of Python while still being able to access the JMX API's used for monitoring and managing Java applications, and in this case, Tomcat.

Using the Jython JMX Client

The Jython JMX Client's sources are available for download at Patches are welcome. Rather than dig into the source code, I will demonstrate how the application works here. 

Step 1: Invoke the JMX Client) java -jar ~msacks/jython2.5rc2/jython.jar
Step 2: Make a Connection to the MBeanServer) jmx> connect -h -p 9999
Step 3: Query the MBean and Attribute)
jmx> getAttribute -m java.lang:type=Memory -a HeapMemoryUsage
contents={committed=5459968, init=0, max=66650112, used=4079208})


jmx> getAttribute -m java.lang:type=Threading -a PeakThreadCount


jmx> getAttribute -m Catalina:type=ThreadPool,name=http-8080 -a currentThreadsBusy

Now with the beauty of Python's cmd library, I can also pass the commands in a text file if I want to automate things a bit more than use the jythonJMXClient in an ad-hoc example as I have here.

#sequence of commands for the jythonJMX Client
connect -h -p 9999
getAttribute -m Catalina:type=ThreadPool,name=http-8080 -a currentThreadsBusy
getAttribute -m java.lang:type=Memory -a HeapMemoryUsage
connect -h -p 8888
getAttribute -m Catalina:type=ThreadPool,name=http-8080 -a currentThreadsBusy
#ad infinitum

The idea is simple, I write, I test, I use my new utility. Writing you own custom applications is more like using an exacto knife where it’s need whereas before all you had was a hammer.

Jython JMX Client's Weaknesses and Strengths

There are already some command line JMX clients out there, jmxsh, jmxterm, and JBoss's twiddle. All of which are fantastic utilities, but I wanted to show how one might write a utility for querying Tomcat

The jythonJMXClient is simple, yet it has a few key shortcomings, mostly authentication, SSL support, and the ability to invoke methods using JMX. It was created primarily as a querying tool for gathering metrics about a running Tomcat instance, and not as a comprehensive management tool.

It’s advantages are that it’s highly customizable to your liking, and is very precise. For operations professionals or developers who do not want to have to remember their entire MBean hierarchy and structure (especially when creating many custom MBeans) it provides a precise and simple tool that is extremely easy to use. It is much more lightweight and precise than something such as JConsole, for example. Also, many folks prefer to use the command line, which gives it automation abilities and is easier to use for some people than a Graphical User Interface.


Writing simple and effective tools such as the jythonJMXClient will make your life infinitely easier when it comes to automation and querying a Tomcat server. I can now query a command line application which will allow me to access specific metrics in an automated fashion. I can integrate it with any other custom tools which I might need to perform some kind of action on, such as send an email based on some criteria, restart the server, or anything I like. What I would like to include in the future is including management facilities for calling object methods through JMX, so I have a complete monitoring and management tool that I can customize and extend to my liking.

Looking Forward

In future versions of jmxCmd, we will add functionality for invoking remote methods via JMX to the command line, and introduce the management aspect of the utility and how to write custom methods in JMX.

Matthew Sacks is an Application System Administrator at, and focuses on administering, monitoring and managing high-volume, high-traffic production Web sites. He is also the Founder and Editor of, a blog on System Administration, Web Application Development and Software Engineering. He is an active member in the USENIX The Advanced Computing Systems Professional and Technical Association, and has contributed to such publications as Linux Pro Magazine, Sys Admin Magazine, and InformIT.

Comments - Global information

f5f6fdf8e039a087cfd771b09f83bab7 Hello!,


Jasa menyewa mobil di pulau malang bisa anda temukan dengan mencari di google terkait tentang sewa mobil malang batu yang tarifnya murah dan bersahabat. Anda juga bisa menggunakan jasa sopir atau juga bisa lepas kunci (tanpa sopir). Tapi untuk sewa mobil malang lepas kunci, ada banyak syarat dan ketentuan yang harus dipenuhi karena pihak kantor penyedia jasa rental mobil malang takut mobilnya dibawa kabur oleh penyewa. Sudah banyak kejadian sewa mobil lepas kunci dan mobilnya digadaikan oleh customer tersebut. Untuk menyewa mobil di malang yang dengan sopir sewa mobil malang murah.
Jasa sewa mobil di surabaya yang bisa angkut-angkut barang untuk pindahan rumah atau pindah kost sangatlah banyak. Jasa transportasi kota surabaya ini biasanya menggunakan mobil pick up yang memang dikhususkan untuk mengangkut barang-barang. Sewa mobil surabaya ini tarif harganya disesuaikan dengan jarak yang akan ditempuh, seperti contok sewa mobil dari surabaya barat menuju surabaya timur tarif harganya cukup 200.000 rupiah saja. Lakukan pemesanan sekarang untuk jasa sewa mobil surabaya untuk angkut barang klik infonya disini.
Kota wisata batu memang sering menjadi tempat bagi pasangan muda mudi yang sedang lagi pacaran dan menikmati dinginnya suasana biar terlihat romantis. Salah satu tempat yang cocok dijadikan tempat berduaan adalah wisata alun-alun kota batu. Dengan tatanan yang apik dan rapi, alun-alun batu ini selalu padat oleh pengunjung setiap malam. Banyak kuliner pilihan yang juga dijual berjejer rapi di sekitar area alun-alun batu tersebut. Menikmati kuliner yang hangat-hangat di dinginnya kota batu tentu akan menjadi romantisme sendiri bersama pasangan.

thanks for j sharing with

thanks for j sharing with that awesome articles thanks u a lot
rasoio elettrico | regolabarba | ferro da stiro con caldaia | Friggitrice ad Aria | scopa a vapore | ripetitore wifi | ripetitore wifi amplificatore wifi piastra a vapore | miglior aspirapolvere | skateboard elettrico | passeggino leggero | miglior smartphone | tablet per bambini tnbikkrf

Thanks for the info Matt. It

Thanks for the info Matt. It is such tips and tutorials from tech geeks like you that help amateurs keep going. You simplify the task superbly. More techies should follow your footsteps and share the knowledge for the greater good. click this link

Software avchd converter

Software avchd converter convert avchd video files to avi, mp4, wmv, mov mod converter free download to convert HD camcorder files. mts to avi mp4 mov mkv iMovie, FCP/FCE with mts converter, so to convert mts files for your PC and mobiles. v3


Wonderful web journal. I appreciated perusing your articles. This is really an extraordinary read for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome! fox theatre seating chart

great post

Really, Hollywood Celebrity And Designers Real Leather Jackets | Top Celebrity Jackets i appreciate the effort you made to share the knowledge. The topic here i found was really effective to the topic which i was researching for a long time.

baixar pou hacker This is

baixar pou hacker This is important, though it's necessary to help you head over to it weblink: clash of clans tipps und tricks

I recently came across your

I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you. buyfollowers | buy small instagram likes


how to get followers That can feel great to learn these kinds of useful and also special posts on your own sites. views

los mejores videos

Estan aqui

videos porno



videos xxx


Thanks for information! I enjoyed reading!
bloodshot eyes eye care professional

I’m impressed, I have to

I’m impressed, I have to admit. Rarely do I encounter a blog that’s both equally educative and engaging, and let me tell you, you've hit the nail on the head. The issue is something which too few men and women are speaking intelligently about. I'm very happy I stumbled across this in my hunt for something relating to this.
Mortgage Broker Calgary

It’s hard to find

It’s hard to find well-informed people in this particular topic, but you seem like you know what you’re talking about! Thanks
Edmonton Mortgage Broker
Life Insurance Vancouver
Life Insurance Calgary


how to get more favorites and retweets on twitter This is helpful, nonetheless it can be crucial so that you can check out the following website: twitter followers buy

In addition, a top car owner

In addition, a top car owner will also plan tracks and factor in the attractions and safe places to take smashes together with sticking to any and all specific customer demands london chauffeur.

Initial You got a awesome

Initial You got a awesome blog .I determination be involved in plus uniform minutes. i view you got truly very functional matters , i determination be always checking your blog blesss. baroque plastic cutlery

Very useful post. This is my

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really great article. Keep it up fifa 17.

Matthew Sacks is an

Matthew Sacks is an Application System Administrator at, and focuses on administering, monitoring and managing high-volume, high-traffic production Web sites. He is also the Founder and Editor of, a blog on System Administration, attorney mm to inches inche to cm Web Application Development and Software Engineering. He is an active member in the USENIX The Advanced Computing Systems Professional and Technical Association, and has contributed to such publications as Linux Pro Magazine, Sys Admin Magazine, and InformIT.

best_essays It's a great

It's a great news indeed, I hope it's going to be the best thing

Good job

I was very interested in the article. It’s quite inspiring I should admit.

Essays service


This is a awesome article.

This is a awesome article. Very simple way of writing and interesting topic. I will read again and again. Love the way you write. Keep posting bonus senza deposito.

Most apparently does not

Most apparently does not require years of labor or hours of meditation a day or any certain knowledge in any respect click to read.

Do you want to learn chakra

Do you want to learn chakra healing? Do you want to know how chakra healing opens and balances the seven power whorls within our body? The website tells you the different chakra exercises for effective chakra healing purposes website design companies

I have a objective that I’m

I have a objective that I’m just now operating on, and I have been at the look out for such details Cash Loans.


Completely awesome posting! Bunches of helpful data and motivation, both of which we all need!Relay welcome your work. seo packages usa

I would never comprehend. It

I would never comprehend. It seems too complicated and extremely extensive for me. I'm expecting for your next publish look here

I really appreciate this

I really appreciate this excellent publish that you have offered for us. I guarantee this would be great for most of the individuals Webteach.

Harga Produk

harga, produk, super, murah, handphone, mobil, motor, sandal, tas, sepatu, jaket

Handphone murah

pakaian, sandal, tas, sepatu, jaket, pakaian, harga

Produk murah

handuk handuk packaging handuk distributor handuk jakarta tukang bordir jakarta grosir souvenir ulang tahun anak grosir handuk murah di jakarta pabrik souvenir souvenir handuk jakarta di jakarta jual handuk bordir di jakarta jual handuk murah grosir souvenir pernikahan handuk salon rajawali grosir sovenir harga souvenir handuk handuk promosi souvenir ulang tahun handuk handuk custom pusat grosir souvenir souvenir bayi handuk super grand souvenir di jakarta soviner souvenir jakarta souvenir grosir harga bordir handuk jual souvenir handuk jual handuk terry palmer souvenir handuk bordir souvenir baby born murah handuk hotel murah handuk bordir rajawali emas souvenir handuk grosir handuk jakarta bordir handuk jakarta bordir handuk grosir handuk souvenir bordir handuk murah handuk bordir jakarta handuk bordir murah handuk kimono bathrobe jual handuk souvenir souvenir handuk murah jasa bordir handuk grosir handuk merah putih souvenir handuk jakarta jual handuk bordir grosir handuk bordir distributor handuk handuk terry palmer bordir handuk souvenir jakarta produsen handuk raja wali emas handuk murah jakarta grosir handuk pabrik handuk jakarta handuk mutia handuk hotel handuk untuk souvenir supplier handuk suvenir handuk sofenir souvenir bordir grosir souvenir natal grosir handuk merah putih murah packing souvenir handuk souvenir handuk ultah anak grosir souvenir grosir handuk murah harga pabrik grosir souvenir jakarta terry palmer handuk souvenir handuk ultah handuk murah jakarta souvenir handuk bordir murah di jakarta pabrik handuk di jakarta bordir jakarta handuk untuk souvenir di jakarta souvenir murah jakarta tempat bordir murah di jakarta juragan bordir souvenir murah supplier handuk jakarta handuk souvenir ultah di jakarta grosir souvenir ultah anak murah souvenir grosir murah handuk souvenir di jakarta ema's handuk grosir jakarta toko grosir handuk handuk grosir handuk putih jual handuk merah putih pesan handuk bordir harga bordir bordir murah handuk bordir nama tempat bordir di jakarta handuk bordir terry palmer jual souvenir

harga produk super murah handphone mobil motor sandal tas sepatu jaket

Awesome article! I want

Awesome article! I want people to know just how good this information is in your article. It’s interesting, compelling content. Your views are much like my own concerning this subject mesin slot online.

I will be rebounding afterward thanks lots for ones wonderful piece of writing. Could fine browse through the ton and reveal varied data on your net journal. Today follow this Thanks lots for the aim of tight piece of writing.


Awesome article! I want people to know just how good this information is in your article.
videos xxx
videos porno
sexo gratis
videos gratis
xxx gratis
porno gratis


videos xxx

Thank you for sharing! Glad

Thank you for sharing! Glad to see the information!
instagram viewer

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.