Reputation: 8631
Recently, I felt the need of opening a port in my applications to which you can telnet in, and probe for some stuff, like memory consumption of a particular structure, print the contents of a List, etc... This greatly facilitates probing deployed solutions in runtime.
But suddenly, I had this strange feeling that a generic framework for such remote probing should already exist. So, here's the question: is there any library that already facilitates such features for Scala/Java? I'm not looking for a "full remote debugging" solution, but something minimalistic that allows easy extension and probing.
Upvotes: 4
Views: 450
Reputation: 27250
Maybe you could use some JavaScript on that console? It is extensible and easy to implement.
I used Apache Mina
and javax.script
for that: How to add remote JS console to your Scala server
Basically, it is the same you described in your question - you point telnet to port, and type commands (almost any commands).
Upvotes: 0
Reputation: 20515
JMX is by far your best bet here. It allows monitoring of a bunch of standard stuff, plus allows you to extend the data you can monitor by creating and publishing what it calls "MBeans". Best of all, if you're running JDK 6 or later, you're all ready running it (at least in local mode). In your JDK installation, you'll find an application called "jconsole". Run it, and you'll see monitoring on any java process running on your machine.
Upvotes: 1
Reputation: 2124
You can embed ostrich into your application. Unlike standard monitoring tools it has light-weight and readable data representation. And you would see not only system metrics but any you could possibly calculate.
Upvotes: 2
Reputation: 61705
Have you tried jvisualvm?
It comes with the jdk. Try running it and see if it fits your requirements...
From that page:
Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug-in Wrapper plug-ins. You can choose from a catalog of standard Java VisualVM plug-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus.
If you really wish to probe values at runtime in production, then you can start the jvm in debug mode, and attach an Eclipse process, which allows you to set break points, and examine variables. However, you may have performance issues with this. See Remote debugging with Eclipse.
Upvotes: 3