CentOS 6.x open Nginx and PHP-FPM status statistics

Source: Internet
Author: User

Both Nginx and PHP-FPM have created a status page during installation to count the relevant state information for Nginx and PHP-FPM. Here's how to turn on the status statistics for Nginx and PHP-FPM, and describe the meanings of each parameter.


(a) Open Nginx status statistics and detailed parameters

Create the nginx_status.conf in/etc/nginx/conf.d/(according to your own Nginx path) and add the following:

[email protected] conf.d]# Cat nginx_status.conf server {Listen 80;    server_name 127.0.0.1;        Location/nginx_status {stub_status on;        Access_log off;        #allow 127.0.0.1;    #deny all; }}

Restart Nginx:

[Email protected] vhost]#/etc/init.d/nginx restartnginx:the configuration file/usr/local/nginx/conf/nginx.conf                                            Syntax is oknginx:configuration file/usr/local/nginx/conf/nginx.conf test is successfulstopping nginx: [OK] Starting nginx: [OK]

Test:

[[email protected] conf.d]# Curl 127.0.0.1:80/nginx_statusactive connections:4 Server accepts handled requests 8 8 Rea ding:0 writing:1 Waiting:3

(ii) Opening PHP-FPM status statistics and detailed parameters

Open php-fpm.conf Open with PHP-FPM status function:

Vim php-fpm.conf:


Pm.status_path =/phpfpm_status

The default is/status, of course, can also be changed to/php_status, I am here to change to/php_status


Vim/etc/nginx/conf.d/php_fpm_status.conf



server {


Listen 80;

server_name 127.0.0.1;


Location/php_status {

Fastcgi_pass 127.0.0.1:9000;

Include Fastcgi_params;

Fastcgi_param script_filename $fastcgi _script_name;

#allow x.x.x.x;

Access_log off;

#deny all;

}

}


Restart Nginx, php-fpm.


Test:


[Email protected] conf.d]# Curl Http://127.0.0.1/php_status

Pool:www

Process Manager:dynamic

Start time:25/feb/2017:10:27:57 +0800

Start Since:7

Accepted Conn:1

Listen queue:0

Max Listen queue:0

Listen Queue len:128

Idle Processes:4

Active processes:1

Total Processes:5

Max Active processes:1

Max Children reached:0

Slow requests:0


PHP-FPM Status Details:

POOL–FPM pool name, mostly wwwprocess manager– process management mode, value: Static, dynamic or OnDemand. Dynamicstart time– Start date, if Reload php-fpm, the time will update the start since– run time accepted conn– the number of requests received by the current pool listen queue– request waiting queue, if this value is not 0, Then to increase the number of FPM processes Max Listen queue– request wait queue highest number listen queue Len–socket wait Queue Length idle processes– idle Process number Active processes– active process number Total processes– Overall process quantity Max active processes– max active process number (FPM start count) Max children reached-the number of times the maximum limit of the avenue process is limited, if this number is not 0, that indicates your maximum process The quantity is too small, please change it a little larger. Slow requests– enabled PHP-FPM Slow-log, number of slow requests


Nginx, PHP-FPM Status page can be personalized with parameters, with parameters JSON, XML, HTML and the first three parameters can be a combination of the full, the following PHP-FPM status as an example:

(1) JSON format:

[Email protected] vhost]# Curl Http://127.0.0.1/php_status?json

{"Pool": "www", "Process Manager": "Dynamic", "Start Time": 1487989605, "start since": 3187, "accepted conn": 179, "listen Queue ": 0," Max Listen queue ": 0," Listen queue Len ": +," idle processes ": +," active Processes ": 1," Total Processes ": 15," Max Active Processes ": 5," Max Children reached ": 0}


(2) XML format:

[Email protected] vhost]# Curl Http://127.0.0.1/php_status?xml

<?xml version= "1.0"?>

<status>

<pool>www</pool>

<process-manager>dynamic</process-manager>

<start-time>1487989605</start-time>

<start-since>3246</start-since>

<accepted-conn>184</accepted-conn>

<listen-queue>0</listen-queue>

<max-listen-queue>0</max-listen-queue>

<listen-queue-len>128</listen-queue-len>

<idle-processes>14</idle-processes>

<active-processes>1</active-processes>

<total-processes>15</total-processes>

<max-active-processes>5</max-active-processes>

<max-children-reached>0</max-children-reached>


(3) HTML format:

[Email protected] vhost]# Curl http://127.0.0.1/php_status?html

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

<HEAD><TITLE>PHP-FPM Status page</title>

<body>

<table>

<tr><th>pool</th><td>www</td></tr>

<tr><th>process manager</th><td>dynamic</td></tr>

<tr><th>start time</th><td>25/feb/2017:10:26:45 +0800</td></tr>

<tr><th>start since</th><td>3272</td></tr>

<tr><th>accepted conn</th><td>186</td></tr>

<tr><th>listen queue</th><td>0</td></tr>

<tr><th>max Listen queue</th><td>0</td></tr>

<tr><th>listen Queue len</th><td>128</td></tr>

<tr><th>idle processes</th><td>14</td></tr>

<tr><th>active processes</th><td>1</td></tr>

<tr><th>total processes</th><td>15</td></tr>

<tr><th>max Active processes</th><td>5</td></tr>

<tr><th>max Children reached</th><td>0</td></tr>

</table>

(4) Full format:

[Email protected] vhost]# Curl Http://127.0.0.1/php_status?full

Pool:www

Process Manager:dynamic

Start time:25/feb/2017:10:26:45 +0800

Start since:3341

Accepted conn:188

Listen queue:0

Max Listen queue:0

Listen Queue len:128

Idle processes:14

Active processes:1

Total processes:15

Max Active Processes:5

Max Children reached:0


************************

pid:4496

State:idle

Start time:25/feb/2017:10:26:45 +0800

Start since:3341

Requests:13

Request duration:13932

Request Method:post

Request URI:/managerlogin/index.php?ctl=default&act=status

Content length:0

User:-

Script:/data/website/index.php

Last Request cpu:71.78

Last Request memory:5767168


A lot of pid! are omitted here.


Full format detailed:

pid– process PID, you can kill this process individually. state– status of the current process (idle, Running, ...) Start time– process Start date start since– current process run time requests– How many requests the current process has processed request duration– request Length (subtle) Request method (GET, PO ST, ...)  Request uri– Requests Uricontent length– request Content Length (POST only) user– User (Php_auth_user) (or '-' if not set) script–php script (or '-' if not Set) Last request cpu– CPU usage. Last request Memorythe-memory used by previous requests


This article is from the "Running Snail" blog, please make sure to keep this source http://441274636.blog.51cto.com/5054639/1901135

CentOS 6.x open Nginx and PHP-FPM status statistics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.