Tuesday, March 5, 2013

What's this?

rpi2pachube is a set of scripts written in Bash that gather and push performance data from your Raspberry Pi to Pachube.

My own feed

Requirements

Raspberry Pi connected to the Internet.

Debian-flavor "ifstat command". Run "ifstat -v"; You should have version 1.1.

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.

How does it work?

rpi2pachube gathers performance data from your Raspberry Pi (temperature, load, network throughput, etc.) at 5 minute intervals and pushes this data to Pachube. From Pachube, you can watch how your Pi is doing from basically anywhere in the world.

What's new in version 2.0?

Temperature can now be pushed to Pachube in Fahrenheit.

Enable/disable monitoring of any performance value.

Monitor multiple network interfaces.

Where can I get it?

Remove any files from any previous versions before installing version 2.0.

Thursday, January 17, 2013

A watchdog timer is a special kind of timer commonly found on embedded systems that is used to detect when the running software is hung up on some task. The watchdog timer is basically a countdown timer that counts from some initial value down to zero. When zero is reached, the watchdog timer understands that the system is hung up and resets it. Therefore, the running software must periodically update the watchdog timer with a new value to stop it from reaching zero and causing a reset. When the running software is locked up doing a certain task and cannot update the watchdog timer, the timer will inevitably reach zero and a reset will occur.

Luckily for us, the Broadcom BCM2835 SoC on the Raspberry Pi comes with a hardware-based watchdog timer that can do just that. You will find this specially useful if you have a Raspberry Pi in a remote location and the operating system hangs and there's no one around to reboot it.

Load the bcm2708_wdog kernel module

To load the watchdog kernel module right now, issue the following command:

$ sudo modprobe bcm2708_wdog

If you are running Raspbian, to load the module the next time the system boots, add a line to your /etc/modules file with "bcm2708_wdog". The -a option makes sure tee appends instead.$ echo "bcm2708_wdog" | sudo tee -a /etc/modules

If you are running Arch Linux, add a file called "bcm2708_wdog.conf" with the text "bcm2708_wdog" in /etc/modules-load.d/ with the following command:

Configure the watchdog daemon

Open /etc/watchdog.conf with your favorite editor (mine is nano).

$ sudo nano /etc/watchdog.conf

Uncomment the line that starts with #watchdog-device by removing the hash (#) to enable the watchdog daemon to use the watchdog device.
Uncomment the line that says #max-load-1 = 24 by removing the hash symbol to reboot the device if the load goes over 24 over 1 minute. A load of 25 of one minute means that you would have needed 25 Raspberry Pis to complete that task in 1 minute. You may tweak this value to your liking.

Start the watchdog daemon

That's it!

You are done! You may play around with the settings in /etc/watchdog.conf if you'd like.
The watchdog daemon performs other tests that you will probably want to configure.

Arch Linux users: I'm well aware that the watchdog daemon is not necessary in Arch because you can enable watchdog features with systemd by editing /etc/systemd/system.conf but I prefer the watchdog daemon as it is much more featured.

Requirements

Debian-flavor "ifstat command". Run "ifstat -v"; You should have version 1.1.

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

Create an account on Pachube if you don't have one already and log in with your account.

Add a new device/feed by clicking on the +Device/Feed button.

Select "Something else" when prompted for device type.

Select "No, I will push data to Cosm" when asked for an existing data source.

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.