Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@james
Last active November 16, 2016 18:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save james/5670035 to your computer and use it in GitHub Desktop.
Save james/5670035 to your computer and use it in GitHub Desktop.
Pingdom Dashing Widget
class Dashing.Pingdom extends Dashing.Widget
<h1 class="title" data-bind="title"></h1>
<ul>
<li class="check" data-foreach-check="checks" data-bind-data-state="check.state">
<span data-bind="check.name"></span>
</li>
</ul>
require 'pingdom-client'
api_key = ENV['PINGDOM_API_KEY'] || ''
user = ENV['PINGDOM_USER'] || ''
password = ENV['PINGDOM_PASSWORD'] || ''
SCHEDULER.every '1m', :first_in => 0 do
client = Pingdom::Client.new :username => user, :password => password, :key => api_key
if client.checks
checks = client.checks.map { |check|
if check.status == 'up'
color = 'green'
else
color = 'red'
end
{ name: check.name, state: color }
}
checks.sort_by { |check| check['name'] }
send_event('pingdom', { checks: checks })
end
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: #dc5945;
// ----------------------------------------------------------------------------
// Widget-clock styles
// ----------------------------------------------------------------------------
.widget-pingdom {
background-color: $background-color;
.check {
float: left;
padding: 4px 0px;
width:100%
}
.check[data-state="green"] {
background-color: green;
}
.check[data-state="red"] {
background-color: red;
}
.check span {
padding: 0px 4px;
}
}

Description

Simple Dashing widget (and associated job) to display Pingdom checks.

##Dependencies

pingdom-client

Add it to dashing's gemfile:

gem 'pingdom-client'

and run bundle install. Everything should work now :)

##Usage

To use this widget, copy pingdom.html, pingdom.coffee, and pingdom.scss into the /widgets/pingdom directory. Put the pingdom.rb file in your /jobs folder.

To include the widget in a dashboard, add the following snippet to the dashboard layout file:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="pingdom" data-view="Pingdom" data-title="Pingdom" data-cols="1"></div>
</li>

##Settings

You'll need to add your pingdom API key and login settings. You can either add it straight to the source code on lines 4-6 of pingdom.rb, or set the variables in the ENV. For heroku, you can do this with

heroku config:set PINGDOM_API_KEY=
heroku config:set PINGDOM_USER=
heroku config:set PINGDOM_PASSWORD=

Pingdom is checked every minute, but you can change that by editing the job schedule.

Contributions

This has been extracted from a dashboard for the UK Ministry of Justice, with minimal generalising. Feel free to submit patches to @james

@jwalton
Copy link

jwalton commented Sep 19, 2013

@james feel free to pull from mine. :)

@petermanser
Copy link

@jwalton @james https://gist.github.com/james/5670035#file-pingdom-rb-L21 should be:

checks.sort_by! { |check| check[:name] }

@foxhunt72
Copy link

Hello,

I have a question, how can i change did so it just shows the down checks, because we have something like more than 40 checks in pingdom so it doesn't fit on the screen.

Richard

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