, (*1)
Plugin to Laravel server Monitor
This plugin is to use a different notification way by host for the Laravel server monitor developed by spatie, (*2)
Installation
You can install this package via composer using this command:, (*3)
composer require spatie/laravel-server-monitor
Next, you must install the service provider:, (*4)
// config/app.php
'providers' => [
...
TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider::class,
];
You must publish the config-file with:, (*5)
php artisan vendor:publish --provider="TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider" --tag="config"
This is the contents of the published config file:, (*6)
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']],
]
];
To use the plugin, you must change the server-monitor.php with the next values:, (*7)
...
'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,
...
]
...
Use it
By default, if no custom configuration was configured, this is the global parameters set in server-monitor.php which will used.
You can change the configuration by host (mail receiver, slack channel ...), and the channel by error type by host., (*8)
To apply this, there is 2 new commands add to artisan:
- Add notification for a specific host: php artisan server-monitor:add-notification-host
- List all notification by host: php artisan server-monitor:list-notifications, (*9)