Last active
February 28, 2017 23:26
-
-
Save sammarx/8806031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% 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 %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What widget type is this using ? (
data-view="Status"
) ?Do you have a link to a gist for that ?