The New nodepingpy Python Package

NodePing has offered a Python library over the years to support convenient usage with our API in your Python projects. Since our current Python package, nodeping-api, was released, Python 2 has become deprecated and Python 3 has made additions. While looking at using some of those additions and the deprecation of Python 2, we decided it would be better to rewrite a whole new package with an improved design instead of improving the old one. Some improvements include:

  • Using dataclasses where convenient for data being submitted to the API
  • Consistent design across the different modules
  • Changed docstrings to Google Style docstrings from Sphinx style
  • Typing used throughout the package

Like the nodeping-api package, nodepingpy provides feature parity with the NodePing API and can do the following, and more:

  • List, create, update, and delete checks
  • Manage contacts
  • Manage contact groups
  • Manage schedules
  • Get check results and uptime
  • Get notification information
  • Get probe information

You can get the code from our GitHub repository or install it from PyPi via pip. Examples are provided in the README as well as useful information provided by the docstrings that will be shown by your text editor’s completion menus.

Installation

To install nodepingpy, you can use the pip package manager:

python3 -m pip install nodepingpy

Examples

Below I will provide a few code snippets to demonstrate how you can use the nodepingpy package to manage your NodePing account via our API.

Get a list of failing checks:

# -*- coding: utf-8 -*-

from pprint import pprint
from nodepingpy import checks


def main():
    """Get failing checks."""

    token = "my-secret-token"
    failing = checks.get_failing(token)

    pprint(failing)


if __name__ == "__main__":
    main()

With the output from the API:

{'202306261809OGK26-HM723FI3': {'_id': '202306261809OGK26-HM723FI3',
                                'created': 1711487757004,
                                'customer_id': '202306261809OGK26',
                                'enable': 'active',
                                'firstdown': 1711487850335,
                                'interval': 1,
                                'label': 'Test Check',
                                'modified': 1711487833733,
                                'mute': False,
                                'parameters': {'sens': 2,
                                               'target': 'sholudfail.example.com',
                                               'threshold': 5},
                                'queue': 'txWlac7EdV',
                                'runlocations': False,
                                'state': 0,
                                'status': 'assigned',
                                'type': 'PING'}}

The following example will create an HTTP check targeted at ‘https://nodeping.com’:

# -*- coding: utf-8 -*-

from pprint import pprint
from nodepingpy import checks
from nodepingpy.nptypes import checktypes


def main():
    """Create an HTTP check."""

    token = "my-secret-token"
    args = checktypes.HttpCheck(
        "https://example.com", label="Check NodePing", interval=3, runlocations="nam"
    )
    result = checks.create_check(token, args)

    pprint(result)


if __name__ == "__main__":
    main()

The check was created and I received this from the API as a response:

{'_id': '202306261809OGK26-FFLHP1UX',
 'autodiag': False,
 'change': 1711488209387,
 'created': 1711488209387,
 'customer_id': '202306261809OGK26',
 'dep': False,
 'enable': 'inactive',
 'homeloc': False,
 'interval': 3,
 'label': 'Check NodePing',
 'modified': 1711488209387,
 'mute': False,
 'parameters': {'follow': False,
                'ipv6': False,
                'sens': 2,
                'target': 'https://example.com/',
                'threshold': 5},
 'public': False,
 'runlocations': ['nam'],
 'status': 'modified',
 'type': 'HTTP',
 'uuid': 'vo5r82j8-twkq-4553-8d0t-02wlfhlgy2x7'}

Lastly, an example of creating a contact on your account:

# -*- coding: utf-8 -*-

from pprint import pprint
from nodepingpy import contacts

from nodepingpy import contacts


def main():
    """Create a NodePing account contact."""

    token = "my-secret-token"
    name = "Bob Alice"
    custrole = "edit"
    customerid = "202306261809OGK26"
    newaddresses = [
        {"address": "me@email.com", "type": "email"},
        {"address": "5551238888", "type": "sms"},
    ]
    result = contacts.create(token, customerid, custrole, name, newaddresses)

    pprint(result)


if __name__ == "__main__":
    main()

And the response I received from the API:

 'addresses': {'0CCJ3QUK': {'accountsuppressall': False,
                            'address': 'me@email.com',
                            'type': 'email'},
               '0CIIIE7K': {'accountsuppressall': False,
                            'address': '5551238888',
                            'type': 'sms'}},
 'customer_id': '202306261809OGK26',
 'custrole': 'edit',
 'name': 'Bob Alice',
 'sdomain': 'nodeping.com',
 'type': 'contact'}

This is only a small part of what the library can do, and the documentation is detailed to get you started on integrating NodePing into your Python project. Give it a try and see how you can improve your uptime monitoring in your Python projects. This code is free and available to download. We encourage pull requests for new features so if you make changes or have requests, feel free to share.

If you aren’t using NodePing yet, you can sign up for a free, 15-day trial and test out monitoring your services today and take advantage of our API in your own Python projects.

Probe Server Change [FR]

The following probe server will be changing IP addresses on 2023-09-13

Paris, France (FR) – FR will change from
195.154.167.97 / 2001:bc8:2327:110::10
to
163.172.52.132 / 2001:bc8:2327:101::10

Please adjust your firewalls appropriately if you whitelist so your checks do not fail because of the probe IP address changes.

An always current and updated list of all the IP addresses for our probe servers can be found in the FAQ, a text file, and via DNS query, probes.nodeping.com.

[UPDATE – 2023-09-13 11:11GMT-7] – IP change complete.

Monitor HTTP Services that require X.509 Certificates

NodePing supports TLS X.509 client certs for authentication to monitor supported HTTP services.

X.509 client certificates utilize public-key infrastructure (PKI) to authenticate to TLS services. Web APIs and other REST-based services can issue their users TLS client certs to authenticate their client requests. X.509 certs can be used alone or along with other supported authentication methods including BASIC AUTH and form-based submission.

To get started monitoring X.509 authenticated HTTP services, upload your client certs to the “Certs and Keys” area and configure the HTTP Advanced checks to authenticate using the TLS client cert. HTTP Advanced checks support verifying specific HTTP status codes in the response, sending and verifying specific headers, specify HTTP methods (POST, PUT, DELETE, HEAD, TRACE, CONNECT), and send form data or raw content like JSON or XML.

If you don’t yet have a NodePing account, please sign up for our free, 15-day trial and see for yourself why professionals around the world use NodePing.

Probe Server Addition [NV]

The following probe server will be added on 2023/04/26:

Las Vegas, Nevada (NV) – USA
(72.46.131.14 / 2605:6f80:0:d::100)

Please adjust your firewalls appropriately if you whitelist so your checks do not fail because of the probe IP address changes.

An always current and updated list of all the IP addresses for our probe servers can be found in the FAQ, a text file, and via DNS query, probes.nodeping.com.

[UPDATE – 2023-04-26 11:45GMT-7] – IP changes complete.

MongoDB Monitoring

Monitoring the availability of a MongoDB database just got a lot easier. Even better, you can monitor, track, graph, and alert on results from a query. That makes NodePing’s new MongoDB check so much more powerful than just uptime monitoring.

Some of the old-timers at NodePing remember when MongoDB hit the scene in 2009. Now the scrappy little fella is double digits old and is a major player in the NoSQL market so adding monitoring functionality for MongoDB was an easy choice.

Availability monitoring for MongoDB is pretty straightforward using the MongoDB connection URL. You can include authentication, host, and port information and we’ll do the rest.

But not everyone can poke a hole in their firewall so a service can keep an eye on their MongoDB instance. With NodePing AGENT checks, you can set up a private probe behind your firewall where your MongoDB checks can run and send their results to us for tracking and notifications. No firewall changes needed.

But wait, there’s more! (how cheesy does that sound?) Need to keep an eye on how many visitors are hitting your MongoDB powered website? Maybe you want to track how many downloads a particular file gets each day. With our MongoDB check, you can specify a query, track, and graph the results. Set a minimum and maximum range for numeric results or do an exact match or regex on string results. You’ll get notifications if the results are not what you’re expecting. If the information is in the database, we can query, track, and graph it.

For instructions on how to create your first MongoDB check, please see our documentation. If you don’t have a NodePing account yet, sign up for our free, 15-day trial and see how fast and accurate NodePing monitoring is for yourself.

Probe Server Removal [NV]

The following probe server will be removed immediately:

Las Vegas, Nevada (NV) – USA
(5.104.78.90 / 2602:fe90:700:2::100)

Please adjust your firewalls appropriately if you whitelist so your checks do not fail because of the probe IP address changes.

An always current and updated list of all the IP addresses for our probe servers can be found in the FAQ, a text file, and via DNS query, probes.nodeping.com.

Probe Server Addition [NV] and Removal [UT]

The following probe server will be added on 2022/11/30:

Las Vegas, Nevada (NV) – USA
(5.104.78.90 / 2602:fe90:700:2::100)

Additionally, we are also removing the following probe server on 2022/11/30:

Ogden, Utah (UT) – USA
(192.154.102.130 / 2606:c700:4020:17:225:90ff:fe50:390a)

Please adjust your firewalls appropriately if you whitelist so your checks do not fail because of the probe IP address changes.

An always current and updated list of all the IP addresses for our probe servers can be found in the FAQ, a text file, and via DNS query, probes.nodeping.com.

[UPDATE – 2022-11-30 12:18GMT-7] – IP changes complete.

MySQL Monitoring

Last month we released our PostgreSQL check with some great features to query, verify, and track result data. We knew some in the NodePing crowd favor MySQL so we put the nose to the grindstone to power up the MySQL check with the same tasty features.

You can ensure that the MySQL database and the host it’s on are available and responding. Optionally send a user-defined query and verify the responses is within your configured thresholds.

If the expected response is numeric, you can set a minimum and maximum threshold and NodePing will alert you if it’s too low or two high. This is handy to get alerts about application login errors or pretty much anything else you can numerically log in your database.

You can also match your query response to text, either by exact match or use a regex for powerful pattern matching. Get alerts when the text you’re expecting is missing.

The results, metric or text, are saved and tracked in your NodePing check history.

NodePing’s new MySQL monitoring is available now. If you don’t have a NodePing account, please sign up for a free, 15-day trial. Be the first to know when your database is offline.

PostgreSQL Monitoring

The database is the cardinal authority of modern website content. PostgreSQL, also known as Postgres or pg, is standing among the top 4 databases in 2022. It’s free and open-source and focuses on extensibility and SQL compliance.

If your database fails, your site may be responding but that all-important content will be missing. It’s best practice to monitor your database to make sure it’s online, responding to connections, and returning the data expected. NodePing’s new PostgreSQL check has got your postgres monitoring covered.

You can ensure that the database and the host it’s on are available and responding. You can also optionally send a query of your choice and verify that the response is within your configured threshold.

If the expected response is numeric, you can set a minimum and maximum threshold and NodePing will alert you if it’s too low or two high. This is handy to get alerts about application login errors or pretty much anything else you can numerically log in your database.

You can also match your query response to text, either by exact match or use a regex for powerful pattern matching.

NodePing’s new pg monitoring is available on all plans and accounts. If you don’t yet have a NodePing account, please sign up for a free, 15-day trial. We’re confident you’ll find our PostgreSQL monitoring fast and reliable.

MTR Check to Monitor Packet Loss

Packet loss and routing issues can impact any provider. Our newest check type, MTR, can help you detect and pinpoint the root of the problem. Faster detection and troubleshooting means less downtime for your websites and services.

The MTR command line tool has been around since 1997. Ask any graybeard sysadmin, they’re sure to be familiar with it. It’s great for revealing the presence of packet loss on a host and where along the route that packet loss starts.

Since routing is different for IPv6 than IPv4, you’ll want to create 2 MTR checks per host – one for your IPv4 address and another for the IPv6 address. You can either force IPv6 DNS resolution on your FQDN or use the IPv6 address itself as the check target.

MTR results from our probes is only half the story though. To get the full picture, you may need to run an MTR from your server. Use NodePing AGENT software to run MTR, PING, and nearly all our other check types from your server. It’s like having your own private NodePing probes. Results are quickly pushed to NodePing for processing and notifications.

No other network tool is more widely used among sysadmins for troubleshooting connectivity issues than MTR. Now you can automate it on both sides of the network using NodePing’s new MTR check.

If you don’t yet have a NodePing account, please sign up for our free, 15-day trial. Your graybeards will thank you.