##Basic installation
This package should be installed in an existing Laravel application. If you're not familiar with Laravel head over to the official documentation to learn how to set up and use this amazing framework.
From the directory of an existing Laravel application you can install the package via composer:
composer require spatie/laravel-server-monitor:^1.0
You'll need to register the service provider:
'providers' => [
Spatie\ServerMonitor\ServerMonitorServiceProvider::class,
];
You can publish the migrations with:
php artisan vendor:publish --provider="Spatie\ServerMonitor\ServerMonitorServiceProvider" --tag="migrations"
After the migration has been published you can create the hosts
and checks
tables by running the migrations:
php artisan migrate
To publish the config file to config/server-monitor.php
run:
php artisan vendor:publish --provider="Spatie\ServerMonitor\ServerMonitorServiceProvider" --tag="config"
By default, the configuration looks like this:
return [
'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,
],
'next_run_in_minutes' => env('SERVER_MONITOR_NEXT_RUN_IN_MINUTES', 10),
'concurrent_ssh_connections' => 5,
'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'],
],
'throttle_failing_notifications_for_minutes' => 60,
'mail' => [
'to' => 'your@email.com',
],
'slack' => [
'webhook_url' => env('SERVER_MONITOR_SLACK_WEBHOOK_URL'),
],
'notifiable' => \Spatie\ServerMonitor\Notifications\Notifiable::class,
'date_format' => 'd/m/Y',
],
'check_model' => Spatie\ServerMonitor\Models\Check::class,
'process_manipulator' => Spatie\ServerMonitor\Manipulators\Passthrough::class,
];
##Scheduling
After performing the basic installation schedule the server-monitor:run-checks
command to run every minute.
protected function schedule(Schedule $schedule)
{
$schedule->command('server-monitor:run-checks')->withoutOverlapping()->everyMinute();
}