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: 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"


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

client =
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
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/
Full source can be found here: