Build a Company Dashboard with Raspberry Pi, Geckoboard, and Django
I came across an excellent, practical, and easy-to-implement project this week that utilizes the Raspberry Pi and Geckoboard in order to power a company dashboard. As a result I went on to implement my own version with a few minor additions and customization so I made notes to share. I had a 42″ plasma sitting around unused and a new Raspberry Pi Model B with 512 MB RAM (although I think the previous model with 256 MB RAM would also run just fine – maybe a reason to re-purpose that model and purchase a new one).
My Requirements
My company came to me recently with a need for company dashboards so that the CEO could have a real-time view of various metrics across the company. These would be presented in his office on big screen TV’s. The goal was simple but identifying the right systems in order to meet our ongoing needs without changing too much or investing significant development efforts was not as straight-forward … until I came across this project. For example, I wanted to represent my customers email newsletter statistics but I was not going to change vendors in order to support this and I did not want to invest development hours to create a separate system to gather the data, process it, and display it on a custom-built dashboard.
Implementation
This solution is very simple. I loaded an SD card (you can select which but I utilize 16 GB SanDisk SD cards with high I/O – 95 MB/sec.) with “Raspbian Wheezy” as my default load. I then installed Chromium per Alex Bain’s instructions from command line, and configured autostart with a link to my Geckoboard dashboard “loop” URL. I won’t take the time to explain all of the details as Alex already did an excellent job of that.
Modifications
On my 60″ big screen the dashboard looked excellent but on my 42″ the resolution was too low to pack in the complete dashboard. So, I made a minor modification to /boot/config.txt and set “hdmi_mode” to 16 to support the higher resolution. After a quick reboot the new dashboard displayed with the real estate I was expecting.
Integration
My focus is currently on the Django framework and I utilized an existing system we built that gather metrics from our newsletter tools every 15 minutes. I used pip to install django-geckoboard (and added to my requirements.txt). I then added the GECKOBOARD_API_KEY parameter to settings.py (not required but restricts access only to my dashboards) and created a new “geckoboard” app within my project. I modified urls.py to intercept requests to the REST API:
urlpatterns = patterns('', # Geckoboard metrics url(r'^$', get_campaign_metric, name='geckoboard-get-campaign-metric'), )
And wrote my Django view to retrieve and display the results:
# Create your views here. from django_geckoboard.decorators import funnel from django.http import Http404 from SomeApp.models import SomeObject @funnel def get_some_metric(request): return { "items": some_stats, "type": qd.get('type', 'standard'), # default, 'reverse' changes direction of the colors. "percentage": qd.get('percentage', 'hide'), # default, 'hide' hides the percentage values. "sort": qd.get('sort', False) == 'True', # default, `True` orders the values descending. }
* Obviously I took a lot of the “meat” out of the above Django view (in order to remove prioprietary information) but I assume if you are here then you are familiar with Django or just interested in the overall concept. The variable, “qd”, represents a QueryDict object and the rest is straight-forward.
As you can see the integration with Django is very plug-and-play. The django-geckoboard decorator already handles XML versus JSON (an option you can specify in your custom Geckoboard charts). I chose to generalize the Django view by passing a simple “metric=<string>” GET/POST parameter and then allowing the view to determine if it exists on a specific model. If so then it passes returns the result and if not, it raises a 404.
And there you have it – a simple, very customizable dashboard using Geckoboard, using Django to integrate with your internal applications for custom metrics, and leveraging the Raspberry Pi’s inherent HDMI support in order to display the dashboard via Chromium in kiosk mode!