fat                                      Tue, 31 Aug 2010 14:49:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=302925

Log:
- add 'max children reached' to the FPM status page. It shows how many times
  a pool has reached the max_children parameter.

Changed paths:
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h
    U   php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_status.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_status.h
    U   php/php-src/trunk/sapi/fpm/php-fpm.conf.in

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -574,6 +574,7 @@
 			}
 			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)); */
 		}

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -366,6 +366,7 @@
 		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 @@
 			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;
 				}

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -99,6 +99,40 @@
 }
 /* }}} */

+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 @@
 	}

 	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 @@
 		"<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 @@
 		"\"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");
 }

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h	2010-08-31 14:49:16 UTC (rev 302925)
@@ -15,6 +15,7 @@
 	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_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);


Modified: php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in	2010-08-31 14:49:16 UTC (rev 302925)
@@ -154,21 +154,25 @@
 ; 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:

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -574,6 +574,7 @@
 			}
 			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)); */
 		}

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -366,6 +366,7 @@
 		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 @@
 			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;
 				}

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_status.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_status.c	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_status.c	2010-08-31 14:49:16 UTC (rev 302925)
@@ -99,6 +99,40 @@
 }
 /* }}} */

+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 @@
 	}

 	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 @@
 		"<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 @@
 		"\"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");
 }

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_status.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_status.h	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_status.h	2010-08-31 14:49:16 UTC (rev 302925)
@@ -15,6 +15,7 @@
 	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_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);


Modified: php/php-src/trunk/sapi/fpm/php-fpm.conf.in
===================================================================
--- php/php-src/trunk/sapi/fpm/php-fpm.conf.in	2010-08-31 14:45:47 UTC (rev 302924)
+++ php/php-src/trunk/sapi/fpm/php-fpm.conf.in	2010-08-31 14:49:16 UTC (rev 302925)
@@ -154,21 +154,25 @@
 ; 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:
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to