Skip to content

Instantly share code, notes, and snippets.

View ryanhoskin's full-sized avatar

Ryan Hoskin ryanhoskin

View GitHub Profile
@ryanhoskin
ryanhoskin / SN_filtered_integration.js
Created April 22, 2015 20:50
Filter out ServiceNow incidents that don't have a PagerDuty Service API Key associated with the assigned group.
// High priority incident escalated - use PagerDuty to find Assigned to
// To support auto-escalated incidents, needed to add Advanced Script Condition
// Evaluates Filter conditions and then advanced conditions (not either/or)
// 1. changes() is not respected on a record insert
// 2. evaluates filter conditions (on When to run pane) before script conditions
// 3. auto-escalated events trap on current.operation() == insert
// 4. also needed to change into an 'after' event
#!/usr/bin/env python
#
# Copyright (c) 2011-2012, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
#! /usr/bin/perl
use LWP::UserAgent;
use JSON qw(decode_json);
use File::Basename;
### Configuration parameters ###
# Directory where is stored necessary files with match up ids between Pandora FMS and PagerDuty
# One hidden tiny file per alert will be created
@ryanhoskin
ryanhoskin / get_log_entries.py
Created August 18, 2015 20:35
This script will export all log entries associated with a PagerDuty user.
#!/usr/bin/env python
import requests
import sys
import json
import csv
from datetime import date, timedelta
#This script will export all log entries associated with a PagerDuty user. All data is written to log_entries.csv.
@ryanhoskin
ryanhoskin / pagerduty_check_mk.cfg
Created December 4, 2014 00:19
Check_MK PagerDuty Integration
define contact {
contact_name pagerduty
alias PagerDuty Pseudo-Contact
service_notification_period 24X7
host_notification_period 24X7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-pagerduty
host_notification_commands notify-host-by-pagerduty
pager YOUR-SERVICE-KEY-HERE
@ryanhoskin
ryanhoskin / Import Users from Active Directory to PagerDuty.ps1
Last active December 11, 2015 04:18
Import users from Active Directory to PagerDuty
# Import users from Active Directory to PagerDuty
# Requires Windows Server 2008 R2
# Users should be members of a security group named "pagerduty"
Import-Module activedirectory
# Import users via the PD API
function POST_Request ($url,$parameters, $api_key) {
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open('POST', $url, $false)
@ryanhoskin
ryanhoskin / gist:5225138
Created March 22, 2013 22:03
Test Opsview perl script.
#!/usr/bin/env perl
# Nagios plugin that sends Nagios events to PagerDuty.
#
# Copyright (c) 2011, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@ryanhoskin
ryanhoskin / gist:5392173
Created April 15, 2013 23:32
Icinga Command w/ Environment Variables
define command {
command_name notify-service-by-pagerduty
command_line /usr/local/bin/pagerduty_icinga.pl enqueue -f pd_nagios_object=service -f CONTACTPAGER="$CONTACTPAGER$" -f NOTIFICATIONTYPE="$NOTIFICATIONTYPE$" -f HOSTNAME="$HOSTNAME$" -f SERVICEDESC="$SERVICEDESC$" -f SERVICESTATE="$SERVICESTATE$"
}
define command {
command_name notify-host-by-pagerduty
command_line /usr/local/bin/pagerduty_icinga.pl enqueue -f pd_nagios_object=host -f CONTACTPAGER="$CONTACTPAGER$" -f NOTIFICATIONTYPE="$NOTIFICATIONTYPE$" -f HOSTNAME="$HOSTNAME$" -f HOSTSTATE="$HOSTSTATE$"
}
#!/usr/bin/env python
import time
import datetime
import requests
import sys
import json
from urllib import urlencode
# How many notifications had to be escalated past the primary, due to lack of response?
#!/usr/bin/env python
import time
import datetime
import requests
import sys
import json
from urllib import urlencode
# How many notifications had to be escalated past the primary, due to lack of response?