Giter VIP home page Giter VIP logo

phpfpm-monitor's Introduction

Php Fpm Monitor

This package can be configured to monitor php5-fpm through its built in ping and status pages. It can then restart php5-fpm if it detects a failure and also optionally notify you of the failure with the last successful status output.

It is not designed as a permanent solution for problems with php-fpm, more a tool to help you handle failure while the problems can be interrogated by notifying you of the state of the last success. Typically the problems might be a mis-configured fpm pool and the log of the last status before failure will hopefully help diagnose those issues.

Instalation

Install with composer:

  1. Add to composer:

    "require": { ... "kevbaldwyn/php-fpm-monitor":"dev-master" ... }

  2. Composer Update:

    $ composer update kevbaldwyn/php-fpm-monitor

  3. Copy the yaml config.example.yml file to a convenient location and configure the options as you require. It should work without notifications out of the box.

Useage

The package provides a binary which will be located in vendor/bin/monitor. Basic useage requires passing the config yaml file path to the command as the first argument. All other options are optional.

$ vendor/bin/monitor check /var/www/config.yml

Passing the help -h flag shows all options. To set the host and port to ping php-fpm for example:

$ vendor/bin/monitor check /var/www/config.yml -l http://example.com -p 80

The idea is that this command is then run from cron periodically to check the state of php-fpm and will automatically restart the service if it is down.

Php5-Fpm status and ping pages

This tool requires the status and ping pages to be correctly setup. More info on this can be found here: https://rtcamp.com/tutorials/php/fpm-status-page/

Failure Handlers

There are 2 built in failure handlers : KevBaldwyn\PhpFpmMonitor\FailureHandlers\PhpFpmRestart which restarts php-fpm and KevBaldwyn\PhpFpmMonitor\FailureHandlers\NotifyHipChat. Both of these can be further configured in the yaml config.

To specify which FailureHandlers run you simply list the fully namespaced classes in the restart_handlers config array.

You can write your own handlers by implementing KevBaldwyn\PhpFpmMonitor\OnFailureInterface. This receives the following method call which contains the full config, as defined in the yaml file, and the last successful status response in json format.

public function handle(array $config, $lastSuccessStatus);

phpfpm-monitor's People

Contributors

kevbaldwyn avatar

Watchers

 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.