Skip to main content
https://img.shields.io/pypi/v/pypingdom.svg https://img.shields.io/pypi/l/pypingdom.svg https://img.shields.io/pypi/pyversions/pypingdom.svg https://travis-ci.org/sekipaolo/pypingdom.svg?branch=master

Python library for interacting with Pingdom services (REST API and maintenance windows).

Features

  • Support for Multi-User Authentication

  • Check management: create, delete, update, list

  • Maintenance windows: create, delete, list

  • Fetching outage summaries

Requirements

  • Pingdom account

  • requests (0.10.8 or newer)

Installation

pip install pypingdom

Usage

The client object will allow you to interact both with the REST API and the GUI (for maintenance windows).

>>> import pypingdom
>>> client = pypingdom.Client(username="username@example.com",
                        password="your_password",
                        apikey="your_api_key",
                        email="your_email")

the email parameter is required for Multiuser Authentication.

Checks

Since Pingdom does not treat the check name as identifier (as we probably want to do) the client object will retrieve the check list from the API and cache it as a dictionary ( check_name => check_instance). You can access it through the checks attribute:

>>> client.checks["my awesome check"]
pingdom.Check <1895866>
  autoresolve: 0
  alert_policy: 2118909
  name: example_com
  created: 1448565930
  lasterrortime: 1489325292
  resolution: 1
  lastresponsetime: 558
  lasttesttime: 1489847772
  alert_policy_name: Production Systems
  paused: False
  host: hostname.example.com
  acktimeout: 0
  ipv6: False
  use_legacy_notifications: False
  type: http
  tags: []

a better way to retrieve a check would be:

>>> client.get_check("my awesome check")

that will return None if the check doesn’t exists

List checks with production and frontend tags:

>>> client.get_checks(filters={"tags": ["production", "frontend"]})

Create a check:

>>> check_definition = {
        "name": "My awesome check",
        "paused": True,
        "alert_policy": 201745,
        "type": "http",
        "host": "www.google.com",
        "url": "/",
        "requestheaders": {
            'XCustom': 'my header value'
        },
        "tags": [{"name": "pypingdom-test"}, {"name": "custom-tag"}],
        "encryption": False
    }
>>> client.create_check(check_definition)

Refers to this page for the list of options.

When you create or modify a check some related entity need to be referenced by id:

Integrations

To enable/disable an integration plugins (like webhooks) use the field integrationids (array with integer ids to set or “null” tring to remove it)

Alert policies

To bind an alerting policy use the field alert_policy (numeric id to set it or string “null” to disable alerts)

Update a check:

>>> client.update_check(check, {"paused": True})

this will return True if an effective change was sent to the API and False otherwise (useful for idempotent usage, like ansible modules)

Delete a check:

>>> client.delete_check(check)

Maintenance windows

Retreive maintenance windows for production websites in the last 7 days:

>>> import datetime
>>> checks = client.get_checks(filters={"tags": ["production", "frontend"]})
>>> start = datetime.datetime.now() - datetime.timedelta(days=7)
>>> client.get_maintenances(filters={"checks": checks, "after": start})

Create a 1 hour maintenance window for production websites:

>>> start = datetime.datetime.now() + datetime.timedelta(minutes=10)
>>> end = start + datetime.timedelta(hours=1)

>>> window = client.create_maintenance({"checks": checks, "name": "pypingdom test maintenance", "start": start, "stop": end})

Delete future maintenance windows:

>>> windows = client.get_maintenances(filters={"checks": checks, "after": datetime.datetime.now()}):
>>> for m in maintenances:
    client.delete_maintenance(m)

Reporting/summary

Retrieve average response time and uptime summaries:

>>> checkid = client.get_check("my awesome check")._id
>>> start = int(time.time()) - 30*24*60*60 # 30 days back
>>> end = time.time()
>>> client.get_summary_average(checkid, start, end, include_uptime="true")

Release files for pypingdom 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypingdom 0.2.2
File Size Uploaded
pypingdom-0.2.2.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pypingdom 0.2.2
File Interpreter ABI Platform
pypingdom-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / pypingdom-0.2.2.tar.gz

Download URL pypingdom-0.2.2.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6269a18f286d0a806a8409003a48a4f52e16f91fae998d267dde2e3b5edcc86c
BLAKE2b-256 checksum
How to use checksums
101d79b1f3af2ef0c22f612914a87c4800c6e24c67dc62a17e3fc50eec317ed6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

Release files / pypingdom-0.2.2-py3-none-any.whl

Download URL pypingdom-0.2.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c467b54fe615dd42718f4b311f49ddaba0148a8153a1363ece481ee4f5b55497
BLAKE2b-256 checksum
How to use checksums
98c5def25496f8038045a612a6f8bf1f8bfc8ac21995e254f66c39f6525455fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

3 release files

0.1.0

3 release files

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page