Create a gist now

Instantly share code, notes, and snippets.

Uptime Robot Dashing Widget

Simple Uptime Robot Dashing widget

Description

Dashing widget to display a short list of Uptime Robot monitors.

Usage

Add this to your Gemfile and run bundle install:

gem 'uptimerobot'

The files uptimerobot.coffee, uptimerobot.html and uptimerobot.scss go in the /widget/uptimerobot directory.

The uptimerobot.rb goes into the /jobs directory.

Put the following in your dashboard.erb file to make it show up in your dashboard:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="uptimerobot" data-view="Uptimerobot"></div>
</li>

Settings (uptimerobot.rb)

You will need to provide an API key from Uptime Robot API

class Dashing.Uptimerobot extends Dashing.Widget
<h1>Server status</h1>
<ul>
<li class="monitor" data-foreach-monitor="monitors" data-bind-class="monitor.status">
<span data-bind="monitor.friendlyname"></span>
</li>
</ul>
require 'uptimerobot'
apiKey = ENV['UPTIMEROBOT_APIKEY']
SCHEDULER.every '5m', :first_in => 0 do |job|
client = UptimeRobot::Client.new(apiKey: apiKey)
raw_monitors = client.getMonitors['monitors']['monitor']
monitors = raw_monitors.map { |monitor|
{
friendlyname: monitor['friendlyname'],
status: 'S' << monitor['status']
}
}
send_event('uptimerobot', { monitors: monitors } )
end
// 0 - paused
// 1 - not checked yet
// 2 - up
// 8 - seems down
// 9 - down
$S0-color: rgba(128, 128, 128, 0.5);
$S1-color: rgba(200, 255, 200, 0.5);
$S2-color: rgba(50, 205, 50, 0.5);
$S8-color: rgba(255, 50, 50, 0.5);
$S9-color: rgba(255, 50, 50, 0.5);
.widget-uptimerobot {
background: linear-gradient(to bottom, #3b4248 0%,#2a2f34 40%,#222529 100%);
.S0 {
background: $S0-color;
}
.S1 {
background: $S1-color;
}
.S2 {
background: $S2-color;
}
.S8 {
background: $S8-color;
}
.S9 {
background: $S9-color;
}
}
@merid14
merid14 commented Dec 3, 2015

Where do you put your UPTIMEROBOT_APIKEY?

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