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