Getting the status from new php-fpm

44 views
Skip to first unread message

Davy Campano

unread,
Feb 23, 2010, 9:02:38 AM2/23/10
to highloa...@googlegroups.com
The new php-fpm that is built into PHP 5.3 supports a /status command to get information about the pool.  I'm wondering if anyone knows if there is an easy way to query this status from a shell script using netcat or something similar?  Thanks

Davy

Jérôme Loyet

unread,
Feb 23, 2010, 6:13:01 PM2/23/10
to highloa...@googlegroups.com
hi,

to request this page, you have to set it up in fpm and configure nginx
(or another front web server) to access it.

For exemple in php-fpm.conf:
<value name="status">/status</value> // requesting /status will
return the status page
<value name="ping">/ping</value> // requesting /ping will return the
text set next
<value name="pong">pong</value> // requestint the previous parameter
will return pong

And in nginx.conf:
...
http {
server {
listen 80;
...
location ~ ^/(status|ping)$ {
include fastcgi_params;
fastcgi_pass backend;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
allow 127.0.0.1;
allow stats_collector.localdomain;
allow watchdog.localdomain;
deny all;
}
}
}

The request the web server:

# curl http://localhost:81/status.php
accepted conn: 2
pool: pool_1
process manager: static
idle processes: 3
active processes: 0
total processes: 3

# curl http://localhost:81/status.php?html
<table>
<tr><th>accepted conn</th><td>3</td></tr>
<tr><th>pool</th><td>pool_1</td></tr>
<tr><th>process manager</th><td>static</td></tr>
<tr><th>idle processes</th><td>3</td></tr>
<tr><th>active processes</th><td>0</td></tr>
<tr><th>total processes</th><td>3</td></tr>

# curl http://localhost:81/status.php?json
{"accepted conn":4,"pool":"pool_1","process manager":"static","idle
processes":3,"active processes":0,"total processes":3}

# curl http://localhost:81/ping.php
pong

enjoy

2010/2/23 Davy Campano <dcam...@gmail.com>:

Michael Shadle

unread,
Feb 23, 2010, 6:30:51 PM2/23/10
to highloa...@googlegroups.com
Perhaps this would be a place to ask - does anyone see an issue with
having it output just JSON data?

It's a small amount of data so still human readable, but it is both
machine readable and human readable as JSON and allows for direct
Javascript consumption too; seems unnecessary to have multiple output
types. Jerome and I sparred over this in email a while back. :)


2010/2/23 Jérôme Loyet <m...@fatbsd.com>:

Jérôme Loyet

unread,
Feb 24, 2010, 12:41:15 AM2/24/10
to highloa...@googlegroups.com
yes we did already discuss about this and this is definitely not the
point of this mail about HOW to access the status page.

++ Jerome

2010/2/24 Michael Shadle <mik...@gmail.com>:

Michael Shadle

unread,
Feb 24, 2010, 12:49:26 AM2/24/10
to highloa...@googlegroups.com
there's no reason why it can't be discussed though. should i start a
new thread? :p

2010/2/23 Jérôme Loyet <m...@fatbsd.com>:

Jérôme Loyet

unread,
Feb 24, 2010, 12:51:43 AM2/24/10
to highloa...@googlegroups.com
2010/2/24 Michael Shadle <mik...@gmail.com>:

> there's no reason why it can't be discussed though. should i start a
> new thread? :p

I didn't say it could'nt be discussed so Yes you can ! :)

任晓磊

unread,
Feb 24, 2010, 2:23:51 AM2/24/10
to highloa...@googlegroups.com
status or status.php?

2010/2/24 Jérôme Loyet <m...@fatbsd.com>:

--
Ren Xiaolei

Jérôme Loyet

unread,
Feb 24, 2010, 11:35:31 AM2/24/10
to highloa...@googlegroups.com
as you wish.

I recommand not to choose a .php extension in order to NOT confuse
with a classic PHP file. This also makes you have two differents conf
in your webserver and this is better for security (you can restrict
access to the status and ping pages easily).

2010/2/24 任晓磊 <july...@gmail.com>:

Davy Campano

unread,
Feb 24, 2010, 11:59:48 AM2/24/10
to highloa...@googlegroups.com
Hey Jerome,

I think he might have been confused because you called it /status but in the curl examples you were calling it with status.php.  Also, just wanted to thank you for your well done examples.  

Thanks

Davy

2010/2/24 Jérôme Loyet <m...@fatbsd.com>

Jérôme Loyet

unread,
Feb 24, 2010, 12:03:01 PM2/24/10
to highloa...@googlegroups.com
2010/2/24 Davy Campano <dcam...@gmail.com>:

> Hey Jerome,
> I think he might have been confused because you called it /status but in the
> curl examples you were calling it with status.php.

yes you're right ... In my test env, it's called status.php to avoid
having 2 location in my nginx.conf.

my mistake

>Also, just wanted to
> thank you for your well done examples.
> Thanks

you're welcome

Reply all
Reply to author
Forward
0 new messages