]> granicus.if.org Git - php/commitdiff
- add 'max children reached' to the FPM status page. It shows how many times
authorJérôme Loyet <fat@php.net>
Tue, 31 Aug 2010 14:49:16 +0000 (14:49 +0000)
committerJérôme Loyet <fat@php.net>
Tue, 31 Aug 2010 14:49:16 +0000 (14:49 +0000)
  a pool has reached the max_children parameter.

sapi/fpm/fpm/fpm_conf.c
sapi/fpm/fpm/fpm_process_ctl.c
sapi/fpm/fpm/fpm_status.c
sapi/fpm/fpm/fpm_status.h
sapi/fpm/php-fpm.conf.in

index 4c7e6d618cf04290bc18ff76e09d3bb7a208d57f..7d25a044fae65f9593f46655ff651dbbbcac829c 100644 (file)
@@ -574,6 +574,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
                        }
                        fpm_status_update_accepted_conn(wp->shm_status, 0);
                        fpm_status_update_activity(wp->shm_status, -1, -1, -1, 1);
+                       fpm_status_update_max_children_reached(wp->shm_status, 0);
                        fpm_status_set_pm(wp->shm_status, wp->config->pm);
                        /* memset(&fpm_status.last_update, 0, sizeof(fpm_status.last_update)); */
                }
index 573a596a355207bcff67c6627612be84f17def91..d4639b0863678aac427f451cdcc85d6a38fc9162 100644 (file)
@@ -366,6 +366,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
                if (idle < wp->config->pm_min_spare_servers) {
                        if (wp->running_children >= wp->config->pm_max_children) {
                                if (!wp->warn_max_children) {
+                                       fpm_status_increment_max_children_reached(wp->shm_status);
                                        zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
                                        wp->warn_max_children = 1;
                                }
@@ -384,6 +385,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
                        children_to_fork = MIN(children_to_fork, wp->config->pm_max_children - wp->running_children);
                        if (children_to_fork <= 0) {
                                if (!wp->warn_max_children) {
+                                       fpm_status_increment_max_children_reached(wp->shm_status);
                                        zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
                                        wp->warn_max_children = 1;
                                }
index 50efaf8df1272f21c81ee51d429e822173eaef50..19285b193da6ca7cb854e6fb0f3b2f7174f9ff20 100644 (file)
@@ -99,6 +99,40 @@ void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int ac
 }
 /* }}} */
 
+void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm) /* {{{ */
+{
+       struct fpm_status_s status;
+
+       if (!shm) shm = fpm_status_shm;
+       if (!shm || !shm->mem) return;
+
+       /* one shot operation */
+       status = *(struct fpm_status_s *)shm->mem;
+
+       status.max_children_reached++;
+
+       /* one shot operation */
+       *(struct fpm_status_s *)shm->mem = status;
+}
+/* }}} */
+
+void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached) /* {{{ */
+{
+       struct fpm_status_s status;
+
+       if (!shm) shm = fpm_status_shm;
+       if (!shm || !shm->mem) return;
+
+       /* one shot operation */
+       status = *(struct fpm_status_s *)shm->mem;
+
+       status.max_children_reached = max_children_reached;
+
+       /* one shot operation */
+       *(struct fpm_status_s *)shm->mem = status;
+}
+/* }}} */
+
 void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update) /* {{{ */
 {
        struct fpm_status_s status;
@@ -130,13 +164,14 @@ static void fpm_status_handle_status_txt(struct fpm_status_s *status, char **out
        }
 
        spprintf(output, 0, 
-               "accepted conn:   %lu\n"
-               "pool:             %s\n"
-               "process manager:  %s\n"
-               "idle processes:   %d\n"
-               "active processes: %d\n"
-               "total processes:  %d\n",
-               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
+               "accepted conn:        %lu\n"
+               "pool:                 %s\n"
+               "process manager:      %s\n"
+               "idle processes:       %d\n"
+               "active processes:     %d\n"
+               "total processes:      %d\n"
+               "max children reached: %u\n",
+               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
 
        spprintf(content_type, 0, "Content-Type: text/plain");
 }
@@ -156,8 +191,9 @@ static void fpm_status_handle_status_html(struct fpm_status_s *status, char **ou
                "<tr><th>idle processes</th><td>%d</td></tr>\n"
                "<tr><th>active processes</th><td>%d</td></tr>\n"
                "<tr><th>total processes</th><td>%d</td></tr>\n"
+               "<tr><th>max children reached</th><td>%u</td></tr>\n"
                "</table>",
-               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
+               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
 
        spprintf(content_type, 0, "Content-Type: text/html");
 }
@@ -176,9 +212,10 @@ static void fpm_status_handle_status_json(struct fpm_status_s *status, char **ou
                "\"process manager\":\"%s\","
                "\"idle processes\":%d,"
                "\"active processes\":%d,"
-               "\"total processes\":%d"
+               "\"total processes\":%d,"
+               "\"max children reached\":%u"
                "}",
-               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
+               status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
 
        spprintf(content_type, 0, "Content-Type: application/json");
 }
index 368fc2cb5176ce50aeca5fe6c1e39894b8796031..e081f5eeb0350cb7d251cb468dc708a97f98a655 100644 (file)
@@ -15,6 +15,7 @@ struct fpm_status_s {
        int active;
        int total;
        unsigned long int accepted_conn;
+       unsigned int max_children_reached;
        struct timeval last_update;
 };
 
@@ -23,6 +24,8 @@ void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int
 void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int accepted_conn);
 void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm);
 void fpm_status_set_pm(struct fpm_shm_s *shm, int pm);
+void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached);
+void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm);
 int fpm_status_handle_status(char *uri, char *query_string, char **output, char **content_type);
 char* fpm_status_handle_ping(char *uri);
 
index d3bc7eacd75dc532a706cfe4271af719e65c54fb..ccf864a5e80594d2f46c3f74cd8cccdbe293c18c 100644 (file)
@@ -154,21 +154,25 @@ pm.max_children = 50
 ; 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.
+;   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.
+;   max children reached - number of times, the process limit has been reached,
+;                          when pm tries to start more children (works only for
+;                          pm 'dynamic')
 ; 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
+;   accepted conn:        12073
+;   pool:                 www
+;   process manager:      static
+;   idle processes:       35
+;   active processes:     65
+;   total processes:      100
+;   max children reached: 1
 ; 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: