-
-
Save rdeavila/1f01ea4ab5d52eb7c251ffc852143af4 to your computer and use it in GitHub Desktop.
Simple script to trigger, acknowledge, and resolve incidents via PagerDuty Integration API.
This file contains hidden or 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
#!/bin/bash | |
CONTENT_TYPE="application/json" | |
DESCRIPTION="bad things™ are happening" | |
URL="https://events.pagerduty.com/generic/2010-04-15/create_event.json" | |
if [ $# -ne 3 ]; then | |
echo "Usage: pd-event.sh [TYPE] [SERVICE KEY] [INCIDENT KEY]" | |
echo " - TYPE: [t]rigger | [a]cknowledge | [r]esolve" | |
echo " - SERVICE KEY: unique identifier for service" | |
echo " - INCIDENT KEY: unique identifier for incident" | |
exit 1 | |
fi | |
case $1 in | |
t) curl -H "Content-type: ${CONTENT_TYPE}" \ | |
-X POST \ | |
-d "{ \"service_key\": \"$2\", \"event_type\": \"trigger\", \"incident_key\": \"$3\", \"description\": \"${DESCRIPTION}\" }" \ | |
"${URL}" | |
;; | |
a) curl -H "Content-type: ${CONTENT_TYPE}" \ | |
-X POST \ | |
-d "{ \"service_key\": \"$2\", \"event_type\": \"acknowledge\", \"incident_key\": \"$3\" }" \ | |
"${URL}" | |
;; | |
r) curl -H "Content-type: ${CONTENT_TYPE}" \ | |
-X POST \ | |
-d "{ \"service_key\": \"$2\", \"event_type\": \"resolve\", \"incident_key\": \"$3\" }" \ | |
"${URL}" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment