Skip to content

Instantly share code, notes, and snippets.

View baskarp's full-sized avatar

Baskar Puvanathasan baskarp

View GitHub Profile
@baskarp
baskarp / create_pagerduty_overrides.rb
Created January 20, 2012 22:44
Ruby script to create overrides in PagerDuty.
#!/usr/bin/env ruby
# Ruby script to create overrides in 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:
# * Redistributions of source code must retain the above copyright
@baskarp
baskarp / pagerduty_nagios.pl
Created July 20, 2012 08:48
PagerDuty Nagios plug-in with support for FLAPPINGSTART and FLAPPINGSTOP
#!/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:
@baskarp
baskarp / gist:3291141
Created August 8, 2012 01:12
How to setup Python command line tool for PagerDuty
Here is a quick instructions on how to setup the Python command line tool for PagerDuty.
1) You'll need to have Python installed (tested with Python 2.6.1)
2) Verify if Python setuptools are installed
python -c "import setuptools;print 'OK';"
if you don't see output "OK", then setuptools are not installed.
To install setuptools, download setuptools (http://pypi.python.org/pypi/setuptools/) appropriate to your Python major version. ("python --version" to get the version number).
@baskarp
baskarp / pagerduty_opsview.pl
Created August 21, 2012 00:43
PagerDuty Nagios plug-in with support for OpsView
#!/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:
@baskarp
baskarp / quick_ack.rb
Created October 29, 2012 07:43
A script to quickly ack a PagerDuty incident by incident number
#
#
# How to use this script:
#
# 1) You'll need to have Ruby installed on your machine.
# Follow these instructions to install Ruby on your machine: https://docs.google.com/document/pub?id=1Eo3f77CC1Flkb2f71ro-NZCYK2VuA6ajxvcuTGG_c6Q
#
# 2) Once Ruby is installed, run the following from your command prompt:
# gem install faraday --no-ri --no-rdoc
#
@baskarp
baskarp / pagerduty.bat
Created October 29, 2012 09:41
Invoke PagerDuty using cURL from Windows
@echo off
:: Download cURL with SSL support from here: http://www.paehl.com/open_source/?CURL_7.28.0:
:: Extract curl.exe in the same directory as this bat file
:: Usage: pagerduty.bat service_key event_type description incident_key
:: event_types = (trigger | acknowledge | resolve)
::
set service_key=%1
set service_key=%service_key:"=\"%
set event_type=%2
set event_type=%event_type:"=\"%
@baskarp
baskarp / mirror_incident.rb
Created November 2, 2012 08:28
Ruby script to mirror an email incident as an API incident in PagerDuty
#!/usr/bin/env ruby
# Ruby script to mirror an email incident as an API incident
#
# 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:
# * Redistributions of source code must retain the above copyright
#!/usr/bin/env ruby
# Ruby script to create recurring maintenance windows in PagerDuty
#
# Copyright (c) 2012, 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:
# * Redistributions of source code must retain the above copyright
@baskarp
baskarp / import_users.rb
Created December 18, 2012 20:07
A simple Ruby script to import users into PagerDuty from a CSV file
#!/usr/bin/env ruby
require 'rubygems'
require 'faraday'
require 'json'
require 'csv'
class PagerDutyAgent
attr_reader :requester_id
attr_reader :token
Import-Module ActiveDirectory
#Import users via the PD API, echo results
function POST_Request ($url,$parameters, $api_key) {
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open('POST', $url, $false)
$http_request.setRequestHeader("Content-type", "application/json")
$token = "Token token=" + $api_key
$http_request.setRequestHeader("Authorization", $token)
$http_request.setRequestHeader("Content-length", $parameters.length)