Server statistics in Status Board

Panic, the company behind apps such as Coda and Transmit, has released a new app called Status Board. This app is in essence a widget hub for your iPad, showcasing cool stuff such as tweets, e-mail, calendar and much more. One of the most awesome things though is the ability to make your own widgets, or to supply data to widgets. It wasn’t hard to think of something I wanted to use this for …

Note: In case you are looking for the server load graph, head over to “Server load graph for StatusBoard with PHP”

Just to get started with this, I decided to show load stats and disk-space for my servers. Initially, the question was how to get this data from the servers to wherever I wanted to collect the data. The following command is my solution:

What this does, is that it sends the result of the uptime command and the df -h command as POST variables via cURL to a script that we define. The reason I want to use specifically those two commands is that uptime includes the load averages, and that df -h gives me the amount of free disk space. The command itself could then be run either manually or every minute using CRON.

The script that we access with the cURL request will contain whatever is needed to handle that data. At the same time, I am using the same script to display the data in Status Board. For example:

When I was coding this I was working from my iPad so I needed to keep it simple. For this reason, I chose to store the statistics in a file as JSON. Since I only needed to update the stats once a minute for each server, this worked just fine.

This way, I would generate an array based on the servers that contacted the script, and each of those would again hold the most recent data for that server. I identified the servers by IP in this case. The only thing missing now, is the part that generates the data for Status Board.

Now you can add this widget to Status Board by dragging in the table-widget using the url to script. It should give you a listing of the servers that called the script, showing a bar graph of how much hdd-space is used, and showing the load averages for the last minute. The table will auto-refresh every minute, so if you run the command from your servers every minute it will stay up to date.

For more info about the customisable widgets for Status Board, you can check the docs for graphs, tables and DIY-widgets. You can get the full code for this example on GitHub.

I'm a webdeveloper based in Oslo, Norway. I currently work with web development at Nettmaker.

I would like to change the world, but they won't give me the source…

0 0 votes
Article Rating
Subscribe
Notify of
guest

16 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments