Skip to content

Instantly share code, notes, and snippets.

@alperkokmen
Last active April 6, 2024 20:39
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save alperkokmen/11057941 to your computer and use it in GitHub Desktop.
Save alperkokmen/11057941 to your computer and use it in GitHub Desktop.
Simple script to trigger, acknowledge, and resolve incidents via PagerDuty Integration API.
#!/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
@li-a
Copy link

li-a commented Jan 31, 2018

-H "Content-Type: ${CONTENT_TYPE}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment