Tweeting uptime and load

On my file server I have at home I run the backend software for my Squeezebox Touch, overall it works well but sometimes it starts using 100% and not responding to any input which is a bit annoying. So I decided to add some kind on monitoring to the machine to know when this happens, first i looked at Nagios but decided that it contained more than I needed so I wrote a very small ruby script that tweets the result of the uptime command. The script is added to the crontab and is run every hour. So to set it up you need a twitter account and then you need to get a oauth token and token secret that the script needs to be able to post and update. To get the oauth token and secret use the following script: https://gist.github.com/1377690 The script itself is just the setup for the twitter gem and then a update, the only thing here is that %[uptime] will execute the update command and return the output from it, something like 12:00:01 up 31 days, 18:48, 2 users, load average: 0.00, 0.00, 0.00.
#!/usr/bin/env ruby

require "rubygems"
require "twitter"

CONSUMER_KEY = 'CONSUMER_KEY'
CONSUMER_SECRET = 'CONSUMER_SECRET '
OAUTH_TOKEN = 'OAUTH_TOKEN '
OAUTH_TOKEN_SECRET = 'OAUTH_TOKEN_SECRET '

Twitter.configure do |config|
  config.consumer_key = CONSUMER_KEY
  config.consumer_secret = CONSUMER_SECRET
  config.oauth_token = OAUTH_TOKEN
  config.oauth_token_secret = OAUTH_TOKEN_SECRET
end

client = Twitter::Client.new
client.update(%x[uptime])
I had some problems with the gem paths when I ran the script though crond so I wrapped the ruby file with this small script that exports the GEM_HOME environment variable
export GEM_HOME=$HOME/.gems
$PATH_TO_SCRIPT/tweet_load.rb
Then the only thing left is to add the shell script to the crontab (crontab -e) to have it run every hour the line should be something like this.
0 * * * * $PATH_TO_SCRIPT/tweet_load.sh
Full source can be found here: https://github.com/FredrikL/TweetLoad

Build your own solar powered usb charger

I've been spending some time on instructables lately and found some cool hacks using solar panels to charge via usb and thought that I can do that too, so here's my version. First a parts list: I decided to use the Sparkfun charger since it also has a micro usb input that allows me to charge the battery from a usb port before first use. This is useful since charging the battery from the solar panel takes a day or two. Step 1: Solder the barrel jack to the booster (depending on your version you might have to cut off the connector) once done you can connect the battery and take it out into the sun, if everything is connected then the small stat led on the booster should light up (and the battery start charring). I also decieded to add a switch to on the cable connecting the battery to the charger, the reason for this is to avid having the booster draining the battery when it's not in use. Step 2: Connect the usb port. Step 3: Cut holes in the case to fit the switch, usb port and allow the solar panel to be glued to the case making the whole charger pack more portable. Step 4: Glue the solarcell to the case. Step 5: Assemble, I used parts that were over from cutting the hole for the solar cell to build a elevation point for the booster circuit, otherwise it was a tight fit and also this allows for easier access to the onboard usb port. To make the battery and circuit stay put I used double-sided tape. Step 6: Connect the solar panel and screw the pieces together. The result should look something like the first picure in the post. I'll probably add and extra switch later that allows me to cut the power from the solar cell to make sure that I can turn the charger completely of. Oh and if you follow these instructions and it causes your house to burn down or something like that don't blame me :)

What I've been up to lately

Just missing a bit of soldering and a nice box then my Pong will be done. Or in another way I think there's no longer any hardware bugs. On the picture, 8x8 led matrix,  breadboard with 2x 595 shift registers (and wires), Arduino Uno, 2x Potentiometer and a Lcd from a Nokia phone.