Code Monkey home page Code Monkey logo

health's Introduction

Health Monitor

Laravel Server & App Health Monitor and Notifier

Latest Stable Version License Code Quality

Build Downloads Coverage PHP

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

  • Highly extensible and configurable: you can create new checkers and notifiers very easily, and you can virtually change everything on it.
  • Easy configuration: uses YAML as configuration files
  • Resilient resource checker: if the framework is working and at least one notification channel, you should receive notification messages.
  • Built-in notification system: get notifications via mail, slack, telegram or anything else you need.
  • Routes for: panel, json result, string result and resource.
  • Configurable panel design.
  • Cache.
  • Schedule checks to automatically receive notifications when a service fails.
  • View app error messages right in the panel.
  • Http response codes 200 and 500, on error, for services like Envoyer to keep track of your app health.

Built-in Resources

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

  • Adyen
  • AppKey
  • APIs
  • Broadcasting
  • Cache
  • ConfigurationCached
  • Certificate
  • Checkout.com
  • Database
  • DebugMode
  • DirectoryPermissions
  • DiskSpace
  • DocuSign
  • ElasticsearchConnectable
  • EnvExists
  • Filesystem
  • Framework
  • HealthPanel
  • Horizon
  • Http
  • Https
  • LaravelServices
  • Latency
  • LocalStorage
  • Mail
  • MailgunConnectable
  • MemcachedConnectable
  • MigrationsUpToDate
  • MixManifest
  • MySql
  • MySqlConnectable
  • NewrelicDeamon
  • NginxServer
  • PackagesUpToDate
  • Php
  • PostgreSqlConnectable
  • PostgreSqlServer
  • Queue
  • QueueWorkers
  • RebootRequired
  • Redis
  • RedisConnectable
  • RedisServer
  • RoutesCached
  • S3
  • SecurityChecker
  • SeeTickets
  • Sendinblue
  • ServerLoad
  • ServerVars
  • ServerUptime
  • Sshd
  • Supervisor

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.

Panel of Panels

If you have a lot of websites to check, you can use the HealthPanel checker to create a Health Monitor application to check all your remote monitors and create a dashboard to summarize the state of all your websites.

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

Nginx

name: NginxServer
abbreviation: ngnxsrvr
checker: PragmaRX\Health\Checkers\ProcessChecker
command: 'pgrep %s'
method: process_count
process_name: nginx
instances:
    minimum:
        count: 4
        message: 'Process "%s" has not enough instances running: it has %s, when should have at least %s'
    maximum:
        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

Screenshots

Panel

default panel

Panel alternate design

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

default panel

Panel in 4 columns layout

default panel

Error Messages

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

default panel

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

default panel

Slack Notification

Here's an example of notification sent via Slack:

default panel

Artisan Console Commands

The health check commands below also return an exit code in a standard format:

Numeric Value Service Status Status Description
0 OK Service and appears to be functioning properly
1 Warning Check ran okay, but was above some "warning" threshold
2 Critical The check detected service is not running or is above a "critical" threshold
3 Unknown Settings for the service check may be misconfigured and is preventing the check for being performed

health:panel

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

health:check

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

default panel

Routes

After installing you will have access to the following routes:

/health/panel

The main panel route.

/health/check

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

default panel

/health/string

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

hlthFAIL-dbFAIL-filesystemOK-frmwrkOK-httpOK-httpsOK-mailOK

/health/resource/{name}

Returns a json with information about a particular service:

default panel

Requirements

  • PHP 7.3+
  • Laravel 8.0+

Installing

Use Composer to install it:

composer require pragmarx/health

Installing on Laravel

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

PragmaRX\Health\ServiceProvider::class,

Publish config and views

php artisan vendor:publish --provider="PragmaRX\Health\ServiceProvider"

Hit The Health Panel

http://yourdomain.com/health/panel

Configure All The Things

Almost everything is easily configurable in this package:

  • Panel name
  • Title and messages
  • Resource checkers
  • Slack icon
  • Notification channels
  • Template location
  • Routes and prefixes
  • Mail server
  • Cache
  • Scheduler

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');
}

Cache

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

http://yourdomain.com/health/panel?flush=true

Events

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

PragmaRX\Health\Events\RaiseHealthIssue::class

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 + Socket.io

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

redis.subscribe('pragmarx-health-broadcasting-channel');

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

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

server.listen(3000);

Pusher

<!DOCTYPE html>
<html>
    <head>
        <title>Pusher Test</title>
        <script src="https://js.pusher.com/3.2/pusher.min.js"></script>
        <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());

                request.open("GET", data.callbackUrl + '?data=' + JSON.stringify(data));

                request.send();
            });
        </script>
    </head>

    <body>
        Pusher waiting for events...
    </body>
</html>

Programatically checking resources

$generalHealthState = app('pragmarx.health')->checkResources();

// or

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

Checking in artisan commands example:

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

SecurityChecker

As the SensioLabs Security Checker package was abandoned, this checker now depends on local-php-security-checker. You need to compile or install it on your server or container in order to use this checker, and update the config/resources/SecurityChecker.yml file accordingly.

Lumen

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('path.storage', app()->basePath() . DIRECTORY_SEPARATOR . 'storage');

$app->withFacades();

$app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app) {
    return new \Illuminate\Routing\ResponseFactory(
        $app['Illuminate\Contracts\View\Factory'],
        $app['Illuminate\Routing\Redirector']
    );
});

$app->register(PragmaRX\Health\ServiceProvider::class);

Testing

$ composer test

Author

Antonio Carlos Ribeiro

License

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

Contributing

Pull requests and issues are more than welcome.

health's People

Contributors

0xflotus avatar antonioribeiro avatar assada avatar caiquebb avatar dennie170 avatar dependabot-preview[bot] avatar erictendian avatar grahamcampbell avatar hilgroth avatar igorbabko avatar igusev avatar keevan avatar khoubeib-soci avatar krns avatar limonte avatar madisn avatar marktopper avatar mnv avatar nadafarouk avatar nope7777 avatar omranic avatar qschmick avatar rap2hpoutre avatar rthomas023 avatar samnela avatar stylecibot avatar telalpal avatar vvanpo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

health's Issues

Redis check failing from code issues

Currently, for Redis check, I get:
Non-static method Redis::set() cannot be called statically

My environment:

  • Laravel v5.4.36
  • PHP 7.1.6

For my environment, the fix is actually quite simple. Based on documentation from https://laravel.com/docs/5.4/redis#interacting-with-redis the fix is just a proper "use" namespace.

Basically, from:

namespace PragmaRX\Health\Checkers;

use Redis;

class RedisChecker extends BaseChecker
{ // rest of the code

I would change to:

<?php
namespace PragmaRX\Health\Checkers;

use Illuminate\Support\Facades\Redis;

class RedisChecker extends BaseChecker
{ // rest of the code

If it's ok, I will submit a pull-request, but, at first, please confirm that the issue can be reproduced in other environments.

Do not recognize config values.

Hi,

I'm using laravel 5.6 here the /check seems not to recognize my config values as if it would be ignoring the .env file and using the default values. Any idea why?

Checking queue worker

Hi,

Thank you for sharing this most useful package.

Please advise how to setup checking that the queue worker is alive and ready to accept jobs.

Many thanks.

Get health information in code

Hi,

is there a way to get the health information in code directly? If i want to show some checks in my application itself without using the panel it would be nice to have a function like "Health::getChecks()" to get informations about the health status.

Cant install in laravel 5.5

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: phpunit/php-timer[2.0.0, 1.0.9].
- Can only install one of: phpunit/php-timer[2.0.0, 1.0.9].
- Can only install one of: phpunit/php-timer[2.0.0, 1.0.9].
- pragmarx/health v0.9.9 requires phpunit/php-timer ^2.0 -> satisfiable by phpunit/php-timer[2.0.0].
- Installation request for pragmarx/health ^0.9.9 -> satisfiable by pragmarx/health[v0.9.9].
- Installation request for phpunit/php-timer (locked at 1.0.9) -> satisfiable by phpunit/php-timer[1.0.9].

[Question] Health Check Panel on cluster

Hi there, here is my use case:
we have two servers which runs the same version of our application, requests are catched by a CDN and, if they pass through, a load balancer decide into which server redirect it.
From what I read from the README, this package seems suited to manage a single app instance and cannot monitor multiple instances in a cluster of servers.
Am I correct? Do you think it can be doable and interesting to develop this feature some time in the future?

resources_enabled list

In the resources_enabled config key (config/health.php file), the comment says:

use an array to select some

I don't know where is the list of available values.

Check for existence of a debug_blacklist

This is mix between a feature request and a question. I know that we are not supposed to allow debug mode in production, but even if that happens by accident it would be nice to have a default check to make sure that a debug_blacklist exists, which would mean thought about hiding sensitive keys, instead of just leaving the Laravel default as it is.

If someone has an idea of how could I check that, I can add a pull request. Would be better to just try to read the config file? Or generate an exception and try get information (like keys) from the whoops page? Any suggestions are welcome. Or if you think that this doesn't make sense also.

Scheduler: config values attempt and Cache error.

Hi guys.

Nice intentions here, what really took my attention was the scheduler options so we can monitor apps on production. But for this I found a few bugs:

  1. on your ServiceProvider you're asking for:

if ( config('health.scheduler.enabled') && ($frequency = config('health.scheduler.frequency')) && config('health.notifications.enabled') )

but on the published config file "schedule" is within "health.notifications" so your validations should be "health.notifications.scheduler..." instead.

Anyways after I change this to test it and finally put it to work. I started receiving a " Class cache does not exist" error related with a different function. I don't have the time to keep digging here maybe if you find out the isue I'll be back to using it or maybe if I find a few hours on my week I can give you a hand with it.

Thanks in advance.

Needs less invasive method to check queues with custom properties (e.g. long-polling)

Given the case:

  1. SQS queue with long-polling (just a little-modified default driver with additional parameter)
  2. This checker slows down its own execution because it needs to write and extract job which is not the desired behaviour, which in long polling have some worst ranges for this idea.
  3. Also, I get Return-Path: <[email protected]> in my debug log.

At all, pushing and pulling an actual job to and from the queue is not a good solution because of its invasive behaviour.
Maybe a good solution is to use underlined drivers to check the ability to write and read queue, not performing actual actions.

ServerLoad Undefined index: load_1

Laravel: 5.7
PHP: 7.2
Config ServerLoad.yml: Default

I'm getting this error in the check server load, what can it be? I am using the default setting, no changes

Thanks

MailChecker fails

Argument 2 passed to Illuminate\Mail\MailServiceProvider::setGlobalAddress() must be of the type array, object given, called in vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php on line 58

It happens that sometimes the mail configuration is by this package read as a collection instead of an array.

I can't replicate it without this package.

Argument 1 passed to PragmaRX\Health\Support\ResourceChecker::PragmaRX\Health\Support\{closure}() must be an instance of PragmaRX\Health\Support\Resource, boolean given

This is a know problem or a genuine error? That’s a pretty vanilla Laravel 5.7 install.

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Argument 1 passed to PragmaRX\Health\Support\ResourceChecker::PragmaRX\Health\Support{closure}() must be an instance of PragmaRX\Health\Support\Resource, boolean given

on vendor/pragmarx/health/src/Support/ResourceChecker.php:185

/health/panel works ok, I’ve got that error on /health/check.

Livereload ERR_CONNECTION_REFUSED

Where does it "livereload.js" come from? There is no reference on source code.

Is there any additional instruction to solve this problem?

NOTE: Laravel Health package was installed on project running with docker.

captura de tela 2018-10-03 as 00 13 03

Health status fails when Cache (Redis) is down

This will return 500, so your Envoyer health checks / etc will pick it up -- however I think it could be handled more gracefully. It also stops the email notices from going out because the console checks fail before generating an email. Slack is also probably stopped, though I didn't test this.

Perhaps if a connection to the cache cannot be made, the cache layer should be ignored and health checks should go directly to the service they check and not write their response to the cache.

Thoughts?

Queue check leaves pile of jobs in queue

First of all, I love this library, saved me a ton of effort. I am using the Queue checker to ensure that my app is configured correctly to talk to Beanstalk.

I noticed that now that it's been running, there is a new Queue called "Queue" that has 19k jobs sitting ready. What is the recommended way to handle this, should I set up a worker to clean these out, or just ignore it?

[Feature Request] application/health+json format

I am not sure if this is within the scope of this project but there is a proposed standard for health data.

More detailed information can be found at:
https://inadarei.github.io/rfc-healthcheck/

Example response format:

  GET /health HTTP/1.1
  Host: example.org
  Accept: application/health+json

  HTTP/1.1 200 OK
  Content-Type: application/health+json
  Cache-Control: max-age=3600
  Connection: close

{
  "status": "pass",
  "version": "1",
  "releaseID": "1.2.2",
  "notes": [""],
  "output": "",
  "serviceID": "f03e522f-1f44-4062-9b55-9587f91c9c41",
  "description": "health of authz service",
  "details": {
    "cassandra:responseTime": [
      {
        "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2",
        "componentType": "datastore",
        "metricValue": 250,
        "metricUnit": "ms",
        "status": "pass",
        "time": "2018-01-17T03:36:48Z",
        "output": ""
      }
    ],
    "cassandra:connections": [
      {
        "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2",
        "type": "datastore",
        "metricValue": 75,
        "status": "warn",
        "time": "2018-01-17T03:36:48Z",
        "output": "",
        "links": {
          "self": "http://api.example.com/dbnode/dfd6cf2b/health"
        }
      }
    ],
    "uptime": [
      {
        "componentType": "system",
        "metricValue": 1209600.245,
        "metricUnit": "s",
        "status": "pass",
        "time": "2018-01-17T03:36:48Z"
      }
    ],
    "cpu:utilization": [
      {
        "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227",
        "node": 1,
        "componentType": "system",
        "metricValue": 85,
        "metricUnit": "percent",
        "status": "warn",
        "time": "2018-01-17T03:36:48Z",
        "output": ""
      },
      {
        "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227",
        "node": 2,
        "componentType": "system",
        "metricValue": 85,
        "metricUnit": "percent",
        "status": "warn",
        "time": "2018-01-17T03:36:48Z",
        "output": ""
      }
    ],
    "memory:utilization": [
      {
        "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227",
        "node": 1,
        "componentType": "system",
        "metricValue": 8.5,
        "metricUnit": "GiB",
        "status": "warn",
        "time": "2018-01-17T03:36:48Z",
        "output": ""
      },
      {
        "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227",
        "node": 2,
        "componentType": "system",
        "metricValue": 5500,
        "metricUnit": "MiB",
        "status": "pass",
        "time": "2018-01-17T03:36:48Z",
        "output": ""
      }
    ]
  },
  "links": {
    "about": "http://api.example.com/about/authz",
    "http://api.x.io/rel/thresholds":
      "http://api.x.io/about/authz/thresholds"
  }
}

Broadcast check failing

Hello,
I have tested this package with a fresh new installation of laravel 5.7 to make sure there was no interference from any other package. I also used the "dev-master" version to see if the problem had been resolved.
The javascript gets a 404 not found when it sends the pong message, I listed all routes and could not find the callback route !
I have no idea why the callback route is not being registered :(
This is what the js script outputs :

Started Server ...
Message pragmarx-health-broadcasting-channel Received ...
ponging...
pong To Url : http://homestead.test/health/broadcasting/callback/6d3y1UH8Xv3L5Lyi7UnW6JQkRRwyB6Pv
error: null
statusCode: 404

and this is the route:list :
vagrant@homestead:~/code/laravel-5-boilerplate$ php artisan route:list | grep health

| | GET|HEAD | health/assets/css/app.css | pragmarx.health.assets.css | PragmaRX\Health\Http\Controllers\Health@assetAppCss | web |
| | GET|HEAD | health/assets/js/app.js | pragmarx.health.assets.js | PragmaRX\Health\Http\Controllers\Health@assetAppJs | web |
| | GET|HEAD | health/check | pragmarx.health.check | PragmaRX\Health\Http\Controllers\Health@check | web |
| | GET|HEAD | health/config | pragmarx.health.config | PragmaRX\Health\Http\Controllers\Health@config | web |
| | GET|HEAD | health/panel | pragmarx.health.panel | PragmaRX\Health\Http\Controllers\Health@panel | web |
| | GET|HEAD | health/resources | pragmarx.health.resources.all | PragmaRX\Health\Http\Controllers\Health@allResources | web |
| | GET|HEAD | health/resources/{slug} | pragmarx.health.resources.get | PragmaRX\Health\Http\Controllers\Health@getResource | web |
| | GET|HEAD | health/string | pragmarx.health.string | PragmaRX\Health\Http\Controllers\Health@string

Thanks for looking into it !
Salh

installation documentation

Hi, I have no clue about Laravel. I would be nice to have a section in the documentation with step-by-step commands we need to run in order to deploy this project on a server.

Even more awesome, if someone knowing how to deploy this project could come up with a Dockerfile it would help a lot.

Can't use domain.com/health/panel, Undefined variable: health

PHP version: 7.2.11
Laravel version: 5.7.*

I receive the following error when attempting to access /health/panel:

Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Undefined variable: health (View: /mnt/c/Users/{removed}/Desktop/dev/laravel/resources/views/vendor/pragmarx/health/default/panel.blade.php)

This is the controller code that's failing

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @throws \Exception
     */
    public function panel()
    {
        $this->healthService->setAction('panel');

        return response((string) view(config('health.views.panel'))->with('laravel', ['health' => config('health')]));
    }

This is the view code that fails in panel.blade.php

                    @foreach($health as $item)
                        @include(
                            config('health.views.partials.well'),
                            [
                                'itemName' => $item['name'],
                                'itemHealth' => $item['health']['healthy'],
                                'itemMessage' => $item['health']['message'],
                                'columnSize' => $item['columnSize'] ?: $item['column_size']
                            ]
                        )
                    @endforeach

When I dd(config('health')); it returns the expected json object, but for some reason $health is undefined.

problem with installing

I followed the steps starting here to install via composer (v0.3.1). I added the ServiceProvider to config/app.php and called php artisan vendor:publish. I cannot find the Facade to add this to config/app.php (I'm using Laravel 5.3). Where does it live?

I manually created the config/health directory - it wasn't already created - and added a simple test config in config/health/nginx.yml (using the example you provided). When I hit the /health/panel route, it's not there. Artisan doesn't have the health commands either.

Documentation - add notice to check the location of binaries

In the .yml files you have

name: Latency
.
.
.
binary: /sbin/ping
.
.
.

Depending upon you os flavour, it may not be in that folder:

health.test$ which ping
/bin/ping

So if you could make a note telling people to check that, it would probably save some of the "Its not working" issues!

JSON output too verbose

I've noticed when using the endpoint for JSON output that it includes all the config information for that health panel as well as the result. This isn't shown in the documentation though. Have I therefore missed a bit of configuration which minimises the amount of data returned?

What I'm expecting to see: https://github.com/antonioribeiro/health/blob/master/docs/images/json.png

What I actually see:

{
	"AppKey": {
		"id": "0b515870-3c13-4c78-8f6c-728a5fbc1952",
		"name": "App Key",
		"slug": "app-key",
		"abbreviation": "appkey",
		"isGlobal": false,
		"errorMessage": "There is no app key defined",
		"style": {
			"columnSize": 3,
			"buttonLines": "multi",
			"multiplier": 0.4,
			"opacity": {
				"healthy": "0.4",
				"failing": "1"
			}
		},
		"notify": true,
		"targets": [{
			"id": "acb69856-4952-4ff6-ac8c-f840180b5da7",
			"name": "default",
			"display": "default",
			"resource": {
				"id": "0b515870-3c13-4c78-8f6c-728a5fbc1952",
				"name": "App Key",
				"slug": "app-key",
				"abbreviation": "appkey",
				"isGlobal": false,
				"errorMessage": "There is no app key defined",
				"style": {
					"columnSize": 3,
					"buttonLines": "multi",
					"multiplier": 0.4,
					"opacity": {
						"healthy": "0.4",
						"failing": "1"
					}
				},
				"notify": true,
				"targets": [{
					"id": "acb69856-4952-4ff6-ac8c-f840180b5da7",
					"name": "default",
					"display": "default",
					"resource": null,
					"result": null,
					"value": null,
					"checks": null,
					"expressionValue": "config('app.key') !== null",
					"shouldReturn": true
				}],
				"checker": [],
				"resources": null,
				"notified": null,
				"currentAction": "check",
				"graphEnabled": false,
				"columnSize": 3
			},
			"result": {
				"healthy": true,
				"elapsedTime": 0.0004050731658935547,
				"value": null,
				"valueHuman": null,
				"errorMessage": null,
				"checks": null
			},
			"value": null,
			"checks": null,
			"expressionValue": "config('app.key') !== null",
			"shouldReturn": true
		}],
		"checker": [],
		"resources": null,
		"notified": null,
		"currentAction": "check",
		"graphEnabled": false,
		"columnSize": 3
	}
}

Alpine uptime not parsed correctly (users is required)

/www # uptime 
 13:44:26 up 15 days, 0 min,  load average: 0.00, 0.02, 0.08

ServerLoadChecker raises : undefined load_1 index.

 preg_match($this->resource['regex'], $system_string, $matches, PREG_OFFSET_CAPTURE);
/** var_export:::
$system_string= ' 13:39:07 up 7:34, load average: 1.65, 1.82, 1.67'
$regex = '~(?\\d{1,2}):(?\\d{2})(?::(?\\d{2}))?\\s+up\\s+(?:(?\\d+)\\s+days?,\\s+)?\\b(?:(?\\d+):)?(?\\d+)(?:\\s+(?:minute|minutes|min)?)?,\\s+(?\\d+).+?(?\\d+.\\d+),?\\s+(?\\d+.\\d+),?\\s+(?\\d+.\\d+)~'
$matches = array ( )

users is not optional on regex:

This regex, fix it:

(?<time_hour>\d{1,2}):(?<time_minute>\d{2})(?::(?<time_second>\d{2}))?\s+up\s+(?:(?<up_days>\d+)\s+days?,\s+)?\b(?:(?<up_hours>\d+):)?(?<up_minutes>\d+)(?:\s+(?:minute|minutes|min)?)?,\s+(?<users>\d+)?.+?(?<load_1>\d+.\d+),?\s+(?<load_5>\d+.\d+),?\s+(?<load_15>\d+.\d+)

Symfony/yaml should be required not required --dev

Trying to deploy a project using this package in production with 'composer install --no-dev' resulted in

production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Symfony\Component\Yaml\Yaml' not found in ./vendor/pragmarx/health/src/Support/Yaml.php:37

Moving symfony/yaml to "required" would fix this issue.

Information disclosure of highly sensible information

At the moment the code is exporting the complete configuration of all health resource to the ui. This means some highly sensitive information is exported, like the APP_KEY (used for encryption), database or external service credentials. But there's absolutely no need to export anything of it. The code should be cleaned to only export relevant information for the ui and never ever (!) export any of the resource configuration options as they may contain very sensitive information. They should never be transmitted!

One could argue that the health panel should only be visible to administrators and route middleware should be configured to ensure this, but...

  • Most people will use it without further configuration. I mean who would expect his database credentials embedded in a health page.
  • If no HTTPs is used this information is sent in plaintext on the web
  • This information may be cached by the browser. I hope you are never opening it from anywhere than your devices.
  • There may be many more reasons.

At the moment using this plugin is in my humble opinion a very hard security breach.

Add demo gif to README

Disclaimer: This is a bot

It looks like your repo is trending. The github_trending_videos Instgram account automatically shows the demo gifs of trending repos in Github.

Your README doesn't seem to have any demo gifs. Add one and the next time the parser runs it will pick it up and post it on its Instagram feed. If you don't want to just close this issue we won't bother you again.

404 for /health/resource/{name}

The route for /health/resource/{name} doesn't seem to be working for me and I get a 404. I have tried the name and the abbreviation for {name} and can't seem to get it to work. Is there additional configuration I'm missing?

[Suggestion] Remote Process Checker

It would be awesome if there was a process checker that could check the process on a set of remote servers.
This would also fix the issues when dealing with a scalable server setup with multiple servers.

A bunch of issues with this

I've found a bunch of issues with this package so far.

The config gives you a "notifier" namespace where you'd assume you can change the namespace and use your own notifier. If you search the entire package, that config is NEVER used.

Also the package breaks if you don't SPECIFICALLY use a model for your notifications which is, in my opinion, not very user-friendly.

The package also needs a revision on the documentation since it just very lightly goes over some of the functionality.

On another note, I'm having issues with registering my own event listener on the RaiseHealthIssue. I've registered it in the EventServiceProvider and it doesn't register at all. (Laravel 5.7)

Can't install in Laravel 5.4

According to Documentation, that this can be installed in Laravel 5.3+, however, composer fails with the following message:

Problem 1 - Installation request for pragmarx/health ^0.4.0 -> satisfiable by pragmarx/health[v0.4.0]. - pragmarx/health v0.4.0 requires laravel/framework 5.5.* -> satisfiable by laravel/framework[5.5.x-dev, v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.27, v5.5.3, v5.5.4, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9] but these conflict with your requirements or minimum-stability.

Please let me know if this can be installed in Laravel 5.4. Thanks.

Support for Laravel 5.8

@antonioribeiro, I was looking for a health check mechanism and found this repository ... I also hoping for this package will have support for Laravel 5.8 ... Thanks in advance 🎉

Resources can't be loaded if laravel path contains a prefix

Issue #115 described problems when laravel had been installed to a subfolder. This has been fixed in 0.9.16. But there's still another problem with subfolders if you are using a path prefix which seems not to be fixed the change.

Background: Laravel path prefix

Take for example you have a laravel application at http://example.com/monitoringapp. If you use a webserver like caddy you can point the domain's path prefix monitoringapp to a laravel installation in a specific folder (e.g. /var/www/laravel-monitoring). Everything works correct when you include the path prefix in your .env (APP_URL=http://example.com/monitoringapp):

  • Routes are registered with /health/check because the /monitoringapp prefix must not be used when registering routes! (laravel will "ignore" the /monitoringapp when routing)
  • The routes are correctly accessible, they resolve to the correct controller.
  • No problem at this point :)

Problem

The code is using the routes.list[*].uri route path directly for axios to load the information. But this will point to /health/* and not /monitoringapp/health/*. The routes.prefix value can not be changed as described because the route has to be registered without the /monitoringappprefix. So the javascript code can not load the information.

Solution

Use laravel's url helper to generate absolute urls for axios, because it does now how to create the correct one:

  • config('health.routes.list[0].uri') => /health/panel WRONG
  • route(config('health.routes.list[0].name')) => http://example.com/monitoringapp/health/panel CORRECT
    Using the url-helper to generate the url for axios may probably solve many more problems with "esoteric" configurations how urls are mapped within laravel because it's relying on the same logic every url is routed within laravel.

Installation failed on Laravel 5.6

Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In Parser.php line 343:
                                                                        
  Duplicate key "name" detected at line 3 (near "name: health-queue").  
                                                                        

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1```

Error on ssl check

Hi there,

My ssl is working fine and still get the message below, please note says "httpSS":

sem titulo

CloudStorage checker can get false-negative related to eventual consistency (needs less invasive method, too?)

Given PragmaRX\Health\Checkers\CloudStorage:

The logic of checker is straightforward:

  1. We put the new file to the disk
  2. We check it existence
  3. We delete it

For local filesystems, it will work fine, but for example s3 it is undesired order of actions:

  1. S3 guarantees consistency for newly created objects.
  2. But for deletes and overwrites with PUT, it doesn't guarantee it. (I don't remember the actual timings).
  3. As a result, we can get into a situation with consequential checks - in the previous one we just deleted an object, in current we add a new object with the same name and it actually considered as overriding, so now it is possible to get file not found exception during an attempt to get content from that file (new version hasn't propagated yet to replace deleted one).

Please note, that the delete action is not a key here - it is similar to PUT request.

So, this checker is inappropriate for S3 with short grace.

Possible workaround:

  1. Force to not using constant strings as the file name
  2. Add some small hash (maybe 4 letters UUID will be good enough) internally to the value of filename in the checker.

Error 404

Error 404 when open route health/panel.

capture
ّFor what ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.