I'm struggling to find a monit config for php-fpm that works.

This is what I've tried:

### Monitoring php-fpm: the parent process.
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group phpcgi # phpcgi group
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  ## Test the UNIX socket. Restart if down.
  if failed unixsocket /var/run/php-fpm.sock then restart
  ## If the restarts attempts fail then alert.
  if 3 restarts within 5 cycles then timeout
  depends on php-fpm_bin
  depends on php-fpm_init

## Test the php-fpm binary.
check file php-fpm_bin with path /usr/sbin/php-fpm
   group phpcgi
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

## Test the init scripts.
check file php-fpm_init with path /etc/init.d/php-fpm
   group phpcgi
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

But it fails because there is no php-fpm.sock (Centos 6)

link|improve this question
feedback

3 Answers

up vote 2 down vote accepted

I´m using the ping.path directive in php-fpm to check if it´s working...

and configured it on nginx.conf (i down´t know if it´s your setup)

location /ping {
    access_log     off;
    allow          127.0.0.1;
    deny           all;
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
    include        fastcgi_params;
}

On monit.d

check process php-fpm.www with pidfile /var/run/php-fpm/php-fpm.pid
  group php-fpm
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  if failed host localhost port 80 protocol http
     and request '/ping'
     with timeout 20 seconds for 5 cycles
     then restart
  ## If the restarts attempts fail then alert.
  if 3 restarts within 5 cycles then timeout
  depends on php-fpm_bin
  depends on php-fpm_init
  depends on nginx
link|improve this answer
thanks. the only other thing I had to do was uncomment ping.path and ping.response in php-fpm.d/www.conf – Adam Jimenez Dec 3 '11 at 9:13
feedback

Have you considered using monit's process pattern matching along with the existing daemon start and stop?

Some form of matching "php-fpm"

link|improve this answer
well it's already tracking the process from the pid file is it not? I was thinking the answer might be to open a http page and look for "bad gateway" - but no idea how to do that :s – Adam Jimenez Oct 24 '11 at 10:19
feedback

Is there php-fpm.sock file in /var/run/php-fpm/php-fpm.sock? If there is, then modify this line

if failed unixsocket /var/run/php-fpm.sock then restart

wit

if failed unixsocket /var/run/php-fpm/php-fpm.sock then restart
link|improve this answer
nope - no php-fpm.sock anywhere. – Adam Jimenez Oct 24 '11 at 10:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.