, (*1)
A PHP application to monitor your servers' health
, (*2)
We all dream of servers that need no maintenance at all. But unfortunately in reality this is not the case. Disks can get full, processes can crash, the server can run out of memory..., (*3)
This commandline app keeps an eye on the health of all your servers. There are a few checks that come out of the box., (*4)
When something goes wrong it can notify you via Slack or mail. This is what a Slack notification looks like:, (*5)
, (*6)
Under the hood the server-monitor-app is a vanilla Laravel 5.4 application with the laravel-server-monitor installed into it. If you know your way around Laravel, it's recommended that you use laravel-server-monitor instead of this app., (*7)
Support us
, (*8)
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products., (*9)
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall., (*10)
Requirements
See the requirements in the docs of the underlying package., (*11)
Installation
You can install the application by issuing this command:, (*12)
composer create-project spatie/server-monitor-app <name of install directory>
To complete your installation these steps must be performed:, (*13)
First you should add the following command to your cron table. It should run
every minute:, (*14)
php <installation path>/artisan schedule:run
Secondly, specify a Slack webhook url in the SERVER_MONITOR_SLACK_WEBHOOK_URL
key
in the .env
file found in the installation directory.
You can create a new webhook url on the Slack website., (*15)
Optionally you can configure e-mail notifications by filling in the MAIL_
keys in the .env
file located in the
installation directory and adding mail
to the notifications
array in the configuration.php
file., (*16)
Configuration
The configuration file configuration.php
is located inside the installation directory., (*17)
Reading it is a good way to quickly get a feel of what server-monitor-app
can do. Here's the content of the config file:, (*18)
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 it's 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,
];
Basic usage
To start monitoring a server:, (*19)
php artisan server-monitor:add-host
and answer the questions that are asked.`, (*20)
To stop monitoring an url issue this command:, (*21)
php artisan server-monitor:delete-host <name>
To list all monitors you can perform:, (*22)
php artisan server-monitor:list-hosts
You can also list all active checks on all hosts:, (*23)
php artisan server-monitor:list-checks
Finally, if you've got a large amount of servers to monitor you can import them from a JSON file:, (*24)
php artisan server-monitor:sync-file <hosts.json>
Advanced usage
Under the hood the server-monitor-app
is a vanilla Laravel 5.4 application with our laravel-server-monitor installed into it. Please refer to it's extensive documentation to know more how to configure and use this application., (*25)
By default the application will use a sqlite
database located at <installation directory>/database.sqlite
to store all monitors., (*26)
Documentation
You'll find the documentation of the underlying laravel-server-monitor
package on https://docs.spatie.be/laravel-server-monitor/v1., (*27)
Find yourself stuck using this app or the underlying package? Found a bug? Do you have general questions or suggestions for improving the uptime monitor? Feel free to create an issue on GitHub, we'll try to address it as soon as possible., (*28)
Postcardware
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using., (*29)
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium., (*30)
The best postcards will get published on the open source page on our website., (*31)
Changelog
Please see CHANGELOG for more information what has changed recently., (*32)
Contributing
Please see CONTRIBUTING for details., (*33)
Security
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker., (*34)
Credits
About Spatie
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website., (*35)
License
The MIT License (MIT). Please see License File for more information., (*36)