Download the PHP package liip/monitor without Composer

On this page you can find all versions of the php package liip/monitor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package monitor

Liip Monitor

This library provides shareable and reusable health checks. It ha been deprecated in favor of zendframework/ZendDiagnostics.

For integration into Symfony2 see the Liip Monitor Bundle.

The idea is that you fork this project and add your own health checks that you think they can useful for someone else project. This library provides a set of interfaces and a runner class to execute the health checks. On top of that it also provides a set of health check implementations (see the list below).

Installation

To get the source of this library simply use git:

# get source
git clone git://github.com/liip/LiipMonitor.git
cd LiipMonitor

To add this library to an existing project it is recommended to use the composer installer. Add the following to your projects composer.json:

"require": {
    ..
    "liip/monitor": "dev-master"
},

Get the composer installer if its not yet installed on your system and run update

# install dependencies
curl -s http://getcomposer.org/installer | php
php composer.phar update liip/monitor

Check groups

Checks can be grouped by implementing the getGroup method of the CheckInterface. By grouping checks it's possible to implement end-user status pages which provide feedback but hide implementation details, similar to status.github.com.

Available Health Checks

DiscUsageCheck

Checks if the maximum disc usage in percentage is reached.

DoctrineDbalCheck

Checks if a doctrine dbal server is running.

HttpServiceCheck

Checks if an http server is running on the host, port and path specified in the service configuration, returning the expected status code and content.

MemcacheCheck

Checks if a memcache server is running on the host and port specified in the service configuration.

RedisCheck

Checks if a redis server is running on the host and port specified in the service configuration.

PhpExtensionsCheck

Checks if the extensions specified in the service configuration are enabled in your PHP installation.

ProcessActiveCheck

Checks if a process containing a phrase specified in the service configuration is running on the machine.

SecurityAdvisoryCheck

Checks any composer dependency has an open security advisory.

WritableDirectoryCheck

Checks if the user executing the script is able to write in the given directory.

RabbitMQCheck

Checks if a rabbitmq server is running on the host and port specified in the service configuration, for declared user/password/vhost.

Writing Health Checks

Let's see an example on how to implement a health check class. In this case we are going to test for the availability of PHP Extensions:

namespace Acme\Hello\Check;

use Liip\Monitor\Check\Check;
use Liip\Monitor\Exception\CheckFailedException;
use Liip\Monitor\Result\CheckResult;

class PhpExtensionsCheck extends Check
{
    protected $extensions;

    public function __construct($extensions)
    {
        $this->extensions = $extensions;
    }

    public function check()
    {
        try {
            foreach ($this->extensions as $extension) {
                if (!extension_loaded($extension)) {
                    throw new CheckFailedException(sprintf('Extension %s not loaded', $extension));
                }
            }
            return $this->buildResult('OK', CheckResult::OK);
        } catch (\Exception $e) {
            return $this->buildResult(sprintf('KO - %s', $e->getMessage()), CheckResult::CRITICAL);
        }
    }

    public function getName()
    {
        return "PHP Extensions Health Check";
    }
}

Once you implemented the class then it's time to register the check service with your runner:

$checkChain = new \Liip\Monitor\Check\CheckChain();
$runner = new \Liip\Monitor\Check\Runner($checkChain);

$phpExtensionCheck = new \Acme\Hello\Check\PhpExtensionsCheck(array('apc', 'memcached'));
$checkChain->addCheck('php_extension_check', $phpExtensionCheck);

Finally to run health checks use:

$runner->runAllChecks() // runs all checks
$runner->runCheckById('php_extension_check'); // runs an individual check by id

To get a list of available checks use:

$chain->getAvailableChecks();

CheckResult values

These values has been taken from the nagios documentation :

As you can see our constructor will take an array with the names of the extensions our application requires. Then on the check method it will iterate over that array to test for each of the extensions. If there are no problems then the check will return a CheckResult object with a message (OK in our case) and the result status (CheckResult::SUCCESS in our case). As you can see this is as easy as it gets.

Contributions

Fork this project, add a health check and then open a pull request.

Note to contributors

BY CONTRIBUTING TO THE LiipMonitor SOURCE CODE REPOSITORY YOU AGREE TO LICENSE YOUR CONTRIBUTION UNDER THE TERMS OF THE MIT LICENSE AS SPECIFIED IN THE 'LICENSE' FILE IN THIS DIRECTORY.


All versions of monitor with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package liip/monitor contains the following files

Loading the files please wait ....