Health Monitor

Laravel Health Panel
Under BSD 3-Clause "New" or "Revised" License
By antonioribeiro

php hacktoberfest server health laravel notifications monitor panel health-panel

Health Monitor
Laravel Server & App Health Monitor and Notifier

This package checks if the application resources are running as they should and creates a service status panel. It has the following main points:

Built-in Resources

Heath has pre-configured resource checkers for the following services:

But you can add anything else you need, you just have to find the right checker to use or just create a new checker for your resource.

Easy Configuration

Creating new resources monitors is easy, just create a new YAML file in app's config/health folder and it's done. Here's some examples:

Amazon S3
name: S3
abbreviation: s3
checker: PragmaRX\Health\Checkers\CloudStorageChecker
notify: true
driver: s3
file: pragmarx-health-s3-testfile.txt
contents: {{ str_random(32) }}
error_message: 'Amazon S3 connection is failing.'
column_size: 4

name: NginxServer
abbreviation: ngnxsrvr
checker: PragmaRX\Health\Checkers\ProcessChecker
command: 'pgrep %s'
method: process_count
process_name: nginx
count: 4
message: 'Process "%s" has not enough instances running: it has %s, when should have at least %s'
count: 8
message: 'Process "%s" exceeded the maximum number of running instances: it has %s, when should have at most %s'
notify: true
pid_file_missing_error_message: 'Process ID file is missing: %s.'
pid_file_missing_not_locked: 'Process ID file is not being used by any process: %s.'
column_size: 4


Panel alternate design

If you have lots of services to check, you may change the default panel design to use less space:

Panel in 4 columns layout

Error Messages

Mouse over a failing resource and get instant access to the error message:

Click the resource button and you'll get an alert showing the error message:

Slack Notification

Here's an example of notification sent via Slack:

Artisan Console Commands

Use the command health:panel to view the status of your services in console.


Use the command health:check to check all your resources and send notifications on failures.


After installing you will have access to the following routes:


The main panel route.


Returns a json with everything the package knows about your services:


Returns a string with status on all your services, useful when using other monitoring services:



Returns a json with information about a particular service:



Use Composer to install it:

composer require pragmarx/health

Installing on Laravel

Add the Service Provider to your config/app.php:


Publish config and views
php artisan vendor:publish --provider="PragmaRX\Health\ServiceProvider"

Hit The Health Panel

Configure All The Things

Almost everything is easily configurable in this package:

Configure binaries

Some of the checkers need you to configure the proper binary path for the checker to work:

'services' => [
'ping' => [
'bin' => env('HEALTH_PING_BIN', '/sbin/ping'),

'composer' => [
'bin' => env('HEALTH_COMPOSER_BIN', 'composer'),

Allowing Slack Notifications

To receive notifications via Slack, you'll have to setup Incoming Webhooks and add this method to your User model with your webhook:

* Route notifications for the Slack channel.
* @return string
public function routeNotificationForSlack()
return config('services.slack.webhook_url');


When Health result is cached, you can flush the cache to make it process all resources again by adding ?flush=true to the url:


If you prefer to build you own notifications systems, you can disable it and listen for the following event


Broadcasting Checker

Broadcasting checker is done via ping and pong system. The broadcast checker will ping your service, and it must pong back. Basically what you need to do is to call back a url with some data:

Redis +
var request = require('request');
var server = require('http').Server();
var io = require('')(server);
var Redis = require('ioredis');
var redis = new Redis();


redis.on('message', function (channel, message) {
message = JSON.parse(message);

if (message.event == 'PragmaRX\\Health\\Events\\HealthPing') {
request.get( + '?data=' + JSON.stringify(;


<!DOCTYPE html>
<title>Pusher Test</title>
<script src=""></script>
var pusher = new Pusher('YOUR-PUSHER-KEY', {
encrypted: true

var channel = pusher.subscribe('pragmarx-health-broadcasting-channel');

channel.bind('PragmaRX\\Health\\Events\\HealthPing', function(data) {
var request = (new XMLHttpRequest());"GET", data.callbackUrl + '?data=' + JSON.stringify(data));


Pusher waiting for events...

Programatically checking resources

``` php
$generalHealthState = app('')->checkResources();

// or

$databaseHealthy = app('')->checkResource('database')->isHealthy();

Checking in artisan commands example:

Artisan::command('database:health', function () {
? $this->info('database is healthy')
: $this->info('database is in trouble')
})->describe('Check database health');


To use it on Lumen, you'll probably need to do something like this on your bootstrap/app.php:

$app->instance('path.config', app()->basePath() . DIRECTORY_SEPARATOR . 'config');
$app->instance('', app()->basePath() . DIRECTORY_SEPARATOR . 'storage');


$app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app) {
return new \Illuminate\Routing\ResponseFactory(



$ composer test


Antonio Carlos Ribeiro


Health is licensed under the BSD 3-Clause License - see the LICENSE file for details


Pull requests and issues are more than welcome.