A powerful, easy to configure uptime monitor
Laravel-uptime-monitor is a powerful, easy to configure uptime monitor. It will notify you when your site is down (and when it comes back up). You can also be notified a few days before an SSL certificate on one of your sites expires. Under the hood, the package leverages Laravel native notifications, so it's easy to use Slack, Telegram or your preferred notification provider.
You'll find extensive documentation on https://docs.spatie.be/laravel-uptime-monitor. It includes detailed info on how to install and use the package.
If you're not familiar with 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.
Reading the config file of this package is a good way to quickly get a feel of what laravel-uptime-monitor
can do. Here's the content of the config file:
return [
/*
* You can get notified when specific events occur. Out of the box you can use 'mail'
* and 'slack'. Of course you can also specify your own notification classes.
*/
'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 => [],
],
/*
* The location from where you are running this Laravel application. This location will be
* mentioned in all notifications that will be sent.
*/
'location' => '',
/*
* To keep reminding you that an uptime check failed, notifications
* will be resent every given number of minutes.
*/
'resend_uptime_check_failed_notification_every_minutes' => 60,
'mail' => [
'to' => 'your@email.com',
],
'slack' => [
'webhook_url' => env('UPTIME_MONITOR_SLACK_WEBHOOK_URL'),
],
/*
* Here you can specify the notifiable to which the notifications should be sent. The default
* notifiable will use the variables specified in this config file.
*/
'notifiable' => \Spatie\UptimeMonitor\Notifications\Notifiable::class,
/**
* The date format used in notifications.
*/
'date_format' => 'd/m/Y',
],
'uptime_check' => [
/*
* When the uptime check could reach the url of a monitor it will pass the response to this class
* If this class determines the response is valid, the uptime check will be regarded as succeeded.
*
* You can use any implementation of Spatie\UptimeMonitor\Helpers\UptimeResponseCheckers\UptimeResponseChecker here.
*/
'response_checker' => Spatie\UptimeMonitor\Helpers\UptimeResponseCheckers\LookForStringChecker::class,
/*
* An uptime check will be performed if the last check was performed more than the
* given number of minutes ago. If you change this setting you have to manually
* update the `uptime_check_interval_in_minutes` value of your existing monitors.
*
* When an the uptime check failed we'll check the uptime every time `monitor:check-uptime` runs
* regardless of this setting.
*/
'run_interval_in_minutes' => 5,
/*
* To speed up the uptime checking process uptime monitor can perform the uptime check of several
* monitors concurrently. Set this to a lower value if you're getting weird errors
* running the uptime check.
*/
'concurrent_checks' => 10,
/*
* The uptime check will fail if the configured url does not respond after the
* given number of seconds.
*/
'timeout_per_site' => 10,
/*
* Fire `Spatie\UptimeMonitor\Events\MonitorFailed` event only after
* the given number of uptime checks have consecutively failed for a monitor.
*/
'fire_monitor_failed_event_after_consecutive_failures' => 2,
/*
* When reaching out to sites this user agent will be used.
*/
'user_agent' => 'spatie/laravel-uptime-monitor uptime checker',
/*
* When reaching out to the sites these headers will be added.
*/
'additional_headers' => []
],
'certificate_check' => [
/*
* The `Spatie\UptimeMonitor\Events\SslExpiresSoon` event will fire
* when a certificate is found whose expiration date is in
* the next number of given days.
*/
'fire_expiring_soon_event_if_certificate_expires_within_days' => 10,
],
'expiration_check' => [
/*
* The `Spatie\UptimeMonitor\Events\DomainExpiresSoon` event will fire
* when a domain is found whose expiration date is in
* the next number of given days.
*/
'fire_expiring_soon_event_if_domain_expires_within_days' => 30,
/**
* @todo Config option for custom whois servers
* @see https://packagist.org/packages/io-developer/php-whois
* @see https://github.com/io-developer/php-whois
*/
'whois_servers' => [],
],
/*
* To add or modify behaviour to the Monitor model you can specify your
* own model here. The only requirement is that it should extend
* `Spatie\UptimeMonitor\Models\Monitor`.
*/
'monitor_model' => Spatie\UptimeMonitor\Models\Monitor::class,
];
API
Currently this package does not offer an API, if you need that take a look at this package.
Documentation
You'll find the documentation on https://docs.spatie.be/laravel-uptime-monitor. It includes detailed info on how to install and use the package.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the uptime monitor? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.
Changes with this Fork
Manage Monitors by ID
Added ability to view and use the ID of the row to manage monitors. E.g. the list command will show all with the ID field. I find it easier to manage with IDs than copying / pasting the full urls.
php artisan monitor:list
Then if you need to disable/enable/check-uptime on a monitor with a given ID or
php artisan monitor:disable 42
php artisan monitor:enable 42
php artisan monitor:check-uptime 42
New Monitor - Check Domain Registration
Added a whois lookup on the domain to monitor if a domain is going to expire within the configured window. Config option:
'fire_expiring_soon_event_if_domain_expires_within_days' => 30,
New monitor examples:
monitor:check-expiration
monitor:check-expiration --url=https://mardala.com
monitor:check-expiration --id=42
TODO
- Create tests for the domain expiration monitor
- Create tests for using IDs
- Create method for modifying / updating the data schema if using an existing installation.
- Create a stand alone package with the entire install
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
To run the tests, issue this command:
vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
We publish all received postcards on our company website.
Credits
Support us
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
License
The MIT License (MIT). Please see License File for more information.