Skip to content

Instantly share code, notes, and snippets.

@zdenekjanda
Created April 1, 2015 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdenekjanda/3fa8f2fa6ecb00527c44 to your computer and use it in GitHub Desktop.
Save zdenekjanda/3fa8f2fa6ecb00527c44 to your computer and use it in GitHub Desktop.
Flapjack from scratsh

Flapjack from scratch by Deu

Irb

launch IRB

irb

init flapjack-diner

require 'flapjack-diner'
Flapjack::Diner.base_uri('127.0.0.1:3081')

create ALL entity (if not created yet)

entity_all_data = {
  :id   => 'ALL',
  :name => 'ALL'
}

unless Flapjack::Diner.entities(entity_all_data[:id])
  puts "Creating entity: ALL"
  Flapjack::Diner.create_entities([entity_all_data])
end

create contact

ada_data = {
  :first_name => 'Yevgen',
  :last_name  => 'V',
  :email      => 'yevgen.v@webgroup-limited.com'
}
Flapjack::Diner.create_contacts([ada_data])

get the id of contact and fill in to create medium

ada_data = {
  :id => '1a86e7a6-c0c3-49d4-8e1f-c472510b9b97'
}

medium = {
  :type => 'jabber',
  :address => 'yevgen@cloudevelops.com',
  :interval => 300,
  :rollup_threshold => 0
}
ada = Flapjack::Diner.contacts(ada_data[:id]).first
if ada[:links][:media].empty?
  puts "Creating Ada's media"
  Flapjack::Diner.create_contact_media(ada_data[:id], [medium])
end

get the medium id and update rollup

Flapjack::Diner.update_media('1a86e7a6-c0c3-49d4-8e1f-c472510b9b97_jabber', :rollup_threshold => nil)

add contact to ALL entity

entity_all = Flapjack::Diner.entities(entity_all_data[:id]).first
unless entity_all[:links][:contacts].include?(ada_data[:id])
  puts "Adding Ada to the ALL entity"
  Flapjack::Diner.update_entities(entity_all_data[:id], :add_contact => ada_data[:id])
end

Syrup

list contacts and get right contact id and notification rule id

syrup -r contact get

update notification rules to send only critical to certain media (i is default rule id)

syrup -r rule update -i 68b94377-13fe-40a5-9ad2-32703f0adb78 -u '' -w '' -c email,sms,sms_twilio,sms_nexmo,jabber,sns

create pagerduty rule with generalquarters tag (i is contact id)

syrup -r rule create -i dc1e0d76-1bfc-4f15-b574-dd073d4e142d -t generalquarters -u '' -w '' -c pagerduty,jabber

login to pagerduty, create account (ex. streamfury.pagerduty.com), create service (ex. streamfury), copy api key and login details for users, create pagerduty login for contact

syrup -r pagerduty create -i 4a5a7863-ae77-4048-af4c-b87221fa3e0f --service-key 1f49466e1a6a42f2b4e4479fc1d7d119 --subdomain streamfury --username zdenek.janda@cloudevelops.com --password supersecretpassword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment