2017 © Pedro Peláez
 

library health

image

fliglio/health

  • Saturday, August 19, 2017
  • by benschw
  • Repository
  • 7 Watchers
  • 0 Stars
  • 5,590 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 15 % Grown

The README.md

Build Status Latest Stable Version, (*1)

fliglio-healthcheck

Extensible suite of health checks for PHP services, complete with custom behaviors to suit your health check consumer's needs. Default health checks include Mysql, Rabbit, Memcache, Can Write File, SSH and HttpResolver., (*2)

Install With Composer

{
    "require" : {
        "fliglio/health" : "2.1.*"
    }
}

Example One, Basic MySql Check:

$manager = new HealthManager();
$manager->addCheck(new MysqlCheck('localhost', 'myuser', 'password'));

echo json_encode($manager->process());

If your connection information is good, you should see:, (*3)

{"status":"UP", "mysql::localhost;myuser":"UP"}

If the connection is not good, for whatever reason, you'll get:, (*4)

{"status":"DOWN", "mysql::localhost;myuser":"DOWN"}

Example Two, Optional Checks:

$manager = new HealthManager();
$manager->addCheck(new MysqlCheck('localhost', 'myuser', 'password'))
    ->addOptionalCheck(new RabbitCheck('localhost', '/', 'myuser', 'password'));

echo json_encode($manager->process());

If the optional check is down, the status will remain "UP". Example:, (*5)

{"status":"UP", "mysql::localhost;myuser":"UP", "rabbit::localhost;myuser":"WARN"}

Behavior Example:

Depending on your apps health check reporting needs, you can add behaviors., (*6)

$response = new fliglio\Response();

$manager = new HealthManager();
$manager->addBehavior(new LogFailuresBehavior())
    ->addBehavior(new LogWarningsBehavior())
    ->addBehavior(new SilentOutputBehavior())
    ->addBehavior(new StatusCodeBehavior($response);

$manager->addCheck(new MysqlCheck('localhost', 'myuser', 'password'));

echo json_encode($manager->process());

If the check is up, you will get HTTP 200 and a single json property. Example:, (*7)

{"status":"UP"}

If the check is down, you will get HTTP 500, a message in the php log and a single json property. Example:, (*8)

{"status":"DOWN"}

Silent Output + Logging Caveat:

If you want to log issue + have silent output, you have to put the SilentOutputBehavior after the loggers - otherwise the loggers wont know if there were any issues., (*9)

$manager = new HealthManager();
$manager->addBehavior(new LogIssuesBehavior())
    ->addBehavior(new SilentOutputBehavior());

Public AWS ALB Behavior Example:

$response = new fliglio\Response();

$manager = new HealthManager();
$manager->addBehavior(new SilentOutputBehavior())
    ->addBehavior(new StatusCodeBehavior($response);

Custom Health Checks:

You can add your own custom health checks, just implement the interface Fliglio\Health\Api\HealthCheck. If you want that health check to log, you'll need to implement the HealthCheckReport interface in addition to adding the LogFailuresBehavior/LogWarningsBehavior behavior., (*10)

The Versions

19/08 2017

dev-master

9999999-dev

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

10/08 2017

dev-Case-Issue

dev-Case-Issue

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

08/08 2017

2.1.7

2.1.7.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

25/07 2017

2.1.6

2.1.6.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

03/04 2017

2.1.5

2.1.5.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

23/03 2017

2.1.4

2.1.4.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

23/03 2017

dev-RABBIT-upgrade

dev-RABBIT-upgrade

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

21/02 2017

2.1.3

2.1.3.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

16/05 2016

2.1.2

2.1.2.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

03/05 2016

2.1.1

2.1.1.0

  Sources   Download

The Requires

 

The Development Requires