kevbaldwyn / php-fpm-monitor
Monitor and restart php-fpm with notification
Installs: 1 432
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.5
- guzzlehttp/guzzle: 6.*
- hipchat/hipchat-php: >=1.0.0
- illuminate/filesystem: 4.*
- symfony/console: 2.*
- symfony/yaml: 2.*
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-12-21 20:13:55 UTC
README
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:
-
Add to composer:
"require": { ... "kevbaldwyn/php-fpm-monitor":"dev-master" ... }
-
Composer Update:
$ composer update kevbaldwyn/php-fpm-monitor
-
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);