2013-02-22 22 views
14

Nginx + php-fpm çalıştırıyorum. PHP işlemlerinin her birinin ne yaptığını nasıl anlayabilirim? Apache'de apad işleminin PID x ile işlendiğini görebileceğim genişletilmiş mod_status gibi bir şey. PHP işleminin URL'yi bildiğinden emin değilim, ancak komut dosyasının yolunu ve adını almak yeterli olacaktır.PHP-FPM işleminde hangi betiğin yürütüldüğü nasıl belirlenir

cevap

24

Ben çözüm bulduk. PHP 5.3.8 veya 5.3.9'dan beri kullanılabilir, ancak belgelenmemiş gibi görünüyor. Özellik isteği #54577 dayanarak, durum sayfası her bir işçinin durumunu ayrı olarak gösterecek olan full seçeneğini destekler. Örneğin URL http://server.com/php-status?full olacak ve örnek çıktı benziyor Yani:

pid:     22816 
state:    Idle 
start time:   22/Feb/2013:15:03:42 +0100 
start since:   10933 
requests:    28352 
request duration:  1392 
request method:  GET 
request URI:   /ad.php?zID=597 
content length:  0 
user:     - 
script:    /home/web/server.com/ad/ad.php 
last request cpu:  718.39 
last request memory: 1310720 
+3

Başka bir kullanışlı seçenek de? Html, örn .: http://server.com/php-status?full&html (çıktıyı html tablosu olarak biçimlendirir, bu da tüm çalışan komut dosyalarını bir kerede çok daha kolay görmenizi sağlar) – ivanhoe

+0

nginx yapısına herhangi bir paramter ekleyeceğimi söyleyebilir miyim? –

+0

@babakfaghihian evet, bu URL'yi (örneğin, 'php-fpm'yi) php-fpm’ye aktarmanız gerekir. – Marki555

6

PHP-FPM yerleşik bir durum izleyicisine sahiptir, ancak mod_status kadar ayrıntılı değildir. (CentOS 6) php-fpm yapılandırma dosyası /etc/php-fpm.d/www.conf

; The URI to view the FPM status page. If this value is not set, no URI will be 
; recognized as a status page. By default, the status page shows the following 
; information: 
; accepted conn - the number of request accepted by the pool; 
; pool    - the name of the pool; 
; process manager - static or dynamic; 
; idle processes - the number of idle processes; 
; active processes - the number of active processes; 
; total processes - the number of idle + active processes. 
; The values of 'idle processes', 'active processes' and 'total processes' are 
; updated each second. The value of 'accepted conn' is updated in real time. 
; Example output: 
; accepted conn: 12073 
; pool:    www 
; process manager: static 
; idle processes: 35 
; active processes: 65 
; total processes: 100 
; By default the status page output is formatted as text/plain. Passing either 
; 'html' or 'json' as a query string will return the corresponding output 
; syntax. Example: 
; http://www.foo.bar/status 
; http://www.foo.bar/status?json 
; http://www.foo.bar/status?html 
; Note: The value must start with a leading slash (/). The value can be 
;  anything, but it may not be a good idea to use the .php extension or it 
;  may conflict with a real PHP file. 
; Default Value: not set 
;pm.status_path = /status 

Etkinleştirseniz itibaren, ardından PHP-FPM için soket/bağlantı noktasına nginx gelen yolunu geçebilir ve durum sayfasını görüntüleyebilirsiniz.

nginx.conf: Bazı googling saat ve tarama PHP.net hata takip sistemi sonrasında

location /status { 

    include fastcgi_params; 
    fastcgi_pass unix:/var/lib/php/php-fpm.sock; 

} 
+0

evet ben php-fpm bu durumu hakkında biliyorum, zaten kullanıyorum munin ve zabbix izleme. Ancak, işlem başına bilgi değil, yalnızca toplu bilgi sağlar. – Marki555

+0

Özel bir günlüğe kaydetme çözümü oluşturma veya erişim günlüğü işlemeyi ayarlama dışında yapabileceğiniz çok şey olduğunu düşünmeyin, ancak bu işlem, işlem süresi gibi gereken ayrıntılı bilgileri vermez. PHP-FPM'nin durum raporlarını genişletecekleri konusunda eminim. – sjdaws

+0

Son olarak durum sayfasının işlem başı bilgisini desteklediğini buldum (cevabıma bakın). – Marki555

3

cgi komut satırı daha rahat olduğunu:

SCRIPT_NAME=/status \ 
SCRIPT_FILENAME=/status \ 
REQUEST_METHOD=GET \ 
cgi-fcgi -bind -connect 127.0.0.1:9000 
+4

Ayrıca OP'nin aradığı şeyi döndürmek için 'QUERY_STRING = full' eklemelisiniz. "SCRIPT_FILENAME" ifadesinin "/ status? Full" olarak değiştirilmesi işe yaramıyor. – Isius

+0

Hala durum sayfasını 'pm.status_path' uncommenting ile etkinleştirmeniz gerekecek; Bu yöntemin avantajı, web sunucusu tarafından açıkta kalması gerekmemesidir. "SCRIPT_NAME" ve "SCRIPT_FILENAME", "php-fpm.conf" dosyasındaki "pm.status_path" ile aynı olmalıdır. Bu son parametre ('127.0.0.1: 9000') FCGI sunucusuna bağlantıdır, * web sunucusuna değil * dinleyeceği parametrenin aynı INI dosyasında olması gerekir. Eğer bir soket ise, bağlanmak için 'sudo' kullanmak zorunda kalabilirsiniz, bu durumda' sE'yi 'sudo'ya çevre değişkenlerini 'cgi-fcgi'ye iletmek için de kullanabilirsiniz. – Wolfgang

İlgili konular