require 'rubygems' require 'pony' require 'open-uri' require 'hpricot' wp_url = "http://westernpower.com.au/online/pii/?location=INNALOO" doc = Hpricot(open(wp_url)) current_status = (doc/:td)[1].inner_text if current_status == "No known outages" wp_stuff = "no known outages" else wp_stuff = "an outage in your area. The estimated restoration time is #{current_status}" end message = "Ahoi hoi, The UPS connected to your machine has reverted to battery power. Western Power is currently reporting that there is #{wp_stuff}. You can continue checking this at #{wp_url}, and my status at http://home.didcoe.id.au/cgi-bin/apcupsd/multimon.cgi Regards, apcupsd daemon running on #{`hostname`}" Pony.mail( :to => "matt@didcoe.id.au, mattman@gmail.com", :from => "apcupsd@didcoe.id.au", :subject => "[APCUPSD] Your power is out - #{Time.now.strftime("%d/%m/%Y %H:%M")}", :body => message )