Created
October 29, 2012 09:41
-
-
Save baskarp/3972633 to your computer and use it in GitHub Desktop.
Invoke PagerDuty using cURL from Windows
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
@echo off | |
:: Download cURL with SSL support from here: http://www.paehl.com/open_source/?CURL_7.28.0: | |
:: Extract curl.exe in the same directory as this bat file | |
:: Usage: pagerduty.bat service_key event_type description incident_key | |
:: event_types = (trigger | acknowledge | resolve) | |
:: | |
set service_key=%1 | |
set service_key=%service_key:"=\"% | |
set event_type=%2 | |
set event_type=%event_type:"=\"% | |
set description=%3 | |
set description=%description:"=\"% | |
set incident_key=%4 | |
set incident_key=%incident_key:"=\"% | |
curl -H "Content-type: application/json" -k -X POST -d "{\"service_key\": %service_key%, \"event_type\": %event_type%, \"incident_key\": %incident_key%, \"description\": %description% }" "https://events.pagerduty.com/generic/2010-04-15/create_event.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, just implemented it today!
Note for the next folks, you do have to quote and escape each element in the JSON, here is what worked for me for the last line of the script:
curl -H "Content-type: application/json" -k -X POST -d "{\"service_key\": \"%service_key%\", \"event_type\": \"%event_type%\", \"incident_key\": \"%incident_key%\", \"description\": \"%description%\" }" "https://events.pagerduty.com/generic/2010-04-15/create_event.json"