spatie / laravel-server-monitor
监控服务器
Requires
- php: ^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- laravel/framework: ^10.0|^11.0
- spatie/laravel-blink: ^1.3
- spatie/regex: ^3.1
- symfony/process: ^6.0|^7.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.34
This package is auto-updated.
Last update: 2024-09-08 16:25:42 UTC
README
我们都梦想着不需要维护的服务器。但遗憾的是,在现实中并非如此。磁盘可能会满载,进程可能会崩溃,服务器可能会耗尽内存...
此包可以监控所有服务器的健康状态。有几个内置检查。添加新的检查非常简单。
当出现问题时,它可以通过 Slack 或邮件通知您。
支持我们
我们投入了大量资源来创建一流的开放源代码包。您可以通过购买我们的付费产品之一来支持我们。
我们非常感谢您从家乡寄来明信片,注明您正在使用我们哪些包。您可以在我们的联系页面上找到我们的地址。我们将所有收到的明信片发布在我们的虚拟明信片墙上。
文档
完整的文档可在我们的文档网站上找到。
安装
您可以通过使用此命令通过 composer 安装此包
composer require spatie/laravel-server-monitor
在 Laravel 5.5 中,服务提供程序将自动注册。在框架的旧版本中,您必须安装服务提供程序
// config/app.php 'providers' => [ ... Spatie\ServerMonitor\ServerMonitorServiceProvider::class, ];
您可以使用以下命令发布迁移
php artisan vendor:publish --provider="Spatie\ServerMonitor\ServerMonitorServiceProvider" --tag="migrations"
发布迁移后,您可以通过运行迁移来创建 hosts
和 checks
表
php artisan migrate
您必须使用以下命令发布配置文件
php artisan vendor:publish --provider="Spatie\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 * `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 its 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, /* * Thresholds for disk space's alert. */ 'diskspace_percentage_threshold' => [ 'warning' => 80, 'fail' => 90, ], ];
需要 UI 吗?
此包没有自带任何屏幕。您可以使用 @paras-malhotra 的 Nova 包 在 Laravel Nova 上监控服务器。
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
要运行测试,您必须首先在另一个终端窗口中启动包含的基于 node 的模拟 ssh 服务器。
cd tests/server
npm install
./start_server.sh
服务器运行后,您可以开始测试。
vendor/bin/phpunit
贡献
请参阅CONTRIBUTING 以获取详细信息。
安全性
如果您发现了关于安全性的错误,请通过security@spatie.be 发送邮件,而不是使用问题跟踪器。
致谢
在远程服务器上执行命令的代码是从Envoy复制的。
许可
麻省理工学院许可(MIT)。更多信息请参阅许可文件。