January 8, 2010

Pretty automatically updating lighttpd server status or “mod_status on steroids”

At work we use the excellent lighttpd (or lighty) web server as a frontend reverse proxy that performs SSL offloading, and  some other neat tricks before our visitors reach our backend servers. It’s been working like a charm.

We’ve been using mod_status to keep track of how much traffic goes through our frontend server. mod_status is one of those little apps that gets the job done but not so much more.

server-status

It contains all the relevant information but I wanted to display this data on a separate monitor to as a way to keep track of how much traffic we where getting in real time.

Since it’s a static html page there wasn’t much interactivity there. So I whipped out my vim-editor and wrote a little helper page that dynamically polls data from the server-status page and displays it in a little more full-screen friendly way. You can see the result below (click on it to enlarge). It will automatically refresh the data once every 5 seconds.

server-status-pretty

Go ahead and download the source. It’s a single html file and all you have to do is to configure your lighty server so that the server status is enabled for a directory to which you’ve got write access to. Ours looks like this:

$SERVER["socket"] == "192.168.30.1:80" {
    status.status-url = "/server-status"
    server.document-root = "/var/www/status"
    mimetype.assign = ( ".html" => "text/html" )
    index-file.names = ( "pretty-status.html" )
}

Then you simply put the file in that page and it should just magically work. Note that the file loads the Google hosted jQuery library so if you don’t have access to the internet (on the machine your viewing from) you’ll have to download the jQuery script and place it along side the page.

Things on the todo list include pretty error messages when the data can’t be fetched and perhaps a nice little demo-mode.

[Download the source], [“Project page at freakcode.com”]

Licensing information

3 comments:

  1. Hi,
    nice, would like to use it but 've got error due to binding on port 80.
    My lighttpd is runing and if I want to use:
    $SERVER["socket"] == "server-ip:80"
    I got an error at lighttpd restart - saying port 80 already in use....

    ReplyDelete
  2. Their seems to be one small problem with this app, since it constantly refreshes itself the ammount of connections increases on every refresh therefore making the logfile larger and making a small amount of traffic. maybe it's not so big of a deal, only b/c I do not know if the logfile deletes itself after getting too large, i can delete it manually every other month i guess.

    ReplyDelete
  3. This is a very cool app. I'm having a good time learning jQuery with it as I extend it to include the server-statistics stats.

    ReplyDelete