Pushing Raspberry Pi Data to Pachube using bash and cron

14 Jan 2013

NEW POST: http://blog.ricardoarturocabral.com/2013/03/raspberry-pi-performance-to-pachube.html

The Pachube API makes it very easy for you to make your Raspberry Pi part of the Internet of Things (IoT). After successfully following this short tutorial, you or any computer connected to the Internet will be able to keep track of how your Raspberry Pi is doing. Even more useful if you have more than one and wish to track them all at once.
This blog post is the result of a brief tutorial I made in Google+'s Raspberry Pi community for +Kim Huebel.


Raspberry Pi
  1. Raspberry Pi connected to the Internet.
  2. Debian-flavor "ifstat command". Run "ifstat -v"; You should have version 1.1.
  3. realpath command for setup.sh. Run "realpath --version" to see if you have it installed. Use apt-get or pacman to install it depending on which linux distro you are using.
Arch Linux users: You WILL have to download the source code for ifstat and compile it yourself if you want to monitor a network interface with this script. Arch Linux's ifstat command output format is significantly different from Debian's ifstat. You will otherwise have to modify rpi2pachube to work with whatever flavor of ifstat Arch Linux uses if you do not wish to do this.

Create a feed on Pachube

  1. Create an account on Pachube if you don't have one already and log in with your account.
  2. Add a new device/feed by clicking on the +Device/Feed button.
    1. Select "Something else" when prompted for device type.
    2. Select "No, I will push data to Cosm" when asked for an existing data source.
    3. Give your device/feed a title. (e.g. raspberry-pi-1)
    4. Optional: Add tags to your new device. (e.g., raspberry pi, network, performance)
    5. Click Create.
    6. Write down the feed ID, as you will need this later for configuring the script.
  3. Click "Keys" in your console and then click the +Key button to add a new key.
    1. Label your key. (e.g. raspberry-pi-update)
    2. Set feed restriction to "Use specific feed(s)" and select the Device/feed you created earlier.
    3. Only "update" is needed in Access Privileges.
    4. Click Create.

Download rpi2pachube from Github

  1. Make a directory where you want rpi2pachube folder to be located. (e.g. ~/scripts).
    • mkdir -p ~/scripts
  2. CD into that directory: (e.g. cd ~/scripts/)
    • cd ~/scripts
  3. Clone the git repository.
    • git clone git@github.com:Cameri/rpi2pachube.git
  4. Run the configuration utility.
    • cd rpi2pachube
    • ./setup.sh
  5. When prompted, answer with your Pachube API Key, Feed ID and a Network Interface to monitor.
The configuration utility creates the file ~/.rpi2pachube.conf where your configuration is stored.
It is also possible to manually create a global configuration file in /etc/rpi2pachube.conf but that is unnecessary and not recommended.
Run the configuration utility (setup.sh) instead of manually editing ~/.rpi2pachube.conf.
Your Raspberry Pi performance values will be pushed to Pachube every 5 minutes. To change it, edit your user's crontab file (e.g. crontab -e).

That is all! Feel free to leave a comment.

Official Google+ Post in the Raspberry Pi community.

Update (Wed, Jan 23rd, 2013): Added "realpath" as a requirement. Renamed script to rpi2pachube and moved repository to a new location.

Legal disclaimer: All mentions of the letter sequence "cosm" on this post or Github repository (or in combination with other letters, or any other representation) refer ONLY to the on-line database service called Pachube and NOT to Cosm®, a trademark that is registered to Mithral Inc.
Original post by Ricardo Cabral - check out Ricardo's Workbench