Skip to content

Instantly share code, notes, and snippets.

@julianeon
Created August 26, 2014 23:51
Show Gist options
  • Save julianeon/cc6bb568102e6db614a7 to your computer and use it in GitHub Desktop.
Save julianeon/cc6bb568102e6db614a7 to your computer and use it in GitHub Desktop.
A script that creates an incident using the PagerDuty API.
#!/usr/bin/env ruby
subdomain="CHANGE_THIS"
api_key="CHANGE_THIS"
incident_key="SORIA82E"
endpoint="https://events.pagerduty.com/generic/2010-04-15/create_event.json"
service_access_key="a9c73c38e9cf4fa197802c7f2eb25b78"
subject="This is a check_cron alert. This service is not running."
def curl_command_trigger(token_string,json,endpoint)
curl_command='curl -H "Content-type: application/json" -X POST -d '+json+' "'+endpoint+'"'
end
trigger_json= '\'{
"service_key": "'+service_access_key+'",
"event_type": "trigger",
"description": "'+subject+'"
}\''
curl_string = curl_command_trigger(api_key,trigger_json,endpoint)
system(curl_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment