Created
March 31, 2014 17:02
-
-
Save ryanhoskin/9896973 to your computer and use it in GitHub Desktop.
Trigger and resolve incidents within PagerDuty forever... Heartbeat
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
#This script can trigger and resolve incidents within PagerDuty every 10 minutes | |
#Hit the PagerDuty Integrations API, echo results | |
function POST_Request ($url,$parameters) { | |
$http_request = New-Object -ComObject Msxml2.XMLHTTP | |
$http_request.open('POST', $url, $false) | |
$http_request.setRequestHeader("Content-type", "application/json") | |
$http_request.setRequestHeader("Content-length", $parameters.length) | |
$http_request.setRequestHeader("Connection", "close") | |
$http_request.send($parameters) | |
Write-Host "Server Response:" $http_request.statusText | |
} | |
#Parameters | |
$service_key = "538e4904f2474722933ee2f4b1051a53" | |
$description = "heartbeat" | |
$incident_key = "heartbeat" | |
$url = "https://events.pagerduty.com/generic/2010-04-15/create_event.json" | |
$parameters = New-Object Collections.Specialized.NameValueCollection; | |
#Trigger and resolve incidents forever | |
while ($TRUE) { | |
Write-Host "Triggering incident" | |
$event_type = "trigger" | |
$parameters = "{`"service_key`":`"" + $service_key + "`",`"event_type`":`"" + $event_type + "`",`"description`":`"" + $description + "`",`"incident_key`":`"" + $incident_key + "`"}" | |
POST_Request $url $parameters | |
Start-Sleep -s 600 | |
Write-Host "Resolving incident" | |
$event_type = "resolve" | |
$parameters = "{`"service_key`":`"" + $service_key + "`",`"event_type`":`"" + $event_type + "`",`"description`":`"" + $description + "`",`"incident_key`":`"" + $incident_key + "`"}" | |
POST_Request $url $parameters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment