Skip to content

Instantly share code, notes, and snippets.

View ryanhoskin's full-sized avatar

Ryan Hoskin ryanhoskin

View GitHub Profile
@ryanhoskin
ryanhoskin / pagerduty.py
Last active December 25, 2015 19:19
Get basic statistics on a PagerDuty service
#!/usr/bin/env python
import time
import datetime
import requests
import sys
import json
from urllib import urlencode
#Your PagerDuty API key. A read-only key will work for this.
#!/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?
@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$"
}
@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. <[email protected]>
# 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 / 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)