mattman (owner)

Revisions

gist: 132547 Download_button fork
public
Public Clone URL: git://gist.github.com/132547.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
)