To expand (or update) on Rhyse posted way above:
I have 2 notifications, a "create pagerduty incident" and "resolve pagerduty incident"
Each of these has a executes a custom script.
The script for "create" is
Param(
[string]$probe,
[string]$device,
[string]$name,
[string]$status,
[string]$down,
[string]$message
)
$Description = "CRITICAL: $probe $device $name $status $down"
$Body = @{
"service_key"="<api key>";
"event_type"="trigger";
"incident_key"=$device;
"description"=$Description;
"client"="$probe";
"client_url"="<url>";
"details"="$message"
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body
#$Body | out-file ".\pager.txt"
and for the "resolve":
Param(
[string]$probe,
[string]$device,
[string]$name,
[string]$status,
[string]$down,
[string]$message
)
$Description = "CRITICAL: $probe $device $name $status $down"
$Body = @{
"service_key"="<api key>";
"event_type"="resolve";
"incident_key"=$device;
"description"=$Description;
"client"="$probe";
"client_url"="<url>";
"details"="$message"
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://events.pagerduty.com/generic/2010-04-15/create_event.json" -ContentType application/json -Method POST -Body $Body
#$Body | out-file ".\pager.txt"
You will note the main difference is I am submitting the incident_key (using the deviceID). This means Pageryduty can resolve the incident if PRTG tells it.
Add comment