Skip to content

Heartbeat Monitoring

Overview

Pingniner offers a simple and reliable way to monitor your scheduled tasks. This can be easily integrated with cronjobs, inside shell scripts, or directly into your app. This helps you ensure that your scheduled tasks run smoothly and on time. Here’s how you can set it up and use it effectively:

Adding a Heartbeat Monitor

  1. Sign in to your Pingniner account.
  2. Navigate to Heartbeats (main menu) and click on "Add Heartbeat Monitor".
  3. Fill in the details: Set a friendly name, fill in the scheduled task frequecy, expressed in minutes and the allowed grace time, also in minutes. Optionally, you can attach the monitor to a group, add some tags or notes.
  4. Integrate Our system will generate an unique ping URL which you can integrate into your systems.

INFO

Grace time defines how much time should we allow for a ping to be received before an alert is sent. For example, for a heartbeat with a 5-minute frequency and a 3-minute grace time, if a ping is not received in 8 minutes, an alert will be created.

Integrating the Ping URL

Here are some examples on how you can integrate hearbeat monitoring into your systems.

Cronjobs

sh
* * * * * echo "Hello World" && curl -fsS -m 10 --retry 5 -o /dev/null https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

* * * * * echo "Hello World" - is your actual cronjob
&& curl -fsS -m... - is simply appended to your existing cron job

PHP (Generic)

php
@file_get_contents("https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID");

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

TIP

Make sure your script stops executing on error or that some kind of logic is added so that the request isn't made even if the script/job failed.

PHP (Laravel)

In Laravel you can use thenPing() in your scheduler. Open app/Console/Kernel.php and add ->thenPing('https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID') to any command that you wish to monitor.

php
class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule): void
    {
		$schedule->command('telescope:prune')
			->daily()
			->thenPing('https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID');
	}
}

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

INFO

Laravel takes care of execution logic and runs thenPing() only on success.

Python

In Python you can use the requests library to make a Ping to our API.

python
import requests
requests.get("https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID")

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

TIP

Make sure your script stops executing on error or that some kind of logic is added so that the request isn't made even if the script/job failed.

Ruby

In Ruby you can use net/http library to make a Ping to our API.

ruby
require 'net/http'
require 'uri'
Net::HTTP.get(URI.parse('https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID'))

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

TIP

Make sure your script stops executing on error or that some kind of logic is added so that the request isn't made even if the script/job failed.

NodeJS

In NodeJS you can use the built-in functions from https to make a Ping to our API.

javascript
var https = require('https');
https.get("https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID");

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

TIP

Make sure your script stops executing on error or that some kind of logic is added so that the request isn't made even if the script/job failed.

Perl

In Perl you can use the LWP::Simple library to make a Ping to our API.

perl
use LWP::Simple;
get("https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID");

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

TIP

Make sure your script stops executing on error or that some kind of logic is added so that the request isn't made even if the script/job failed.

Bash (shell scripts)

Using cUrl

sh
curl --retry 3  https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID

Using Wget

sh
wget -O /dev/null  https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID

Replace YOUR_HEARTBEAT_ID with the ID of your monitor.

Providing runtime, memory and message

You can optionally provide runtime, memory usage, and a message in the heartbeat URL as GET parameters.

https://ingest.pingniner.com/api/heartbeat/YOUR_HEARTBEAT_ID?runtime=100&memory=100&message=Hello+World
  • runtime - numeric
  • memory - numeric
  • message - URL encoded string

You can choose to pass along just one of these items or all of them at once, all are optional.

TIP

Sending runtime and/or memory will automatically activate the performace graphs on the heartbeat monitor dashboard.

Viewing & Managing Heartbead Monitors

To view or manage a heartbeat monitor, click on Heartbeats (main menu) and then click on the desired heartbeat monitor.

Overview

The overview dashboard offers a bird's-eye view of the heartbeat monitor with:

  • Real-time status
  • Runtime graph (if runtime is reported)
  • Memory graph (if memory is reported)
  • Uptime
  • Tips on how to integrate

Edit

This section can be used to update the monitor's details. All details can be updated if required, including the frequency and grace time.

History

Here you can check and export the historical data of received pings.

Runtime, Memory and messahe is availble here, if reported, for each received ping.

INFO

Historical data is available for the last 30 days for subscribed accounts and 1 day for free accounts.

Triggers

In this tab, you can manage the active checks and triggers for the current monitor.

For heartbeat monitors, the following triggers iare available:

  • Grace Time Exceeded: This trigger is active by default and is used to fire an alert if the a Ping is not received in the allowd time frame.
  • Runtime: If you are reporting runtime you can activate this trigger to receive an alert if the reported runtime exceeds your threshhold.
  • Memory: If you are reporting memory you can activate this trigger to receive an alert if the reported memory exceeds your threshhold.

INFO

While updating a trigger, you can set the contacts that get notified, the threshold value (where applicable), and the sensitivity (occurrences) of the trigger.

TIP

You can adjust the sensitivity of the trigger with Occurrences. By default, the Blacklisted trigger has occurrences set to 1, which means that on first detection on any blacklist, an alert will be created.