Git Product home page Git Product logo

lumen-diagnostics's Introduction

Lumen Diagnostics

Lumen Diagnostics exposes Zend Diagnostics results as a Lumen controller and Artisan command.

This README assumes knowledge of the Zend Diagnostics README.

Installation

composer require activecampaign/diagnostics

Configuration

Create a diagnostics.php configuration file in your application. It needs to have three properties: default_group, groups, and checks.

<?php

return [
    'default_group' => 'default',
    'groups' => [
        'default' => ['writable_directory', 'disk_usage', 'disk_free', 'pdo_connection', 'opcache_memory', 'redis'],
        'cli' => ['writable_directory', 'disk_usage', 'disk_free', 'pdo_connection'],
    ],
    'checks' => [
        'writable_directory' => [ZendDiagnostics\Check\DirWritable::class, [sys_get_temp_dir()]],
        'disk_free' => [ZendDiagnostics\Check\DiskFree::class, ['10G', sys_get_temp_dir()]],
        'disk_usage' => [ZendDiagnostics\Check\DiskUsage::class, [95, 100, '/']],
        'pdo_connection' => [
            ZendDiagnostics\Check\PDOCheck::class,
            [
                env('DB_CONNECTION') . ':' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE'),
                env('DB_USERNAME'),
                env('DB_PASSWORD'),
            ]
        ],
        'redis' => ZendDiagnostics\Check\Redis::class,
        'opcache_memory' => [ZendDiagnostics\Check\OpCacheMemory::class, [80, 95]],
    ]
];

The checks array is keyed by an arbitrary name for that check. The value is either a simple class name (see redis in the example) or an array tuple of the class name and the constructor parameters (see everything else in the example).

Usage

The Artisan command is run with php artisan monitor:health. If the exit status is 0 then all health checks are good. If the exit status is anything but 0 then there are failing health checks.

The HTTP controller is accessible at /health. When it returns HTTP 200 then all health checks are good. If it returns HTTP 502 then there are failing health checks.

Credits

Parts of this project are taken from the MIT licensed Liip Monitor Bundle for Symfony.

lumen-diagnostics's People

Contributors

bangpound avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.