spatie/laravel-uptime-monitor

功能强大、易于配置的在线监控工具

4.4.0 2024-09-20 13:20 UTC

This package is auto-updated.

Last update: 2024-09-20 13:20:58 UTC


README

Latest Version on Packagist MIT Licensed GitHub Workflow Status Total Downloads

Laravel-uptime-monitor 是一个功能强大、易于配置的在线监控工具。它会在您的网站宕机(以及恢复在线时)时通知您。您还可以在您的网站上某个 SSL 证书即将到期前几天收到通知。在底层,该包利用 Laravel 原生的通知,因此可以轻松使用 Slack、Telegram 或您喜欢的通知提供商。

您可以在 [https://spatie.be/docs/laravel-uptime-monitor] 找到详细的文档。它包括关于如何安装和使用该包的详细信息。

如果您不熟悉 Laravel,但仍想使用我们的在线监控工具,请查看包含该包独立版本的 uptime-monitor-app 仓库。

阅读该包的配置文件是快速了解 laravel-uptime-monitor 可以做什么的好方法。以下是配置文件的内容

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 a site is down, 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 uptime check fails we'll check the uptime for that monitor every time `monitor:check-uptime`
         * runs regardless of this setting.
         */
        'run_interval_in_minutes' => 5,

        /*
         * To speed up the uptime checking process the package 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 for a monitor will fail if the url does not respond after the
         * given number of seconds.
         */
        'timeout_per_site' => 10,

        /*
         * Because networks can be a bit unreliable the package can make three attempts
         * to connect to a server in one uptime check. You can specify the time in
         * milliseconds between each attempt.
         */
        'retry_connection_after_milliseconds' => 100,

        /*
         * If you want to change the default Guzzle client behaviour, you can do so by
         * passing custom options that will be used when making requests.
         */
        'guzzle_options' => [
            // 'allow_redirects' => false,
        ],

        /*
         * 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,
    ],

    /*
     * 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

目前此包不提供 API,如果需要,请查看 此包

文档

您可以在 https://docs.spatie.be/laravel-uptime-monitor 上找到文档。它包括关于如何安装和使用的详细信息。

使用包时遇到困难?发现了错误?您有关于改进在线监控工具的通用问题或建议?请随时在 GitHub 上创建一个问题,我们将尽快处理。

更新日志

请参阅 CHANGELOG 以获取更多有关最近更改的信息。

测试

要运行测试,请执行以下命令

vendor/bin/phpunit

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全

如果您发现有关安全的错误,请通过 security@spatie.be 发送邮件,而不是使用问题跟踪器。

鸣谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。