Skip to content

Instantly share code, notes, and snippets.

@sammarx
Last active February 28, 2017 23:26
Show Gist options
  • Save sammarx/8806031 to your computer and use it in GitHub Desktop.
Save sammarx/8806031 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'watir-webdriver'
TW_HEALTH_TO_LIGHT = {
'Service is operating normally' => 'green',
'Performance issues' => 'yellow',
'Service disruption' => 'red'
}
SCHEDULER.every '10s', :first_in => 0 do |job|
url='https://status.io.watchmouse.com/7617'
b = Watir::Browser.new :phantomjs
b.goto(url)
d=Nokogiri::HTML(b.html)
rows=[]
a = d.css(".psp-table").first.css('td').each_slice(5).map{|l| l.join(',').split(',')}.drop(1)
a.each do |line|
rows << line[0]
data = {
status: TW_HEALTH_TO_LIGHT[line[1]],
message: line[0]
}
send_event(line[0], data)
end
set :twitter_rows, rows
b.quit
end
<% settings.twitter_rows.each do |row| %>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="<%=row%>" data-view="Status" data-title="Twitter API Health" style="background-color:#ff9618"></div>
</li>
<% end %>
@ddewaele
Copy link

ddewaele commented Apr 9, 2015

What widget type is this using ? (data-view="Status") ?
Do you have a link to a gist for that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment