thecodingmachine / laravel-server-monitor-plugin-notification-by-host
用于通过主机发送通知的服务器监控插件
0.2
2017-12-27 06:28 UTC
Requires
Requires (Dev)
- mockery/mockery: ^0.9.8
- orchestra/testbench: ^3.4.5
- phpunit/phpunit: ^5.7
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-09-06 23:57:06 UTC
README
Laravel服务器监控插件
此插件旨在使用不同的通知方式,通过主机为spatie开发的Laravel服务器监控。
安装
您可以使用以下命令通过composer安装此包
composer require spatie/laravel-server-monitor
接下来,您必须安装服务提供者
// config/app.php 'providers' => [ ... TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider::class, ];
您必须使用以下命令发布配置文件
php artisan vendor:publish --provider="TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ 'notifications' => [ /* List of each channel you can be used */ /* This contain the detail of parameter mandatory to use it */ 'channels' => ['mail' => ['to' => 'array']], ['slack' => ['webhook_url' => 'string']], ] ];
要使用此插件,您必须将server-monitor.php修改为以下值
... 'notifications' => [ 'notifications' => [ TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckSucceeded::class => [], TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckRestored::class => ['slack'], TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckWarning::class => ['slack'], TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckFailed::class => ['slack'], ], ... 'notifiable' => TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifiable::class, ... ] ...
使用方法
默认情况下,如果没有配置自定义配置,这将是在server-monitor.php中设置的全球参数,将被使用。您可以通过主机(邮件接收者、Slack频道等)更改配置,并通过主机按错误类型更改频道。
为此,已向Artisan添加了2个新命令
- 为特定主机添加通知:php artisan server-monitor:add-notification-host
- 列出所有主机通知:php artisan server-monitor:list-notifications