Last active
May 18, 2016 01:39
-
-
Save slemiere/a59fdbfadbd3726eb622 to your computer and use it in GitHub Desktop.
Blink + PagerDuty
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sweet!