Scheduled task monitoring now available to all our users

After an intense testing period, we're excited to announce our scheduled task monitoring is now available to all our users!

Scheduled task monitoring in Oh Dear

Why monitor scheduled tasks?

Automation is at the heart of just about every company these days. We trust our automation to do the work for us. We trust that it will continue to run fine, from the day we wrote the code.

But trust isn't a strategy. It's hope. It's a wish.

With our newly launched scheduled task monitor, we can turn that hope into a certainty. 😎

You'll be able to monitor the frequency of every scheduled task you have and get actionable reports when they either A) don't run on time or B) don't report any status, indicating the task more than likely failed.

Free for all Oh Dear users

This feature is now live and available to all existing Oh Dear users, at no additional cost.

You'll find a new column on your dashboard called Tasks, with additional information available once you click through. Per site, you can add scheduled tasks and start monitoring straight away!

How does scheduled task monitoring work?

We use an industry-standard approach in the form of "ping URLs".

The idea is quite simple: after every task gets executed, your application code can make a network request to a pre-defined URL we provide you. We monitor the requests on that URL.

If we don't receive a request (on time), we assume the scheduled task has failed, and we can notify you.

Making a network request doesn't have to be complex, for many languages it's a one-line addition to your scripts.

PHP:

@file_get_contents('https://ping.ohdear.app/e536e771-9ff6');

Python:

requests.get("https://ping.ohdear.app/e536e771-9ff6")

Ruby:

Net::HTTP.get(URI.parse('https://ping.ohdear.app/e536e771-9ff6'))

Node:

https.get("https://ping.ohdear.app/e536e771-9ff6");

We've got a lot of examples available for just about any popular language.

Deep integration into PHP

Because we have deeply nested roots in the PHP community, there are more convenient integrations available for Laravel and Symfony users.

For Laravel, you can integrate using an additional package that auto-syncs your tasks to Oh Dear.

$ composer require spatie/laravel-schedule-monitor
$ composer require ohdearapp/ohdear-php-sdk 
$ php artisan vendor:publish --provider="Spatie\ScheduleMonitor\ScheduleMonitorServiceProvider" --tag="migrations"
$ php artisan vendor:publish --provider="Spatie\ScheduleMonitor\ScheduleMonitorServiceProvider" --tag="config"
$ php artisan migrate

As a final step, add your Oh Dear API key to config/schedule-monitor.php and this package will automatically sync all schedules to Oh Dear and we'll take it from there.

Cron sync from Oh Dear

Freek made a more in-depth video of how this works under the hood, if you're interested:

If you prefer not to use an extra package, you could add the thenPing() method to each of the task definitions in your Console/Kernel.php instead:

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('emails:send')
            ->daily()
            ->thenPing('https://ping.ohdear.app/e536e771-9ff6');
    }
}

For Symfony users, there's a PingTask package that allows you to define the ping URL per task you define:

use Zenstruck\ScheduleBundle\Schedule\Task\PingTask;

$schedule->add(new PingTask('https://ping.ohdear.app/e536e771-9ff6'));

Whatever your use case may be, you'll find a convenient integration for it.

Notifications where you need them

As with all our checks, this monitoring is coupled with our powerful notification system!

You can choose where you receive your notifications and what type of notifications you want. Only care about the failures? Just enable that.

Example Slack notification for a failed scheduled task

We've been using this ourselves for several months now and have included every improvement we wanted ourselves into this feature. Our goal is to put all the necessary information right at your fingertips.

Cron jobs & scheduled task monitoring

We call the feature "scheduled task monitoring", but it's more than just that. Anything can be a scheduled task.

From a cron job that calls a back-up script to a scheduled task on Windows, everything that should run on a fixed schedule can be monitored through this new feature.

For instance, you can monitor the successes of your back-up script that is triggered via cron:

24 4 * * * /root/tarsnap-backup.sh && curl -fsS --retry 3 -o /dev/null https://ping.ohdear.app/e536e771-9ff6

Because of the use of the && operator, the curl example will only be executed if the first script exited with an exit code of 0, to indicate it succeeded. If it reports anything else, the curl won't be called and we will know we missed a report for that task.

Monitoring queues and jobs health

Since the idea behind scheduled task monitoring is to check a URL for recurring hits, this can also be used to monitor the health of running jobs or queues.

Imagine the following flow:

  1. Add a new scheduled task in your code to put a new job on the queue every 5 minutes
  2. This job has one purpose: to ping our endpoint

This way, you've tested your application one step further: this ensures both the schedule runs and the queues are alive to pick up & process jobs.

If we don't receive the hit to our endpoint on time, chances are something's wrong and we can alert you.

Want to give it a try?

Some things at Oh Dear don't change: we still have a free, 10-day trial, with no strings attached. Just an email and a password are needed, no credit card details.

Start a trial today and see how easy it is to integrate scheduled task monitoring!

If you decide to sign up, we're giving a 30% discount for the first 3 months for any new user. Use coupon code MONITOR-ALL-THE-THINGS during subscription to lock in your discount. This code is valid until October 1st, 2020!

We're immensely proud of this feature (so much goes on behind the scenes) and can't wait to hear your feedback.

If we could ask a favour: share this post as far and wide as you can! 😁

More updates

Want to get started? We offer a no-strings-attached 30 day trial. No credit card required.

Start monitoring

You're all set in
less than a minute!