A Dashing widget for displaying the number of websites down according to StatusCake.
See a live demo here.
Setup the following environment variables:
See instructions here to learn how to setup your token and client ID.
A Dashing widget for displaying the number of websites down according to StatusCake.
See a live demo here.
Setup the following environment variables:
See instructions here to learn how to setup your token and client ID.
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="statuscake" data-view="Number" data-title="Monitoring" style="background-color:#3ADF00"></div> | |
</li> |
require 'json' | |
username = ENV["STATUSCAKE_USERNAME"] | |
key = ENV["STATUSCAKE_KEY"] | |
SCHEDULER.every "1h" do | |
items=[] | |
is_down=0 | |
status='ok' | |
response = Net::HTTP.get_response(URI('https://www.statuscake.com/API/Tests/?Username='+username+'&API='+key)) | |
all_tests = JSON.parse(response.body) | |
test_ids = all_tests.map do |site_test| | |
site_test["TestID"] | |
end | |
test_ids.each do |testid| | |
response = Net::HTTP.get_response(URI("https://www.statuscake.com/API/Tests/Details/?TestID=#{testid}&Username=#{username}&API=#{key}")) | |
website = JSON.parse(response.body) | |
if website['Status']!='Up' | |
items << { site: website['WebsiteName'], status: website['Status'], lasttest: website['LastTested'] } | |
status='warning' | |
end | |
end | |
send_event('statuscake', { current: items.count, status: 'danger' }) | |
end |