thecodingmachine/laravel-server-monitor-plugin-notification-by-host

Monitor servers plugin to send notification by host

0.2 2017-12-27 06:28 UTC

This package is auto-updated.

Last update: 2024-12-07 00:34:04 UTC


README

Scrutinizer Code Quality Build Status Coverage Status

Plugin to Laravel server Monitor

This plugin is to use a different notification way by host for the Laravel server monitor developed by spatie

Installation

You can install this package via composer using this command:

composer require spatie/laravel-server-monitor

Next, you must install the service provider:

// config/app.php
'providers' => [
    ...
    TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider::class,
];

You must publish the config-file with:

php artisan vendor:publish --provider="TheCodingMachine\ServerMonitorPluginNotificationbyHost\ServerMonitorPluginNotificationByHostServiceProvider" --tag="config"

This is the contents of the published config file:

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:

    ...

    '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.

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