Last active
August 29, 2015 13:55
-
-
Save julianeon/8743617 to your computer and use it in GitHub Desktop.
A script to create in incident in a given service.
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
require 'json' | |
subdomain="change_this" | |
api_key="change_this" | |
endpoint="https://events.pagerduty.com/generic/2010-04-15/create_event.json" | |
service_access_key="change_this" | |
incident_key="change_this" | |
subject="change_this" | |
client="change_this" | |
client_url="change_this" | |
details_hash={"ping time" => "1200ms", "load average" => "200ms"} | |
def curl_command_post_schedules(token_string,schedule_json,endpoint) | |
curl_command='curl -H "Content-type: application/json" -X POST -d '+schedule_json+' "'+endpoint+'"' | |
end | |
def hash_to_json(hash) | |
string="" | |
hash.each do |key,value| | |
string+='"'+key+'": "'+value+'", ' | |
end | |
string | |
end | |
sched_json= '\'{ | |
"service_key": "'+service_access_key+'", | |
"incident_key": "'+incident_key+'", | |
"event_type": "trigger", | |
"description": "'+subject+'", | |
"client": "'+client+'", | |
"client_url": "'+client_url+'" } }\'' | |
curl_string = curl_command_post_schedules(api_key,sched_json,endpoint) | |
puts curl_string | |
system(curl_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment