##Basic installation
This package is meant to be installed into an existing Laravel application. If you're not familiar with Laravel head over to the official documentation to learn how to set up and use this amazing framework. If you have no interest in learning Laravel, but still want to use our uptime monitor, take a look at the uptime-monitor-app repo which contains a stand alone version of this package.
Standing in the directory of an existing Laravel application you can install the package via composer:
composer require spatie/laravel-uptime-monitor
The package will automatically register itself.
To publish the config file to config/uptime-monitor.php
run:
php artisan vendor:publish --provider="Spatie\UptimeMonitor\UptimeMonitorServiceProvider"
The default contents of the configuration looks like this:
<?php
return [
'notifications' => [
'notifications' => [
\Spatie\UptimeMonitor\Notifications\Notifications\UptimeCheckFailed::class => ['slack'],
\Spatie\UptimeMonitor\Notifications\Notifications\UptimeCheckRecovered::class => ['slack'],
\Spatie\UptimeMonitor\Notifications\Notifications\UptimeCheckSucceeded::class => [],
\Spatie\UptimeMonitor\Notifications\Notifications\CertificateCheckFailed::class => ['slack'],
\Spatie\UptimeMonitor\Notifications\Notifications\CertificateExpiresSoon::class => ['slack'],
\Spatie\UptimeMonitor\Notifications\Notifications\CertificateCheckSucceeded::class => [],
],
'location' => '',
'resend_uptime_check_failed_notification_every_minutes' => 60,
'mail' => [
'to' => ['your@email.com'],
],
'slack' => [
'webhook_url' => env('UPTIME_MONITOR_SLACK_WEBHOOK_URL'),
],
'notifiable' => \Spatie\UptimeMonitor\Notifications\Notifiable::class,
'date_format' => 'd/m/Y',
],
'uptime_check' => [
'response_checker' => Spatie\UptimeMonitor\Helpers\UptimeResponseCheckers\LookForStringChecker::class,
'run_interval_in_minutes' => 5,
'concurrent_checks' => 10,
'timeout_per_site' => 10,
'retry_connection_after_milliseconds' => 100,
'guzzle_options' => [
],
'fire_monitor_failed_event_after_consecutive_failures' => 2,
'user_agent' => 'spatie/laravel-uptime-monitor uptime checker',
'additional_headers' => [],
],
'certificate_check' => [
'fire_expiring_soon_event_if_certificate_expires_within_days' => 10,
],
'monitor_model' => Spatie\UptimeMonitor\Models\Monitor::class,
];
As a last step, run the migrations to create the monitors
table.
php artisan migrate
##Scheduling
After you have performed the basic installation you can check the uptime and ssl certificates of sites using the monitor:check-uptime
and monitor:check-certificate
commands. In most cases you'll want to schedule them. We recommend that you run the uptime check every minute and the ssl certificate check daily.
You can schedule the commands, like any other command, in the console Kernel.
protected function schedule(Schedule $schedule)
{
$schedule->command('monitor:check-uptime')->everyMinute();
$schedule->command('monitor:check-certificate')->daily();
}