spatie/uptime-monitor-app

此包已被弃用且不再维护。未建议替代包。

一个用于监控在线时间和SSL证书的PHP应用程序

安装次数: 1,029

依赖项: 0

建议者: 0

安全: 0

星标: 195

关注者: 9

分支: 28

开放问题: 0

类型:项目

2.0.0 2017-01-24 17:03 UTC

This package is auto-updated.

Last update: 2020-02-12 17:20:30 UTC


README

Latest Version on Packagist Software License Total Downloads

uptime-monitor-app是一个用PHP 7编写的强大、易于配置的在线时间监控器。当您的站点之一出现故障(以及恢复正常时),它会通知您。您还可以在您的站点上的SSL证书即将到期前几天收到通知。默认情况下,您可以通过邮件或Slack接收通知。

以下是一些Slack通知的示例

68747470733a2f2f646f63732e7370617469652e62652f696d616765732f757074696d652d6d6f6e69746f722f6d6f6e69746f722d6661696c65642e6a7067
68747470733a2f2f646f63732e7370617469652e62652f696d616765732f757074696d652d6d6f6e69746f722f6d6f6e69746f722d7265636f76657265642e6a7067
68747470733a2f2f646f63732e7370617469652e62652f696d616765732f757074696d652d6d6f6e69746f722f73736c2d6578706972696e672d736f6f6e2e6a7067

在底层,在线时间监控器是一个原始的Laravel 5.3应用程序,其中安装了laravel-uptime-monitor。如果您熟悉Laravel,建议您使用laravel-uptime-monitor而不是此应用程序。

安装

您可以通过以下命令安装应用程序

composer create-project spatie/uptime-monitor-app <name of install directory>

为了完成您的安装,必须执行以下步骤

首先,您应该将以下命令添加到您的cron表中。它应该每分钟运行一次

php <installation path>/artisan schedule:run

其次,在安装目录中找到的configuration.php文件中,指定notifications.slack.url键的Slack webhook url。您可以在Slack网站上创建一个新的webhook url

配置

配置文件configuration.php位于安装目录内。

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

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,

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

基本用法

要开始监控一个url

php artisan monitor:create <url>

并回答提出的问题。如果您的url以https://开头,则应用程序还会监控SSL证书。

要停止监控一个url,请发出此命令

php artisan monitor:delete <url>

要列出您可以执行的所有监控,请

php artisan monitor:list

高级用法

在底层,在线时间监控器是一个原始的Laravel 5.3应用程序,其中安装了我们的laravel-uptime-monitor。请参阅其详尽的文档以了解如何配置和使用此应用程序。

默认情况下,应用程序将使用位于<安装目录>/database.sqlitesqlite数据库来存储所有监控器。

文档

您可以在https://docs.spatie.be/laravel-uptime-monitor/v1上找到底层laravel-uptime-monitor包的文档。

在使用此应用程序或其底层包时遇到困难吗?发现了bug吗?您是否有关于提高监控稳定性的一般性问题或建议?请随时在GitHub上创建一个issue,我们将尽快解决。

Postcardware

您可以使用此包(它是MIT许可的),但如果它进入您的生产环境,我们非常欢迎您从家乡给我们寄一张明信片,并注明您正在使用我们的哪个包。

我们的地址是:Spatie,Samberstraat 69D,2060 安特卫普,比利时。

最佳明信片将被发布在我们的网站上开源页面。

变更日志

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

贡献

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

安全

如果您发现任何与安全相关的问题,请通过电子邮件freek@spatie.be联系,而不是使用问题跟踪器。

致谢

关于Spatie

Spatie是一家位于比利时安特卫普的网络设计公司。您可以在我们的网站上找到我们所有开源项目的概述在此

许可证

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