Skip to content

Instantly share code, notes, and snippets.

@slemiere
Last active May 18, 2016 01:39
Show Gist options
  • Save slemiere/a59fdbfadbd3726eb622 to your computer and use it in GitHub Desktop.
Save slemiere/a59fdbfadbd3726eb622 to your computer and use it in GitHub Desktop.
Blink + PagerDuty
#!/usr/bin/env ruby
require 'httparty'
require 'blink1'
class PagerDuty
include HTTParty
TOKEN = "YOUR_PAGERDUTY_API_TOKEN"
PAGERDUTY_DOMAIN = "YOUR_PAGERDUTY_DOMAIN"
base_uri "https://#{PAGERDUTY_DOMAIN}.pagerduty.com/api/v1"
def initialize
@options = { headers: {"Authorization"=>"Token token=#{TOKEN}"} }
end
def incidents
self.class.get("/incidents", @options)
end
end
client = PagerDuty.new
open_incidents = client.incidents['incidents'].select{|i| i['status'] != 'resolved'}
if open_incidents.count > 0
Blink1.open do |blink1|
blink1.blink(255, 0, 0, 5)
end
end
@mrose17
Copy link

mrose17 commented Oct 9, 2014

sweet!

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