1

I have server daemons running on several machines. I decide to expose the internal stats of the server daemons for monitoring and statistic, using HTTP protocol.

So, what's the simplest way to do this?

  • The less 3rd-party jar dependencies, the better.
  • The lighter the framework is, the better.
  • The less complexity, the better.
qiuxiafei
  • 5,827
  • 5
  • 30
  • 43
  • @CoolBeans i think they are a bit complex and heavy for my application. I just wanna get some internal stat message via visit url like: http://server.ip/metrix-name . – qiuxiafei Sep 20 '12 at 03:13
  • What functionality do you need? Servlet container?? You could have a a look at [Jetty](http://jetty.codehaus.org/jetty/) or [Apache HTTP Components](http://hc.apache.org/) which has library that can be used to build a HTTP server from... – MadProgrammer Sep 20 '12 at 03:15
  • 1
    You could also take a look at the [Inbuilt HTTP Server](http://alistairisrael.wordpress.com/2009/09/02/functional-http-testing-with-sun-java-6-httpserver/) in Java 6 – MadProgrammer Sep 20 '12 at 03:21
  • possible duplicate of [simple HTTP server in Java using only Java SE API](http://stackoverflow.com/questions/3732109/simple-http-server-in-java-using-only-java-se-api) – BalusC Sep 20 '12 at 03:57
  • Have you considered JMX? It's pretty simple and close to what you want. – user949300 Sep 20 '12 at 05:19
  • possible duplicate of [Tiniest Java web server](http://stackoverflow.com/questions/8572127/tiniest-java-web-server) – Shaun the Sheep Sep 20 '12 at 15:18

2 Answers2

1

If the stats are a small number of fairly basic statistics, and you aren't wedded to the HTTP server concept, use JMX. I used it to instrument a daemon process and it was pretty simple. You can monitor remotely (on another computer) via an ugly, but serviceable UI.

Here's a tutorial instrumenting a web server app Probably very close to what you want.

Here's a StackOverflow link on remote monitoring

Community
  • 1
  • 1
user949300
  • 15,364
  • 7
  • 35
  • 66
0

The lightest weight java webserver I know of is Jetty. If you use maven, you don't have to add any dependencies to your project, just add jetty as a plugin:

 <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.26</version>
 </plugin>

then you can just call

 mvn jetty:run

at the command line. a lot of open source projects ship with a jetty server embedded, including hadoop.

Paul Sanwald
  • 10,899
  • 6
  • 44
  • 59