PagerDuty Public Support Scripts
This is a collection of miscellaneous scripts that the PagerDuty Support Team has written and collected over time. Their purpose is to perform specific, limited-scope tasks through the REST API that cannot (as of the time that they are written) be performed through the PagerDuty UI.
This README shall serve as both a set of instructions on the usage of these scripts as well as a description of how this repository is to be maintained and organized.
Each of the directories within this repository describes a task in
carried out by the script(s).
In each of these directories shall be the script(s) that carry out the task, plus documentation on usage.
Each script can be run as a standalone program, i.e.:
As opposed to requring it to be run as follows, although it is also an option:
<interpreter> name-of-script.lang <options>
If including the command line flag
-h, the script shall print out
instructions for usage ("helptext").
The directory shall also contain a file
README.md containing any additional
usage instructions that cannot be included in the helptext and/or historical
information about the origin of the script (i.e. original author/source) and
how it has been used / can be used.
In some cases, scripts will require additional software modules or libraries in order to run.
If the script is written in Python, the directory shall include a file
requirements.txt, which can be used to install dependencies with
pip install -r ./requirements.txt
The program pip must be installed in the local operating system in order to perform this type of dependency installation.
More information on requirements files can be found in the pip documentation, at pip.pypa.io.
If the script is written in Ruby, the directory shall include a file
specifiying gem dependencies, that can be used to install them using the
Rubygems will need to installed in the local operating system in order to perform this type of dependency installation.
More information on gemfiles and Bundle can be found here: bundler.io/gemfile.html
In addition to following each of the above conventions, i.e. residing in its own directory, each script shall begin with with a "shebang" line as follows:
<interpreter> is the language command (i.e.
etc.). Specific versions of interpreters (i.e. Python 2.7 or Python 3) shall be
specified in the name of the exectuable. If the generic name is used (i.e.
python), the script should be written such that it is compatible with the
widest possible range of versions that might be available on any given
The following is a list of supplemental scripts that may eventually be merged into this collection and standardized/documented in the future according to the outlined above. Any that remain referenced here indefinitely have been deemed sufficiently well-documented and self-contained, i.e.:
- They reside in their own GitHub repository (which facilitates contributing to them) versus a Gist or a file in itself passed around
- They already follow many of the conventions of this collection of scripts
- The original maintainer is willing to review and accept pull requests to fix bugs
- They are both hosted and used externally / in the cloud, i.e. JSFiddle
Download Alerts to CSV
A sample script to programatically access and download the alerts for an incident as a CSV file.
Alert Volume/Pain for On-Call Users
A quick command-line to get the incident volume assigned to an escalation policy broken down by week.
Get Incident Details
Sample script to output incident details to a CSV in the format:
Export Incidents to CSV
Output all PagerDuty incidents for a given time period to a CSV file.
Sample shell script to pull PagerDuty incidents that were triggered within the given time period and are currently open.
Show All Incidents for a Service and Output to a File
Pull all the incidents from a service within a given time range and print the output to the file
Trigger an incident within multiple PagerDuty services.
Trigger/acknowledge/resolve PagerDuty incidents
Snooze a PagerDuty incident
JSFiddle to snooze an incident within your account
Incident Log Entries
Get Log Entry Details
Script to retrieve detailed information about a specific log entry
Script to retrieve detailed information about a specific PagerDuty log entry in a plain text file
Retrieve Lists of Log Entries
Get a summary of all log entries for an incident
Get Details of a Schedule
Retrieve information about a specific schedule
List Schedules by Name
JSFiddle to list all PagerDuty schedules by name
List On-Call Shifts for a PagerDuty Schedule
JSFiddle to list on-call shifts for a particular schedule
Update Settings on All PagerDuty Services
JSFiddle to update acknowledgement_timeout and auto_resolve_timeout parameters on all PagerDuty services
Schedule Recurring Maintenance Windows
Schedule a recurring regular maintenance window for a service or services.
Remove All Future Maintenance Windows
Removes all future maintenance windows for a service or from your entire account.
Get User Activity
Get the latest activity for all users within a PagerDuty account.
List PagerDuty Users who Don't Have a Minute 0 Phone Notification
List users who have a small # of Notification Rules
List On-Call Users
Also: same as above, but with
Import Users from CSV
Given a CSV named "users.csv" in the format:
name,email,role,address,type John Doe,firstname.lastname@example.org,admin,5555555555,phone Jane Doe,email@example.com,user,5555555554,sms
Creates each user, creates a default contact method and immediate notification rule for email, and creates a contact method and immediate notification rule for SMS or phone.
Note: Phone address must be a valide 10-digit phone number
Note: Address type must be one of
Import Users from Active Directory
If you are looking for an integration with ADFS, use this guide:
If you would like a one-time import of users via AD, you can use this:
List PagerDuty Users with Contact Information
Add webhooks to every PagerDuty service
Replace Webhook URL on All PagerDuty Services
License and Copyright
Copyright (c) 2016, PagerDuty 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 notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of [project] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.