Pager Duty API Bash
Jump to navigation
Jump to search
https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTc3-events-api-v1
https://gist.github.com/alperkokmen/11057941
#!/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