Low Power Server Monitoring with Raspberry Pi
Last Friday, our summer interns1 went back to University, leaving us with a couple of 28" monitors spare, crying out to be put to a good use. At the same time, we had a need for greater visibility of our graphite monitoring of our live site, and also of our jenkins continuous build server.
The only question remaining was what to machine to run this on? A number of options were available:
- Add an extra screen to a development machine. Mostly free, but relies on the developer's machine being on.
- Use a spare laptop. Quite energy hungry for the amount of work it will do. Zero cost, but the laptop would be unavailable for other uses.
- Buy a small desktop machine. Moderate expenditure, but again quite power hungry.
- Raspberry Pi. Tiny, low power and cheap. Perfect.
Raspberry Pi Acquisition
Once we'd set our hearts on the pi, the next problem was acquiring one. After a disheartening look at Farnell and RS who had a 3 and 9 week lead time respectively, I found that Maplin had stock. It includes a keyboard, mouse, USB hub, wifi dongle and SD card with Raspbian installed all for £69.99. A little on the expensive side for what it is, but well worth it due to the ability to get your hands on it quickly.
A trip to my nearest Maplin after work left me Pi-less. They did have one in stock earlier in the day, but it was snapped up after 20 minutes. A helpful call to the other branch in town secured me a kit, to be picked up the next day.
The initial setup was massively straightforward:
- Plug in network, HDMI, keyboard, mouse and power.
- Set the boot option to boot into the UI when prompted.
- Wait for desktop to load.
- Open Midori web browser.
- Browse to graphite dashboard.
- Stare at the magic of a live dashboard for 10+ minutes
At the time of buying, Maplin didn't have a specific case for the Pi in the store, so to start with, I'm using a modified Graze punnet with holes cut to accommodate the ports. There are a multitude of cases available if the homegrown solution doesn't take your fancy.
I wanted this system to be as compact and self contained as possible, so attached the rPi "Case" to the back of the monitor using sticky velcro tape to allow it to be easily removed if needed. The cables were tidied away with cable ties to keep everything nice and neat. Once this is done, the complete setup just needs three external cables: Monitor power, Pi power and network (although the Wifi dongle could be used). The monitor could easily be wall mounted with a VESA mount without the Pi getting in the way.
By default, the Raspbian distribution has power saving features set that turn the monitor off after about 10 minutes. This is obviously not ideal, so I let @rmyates (from our awesome devops team) loose on it to work his magic. Here's what he came up with:
To disable power management during the day change /etc/xdg/lxsession/LXDE/autostart:
@xset s off
@midori -p -e Fullscreen -a http://url.to.dashboard
Additionally, you should remove the xscreensaver line. To turn the screen off overnight, add a cron job that runs:
tvservice --off > /dev/null
To turn the screen back on in the morning before people arrive, add a cron job to run:
tvservice --preferred > /dev/null
fbset -depth 8; fbset -depth 16; xrefresh
One of the aims of this build was to end up with relatively low power server monitoring dashboard. The power readings taken from the solution are:
- 2W for the rPi
- 70W for the monitor when active
- 1W for the monitor overnight
The monitor would probably be more efficient if it was LED back-lit.
So all in all, we now have a very compact and capable monitoring platform that isn't unnecessarily over-specced.
Update on 15 January 2013: "Raspberry Pi Sells one Million Units - Maybe". Congratulations!
Update on 13 May 2015: We're still doing monitoring like this and it works great. Only change is that, as the company grew over 10x, we had to buy a second Raspberry Pi.
1If you're a Student and interested in joining us for the Summer, get in touch.
Want to find out more?