johnnguyen/server-monitor

监控服务器

v1.0.1 2020-07-05 01:50 UTC

This package is auto-updated.

Last update: 2024-09-05 11:37:38 UTC


README

Latest Version on Packagist Build Status SensioLabsInsight Quality Score StyleCI Total Downloads

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

此包会监视所有服务器的健康状态。有一些开箱即用的检查,可以轻松添加新检查

当出现问题通知你,可以通过Slack或邮件。以下是一个Slack通知的示例

在幕后,利用Laravel的本地通知系统,你可以使用许多通知驱动程序之一。

文档

完整文档可在我们的文档网站上找到

Postcardware

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

我们的地址是:Spatie,Samberstraat 69D,2060 Antwerp,比利时。

所有收到的明信片都将在我们的网站上发布

安装

您可以通过composer使用以下命令安装此包

composer require spatie/laravel-server-monitor

接下来,您必须安装服务提供者

// config/app.php
'providers' => [
    ...
    JohnNguyen\ServerMonitor\ServerMonitorServiceProvider::class,
];

您可以使用以下命令发布迁移

php artisan vendor:publish --provider="JohnNguyen\ServerMonitor\ServerMonitorServiceProvider" --tag="migrations"

迁移发布后,您可以通过运行迁移来创建hostschecks

php artisan migrate

您必须使用以下命令发布配置文件

php artisan vendor:publish --provider="JohnNguyen\ServerMonitor\ServerMonitorServiceProvider" --tag="config"

这是已发布配置文件的内容

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
     * `JohnNguyen\ServerMonitor\Checks\CheckDefinitions\CheckDefinition` class.
     */
    'checks' => [
        'diskspace' => JohnNguyen\ServerMonitor\CheckDefinitions\Diskspace::class,
        'elasticsearch' => JohnNguyen\ServerMonitor\CheckDefinitions\Elasticsearch::class,
        'memcached' => JohnNguyen\ServerMonitor\CheckDefinitions\Memcached::class,
        'mysql' => JohnNguyen\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' => [
            JohnNguyen\ServerMonitor\Notifications\Notifications\CheckSucceeded::class => [],
            JohnNguyen\ServerMonitor\Notifications\Notifications\CheckRestored::class => ['slack'],
            JohnNguyen\ServerMonitor\Notifications\Notifications\CheckWarning::class => ['slack'],
            JohnNguyen\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' => \JohnNguyen\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' => JohnNguyen\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 JohnNguyen\ServerMonitor\Manipulators\Manipulator
     */
    'process_manipulator' => JohnNguyen\ServerMonitor\Manipulators\Passthrough::class,
];

变更日志

有关最近更改的更多信息,请参阅变更日志

测试

要运行测试,您必须首先在一个单独的终端窗口中启动包含的基于node的虚拟ssh服务器。

cd tests/server
npm install
./start_server.sh

服务器运行后,您可以开始测试。

vendor/bin/phpunit

贡献

有关详细信息,请参阅贡献

安全

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

鸣谢

在远程服务器上执行命令的代码是从Envoy中复制的。

关于Spatie

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

许可证

麻省理工学院许可证(MIT)。更多信息请参阅许可证文件