Remote monitoring Raspberry Pi 2 CPUs

I wanted to visualise of all those CPU cores on my new Raspberry Pi 2, so I decided to build a remote CPU monitoring webserver. The idea is to serve a webpage showing the percentage use of the CPU cores in a nice scrolling graph. Another idea I wanted to try was to keep all the HTML and JavaScript files embedded in the executable. So you only need the single binary program file. It means you just run the program without having to worry about putting supporting files in a particular place.

I'm hopeful that because it's lightweight and written in C the program itself won't consume many of the Raspberry Pi's resources. If you wanted, you could probably run the program as a service when the machine starts and not notice any difference. The CPU data is sent from a minimal Web API, which is built into the webserver. It sends out the CPU percentages as an array in JSON format. This means that most of the work is done by the browser (all the plotting and scrolling) and on the server side we just need to send an array of numbers every second or so. And whilst I was at it, I also included the ability to monitor the core temperature (if it is running on a Raspberry Pi).

I have put the resulting project on GitHub, so if anybody wants to have the ability to monitor their CPU cores over their network they can try it. I expect it will work on other Linux machines too, it's not restricted to the Raspberry Pi. The number of graphs is dynamically updated, depending on the number of cores you have.

This is how it looks (in this case showing the graphs on a simulated iPhone 4s):

If you want to, you can try it out like this:

git clone https://github.com/davidsblog/rCPU
cd rCPU/rCPU
make
sudo ./rcpu 80

...which will only work if you're not running an existing webserver on the machine, otherwise substitute the 80 on the last line for a different port. When the server is running, simply point a browser at your machines IP address (and port if its different than 80) and enjoy.

I did notice that the graphs don't plot very nicely on the default browser included with Raspbian (although if you install an alternative like Chromium it should be OK). But since the purpose is to monitor the CPUs remotely this should not really be an issue.

New Raspberry Pi 2

So, I ordered a new Raspberry Pi 2 as soon as they were launched last week. When it arrived, I couldn't resist documenting the occasion:

Last weekend I booted it up and started having a play. It seems quite an impressive little computer.

But since I had never bothered to order a B+ model I've only been using the 'original' Raspberry Pi until now, and I had forgotten that I need a microSD card these days. But I did have one lying around, so that was OK. I used a cheap HDMI to VGA adapter to use an older monitor.

The other thing I noticed was that I needed a better power supply. In the past I was using a kindle charger... but I needed to borrow the charger from my hudl tablet to get 5v at 2A. Otherwise, there was a little rainbow square showing at the top right of the screen to indicate that the device wasn't getting enough power. So watch out for that.

By the time I had finished messing around, my workbench looked like this: