spatie/server-monitor-app

一个用于监控服务器健康的PHP应用程序

1.0.1 2017-03-16 09:03 UTC

This package is auto-updated.

Last update: 2024-09-21 18:18:59 UTC


README

一个用于监控您的服务器健康的PHP应用程序

Latest Version on Packagist Software License Total Downloads

我们都梦想着不需要任何维护的服务器。但不幸的是,在现实中并非如此。磁盘可能会满,进程可能会崩溃,服务器可能会耗尽内存...

这个命令行应用程序会监控您所有服务器的健康。有一些内置检查

当出现问题时,它可以通过Slack或邮件通知您。这是Slack通知的示例

Screenshot slack

在底层,server-monitor-app是一个纯Laravel 5.4应用程序,在其中安装了laravel-server-monitor。如果您熟悉Laravel,建议您使用laravel-server-monitor而不是此应用程序。

支持我们

我们投入了大量资源来创建最佳开源软件包。您可以通过购买我们的付费产品之一来支持我们。

我们非常感谢您从您家乡寄给我们明信片,说明您正在使用我们哪些软件包。您可以在我们的联系页面上找到我们的地址。我们将所有收到的明信片发布在我们的虚拟明信片墙上。

需求

查看底层软件包的文档中的要求

安装

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

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

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

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

php <installation path>/artisan schedule:run

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

可选地,您可以通过在安装目录中找到的.env文件中填写MAIL_键,并将mail添加到configuration.php文件中的notifications数组中,来配置电子邮件通知。

配置

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

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

return [

    /*
     * These are the checks that can be performed on your servers. You can add your own
     * checks. The only requirement is that they should extend the
     * `Spatie\ServerMonitor\Checks\CheckDefinitions\CheckDefinition` class.
     */
    'checks' => [
        'diskspace' => Spatie\ServerMonitor\CheckDefinitions\Diskspace::class,
        'elasticsearch' => Spatie\ServerMonitor\CheckDefinitions\Elasticsearch::class,
        'memcached' => Spatie\ServerMonitor\CheckDefinitions\Memcached::class,
        'mysql' => Spatie\ServerMonitor\CheckDefinitions\MySql::class,
    ],

    /*
     * The performance of the package can be increased by allowing a high number
     * of concurrent ssh connections. Set this to a lower value if you're
     * getting weird errors running the check.
     */
    'concurrent_ssh_connections' => 5,

    /*
     * This string will be appended to the ssh command generated by the package.
     */
    'ssh_command_suffix' => '',

    'notifications' => [

        'notifications' => [
            Spatie\ServerMonitor\Notifications\Notifications\CheckSucceeded::class => [],
            Spatie\ServerMonitor\Notifications\Notifications\CheckRestored::class => ['slack'],
            Spatie\ServerMonitor\Notifications\Notifications\CheckWarning::class => ['slack'],
            Spatie\ServerMonitor\Notifications\Notifications\CheckFailed::class => ['slack'],
        ],

        /*
         * To avoid burying you in notifications, we'll only send one every given amount
         * of minutes when a check keeps emitting warning or keeps failing.
         */
        'throttle_failing_notifications_for_minutes' => 60,

        'mail' => [
            'to' => 'your@email.com',
        ],

        'slack' => [
            'webhook_url' => env('SERVER_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\ServerMonitor\Notifications\Notifiable::class,

        /*
         * The date format used in notifications.
         */
        'date_format' => 'd/m/Y',
    ],

    /*
     * To add or modify behaviour to the `Check` model you can specify your
     * own model here. The only requirement is that they should
     * extend the `Check` model provided by this package.
     */
    'check_model' => Spatie\ServerMonitor\Models\Check::class,

    /*
     * Right before running a check it's process will be given to this class. Here you
     * can perform some last minute manipulations on it before it will
     * actually be run.
     *
     * This class should implement Spatie\ServerMonitor\Manipulators\Manipulator
     */
    'process_manipulator' => Spatie\ServerMonitor\Manipulators\Passthrough::class,
];

基本用法

要开始监控服务器

php artisan server-monitor:add-host

并回答提出的问题。

要停止监控URL,发出以下命令

php artisan server-monitor:delete-host <name>

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

php artisan server-monitor:list-hosts

您还可以列出所有主机上的所有活动检查

php artisan server-monitor:list-checks

最后,如果您有大量需要监控的服务器,您可以从JSON文件导入它们

php artisan server-monitor:sync-file <hosts.json>

高级用法

在底层,server-monitor-app是一个纯Laravel 5.4应用程序,其中安装了我们的laravel-server-monitor。请参考其详细的文档以了解更多关于如何配置和使用此应用程序的信息。

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

文档

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

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

明信片软件

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

我们的地址是:Spatie,Kruikstraat 22,2018 安特卫普,比利时。

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

更新日志

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

贡献

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

安全性

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

鸣谢

关于Spatie

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

许可证

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