Skip to content
The PagerDuty Agent is a program that lets you easily integrate your monitoring system with PagerDuty.
Python Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Add source_address config param and us it in httpswithverify.py Jan 1, 2017
build-linux removing commented code Jul 26, 2019
conf check for python minor ver > 6 for source_address arg Aug 9, 2018
pdagent bumped version and removed release content from readme Jul 26, 2019
pdagenttest added centos72 env and update self_signed cert to 2048 bit Aug 10, 2018
pdagenttestinteg setting util.sh service key back to CHANGEME Aug 13, 2018
scripts one-time rpm scriptlet tweaks for v1.4 -> v1.5 upgrade Aug 13, 2018
.gitignore Minor gitignore reordering Mar 18, 2014
.project Change pydev project name to pdagent Feb 27, 2014
.pydevproject
LICENSE.TXT Mention third party contributors Jul 7, 2014
README.md bumped version and removed release content from readme Jul 26, 2019
SConstruct Bug fix with list-access in SConstruct Apr 23, 2014
Vagrantfile package tweaks for proper state transitions Aug 11, 2018
idea-setup.md
pydev-setup.md doc updates Jul 26, 2019
run-tests.py Add license to run-tests.py Feb 21, 2014
scons-setup.md doc updates Jul 26, 2019
vagrant-setup.md doc updates Jul 26, 2019

README.md

This is the source code and project. For the PagerDuty Agent Install Guide, see http://www.pagerduty.com/docs/guides/agent-install-guide/

Introduction

The PagerDuty Agent is a program that lets you easily integrate your monitoring system with PagerDuty.

It includes command-line tools to trigger, acknowledge & resolve PagerDuty incidents.

The supported events are those listed in the PagerDuty Integration API:

https://v2.developer.pagerduty.com/docs/events-api

The PagerDuty Agent is completely open-source which means that you can download the source code and customize it for your needs.

The Agent requires Python 2.6 or 2.7. The instructions here assume that you're on a Mac.

Developing

Running in Development

You can run the Agent in development without any setup. Start the Agent daemon as follows:

bin/pdagentd.py

When run in development the daemon automatically creates a tmp directory inside the project where it stores its various work files.

Similarly, you can use the pd-send command immediately.

bin/pd-send -h
usage: pd-send [-h] -k SERVICE_KEY -t {trigger,acknowledge,resolve}
               [-d DESCRIPTION] [-i INCIDENT_KEY] [-f FIELDS]

Queue up a trigger, acknowledge, or resolve event to PagerDuty.
...

Make sure that you have run the daemon at least once so that the tmp directory exists.

You can stop the daemon as follows:

kill $(cat tmp/pdagentd.pid)

IDE Setup

For IDE setup instructions see PyDev Setup or IDEA Setup. Apart from the usual benefits, the IDEs provide PEP-8 warnings which we care about.

Build Tools

To perform a complete automated build, you'll need to install Vagrant and Scons. See Vagrant Setup and Scons Setup for instructions.

Running Unit Tests

You can run the unit tests with the following command:

scons test-local

To run them without installing SCons, use the run-tests.py test runner, e.g.:

python run-tests.py pdagenttest/test_*.py pdagenttest/thirdparty/test_*.py

Building Packages

For development builds, you can perform a full automated clean build of the Agent with the following steps:

  1. Configure signing keys by following the One-time setup of GPG keys instructions.

  2. Run the following commands:

scons --clean
scons local-repo gpg-home=build-linux/gnupg

Note that this will spin up multiple virtual machines using Vagrant to run tests and perform builds on.

  1. Run integration tests on the packages as follows:
  • Edit the file pdagenttestinteg/util.sh and change the line SVC_KEY=CHANGEME to a real PagerDuty Service API Key in your pdt test account.
  • Run the command:
scons test-integration

This will run the integration tests on the various VMs using the packagesbuilt in the previous step. Note that the tests will trigger and resolve some incidents when they run.

If you want to build packages by hand, follow the instructions in the Build Linux Howto.

Similarly, you can check the SCons targets using scons -h for instructions on performing specific builds tasks and on specific VMs.

Some helpful scripts

scripts/rev_pkgs.sh

This will remove the installed pdagent packages from the vagrant build machines, agent-minimal-centos65 and agent-minimal-ubuntu1204, and run scons local-repo gpg-home=build-linux/gnupg to install them again. Run this anytime you revise a package artifact like build-linux/deb/postinst.

scripts/kill_pids.sh

This will kill stray pdagent processes and cleanup the pidfile on all vagrant machines. Run this if your changes are causing integration tests to fail due to improper process managment via service or systemctl.

scripts/setup_upgrade_test.sh

This will vagrant destroy, up and install the latest public repo pdagent package on machines for upgrade testing via scons test-integration.

#License Copyright (c) 2013-2014, 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 notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder 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.

You can’t perform that action at this time.