- add 'max children reached' to the FPM status page. It shows how many times

a pool has reached the max_children parameter.
This commit is contained in:
Jérôme Loyet 2010-08-31 14:49:16 +00:00
parent d3670280f0
commit 4d62c8c501
5 changed files with 69 additions and 22 deletions

View 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)); */
}

View 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;
}

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

View 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);

View 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: