/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/* Status Module. Display lots of internal data about how Apache is * performing and the state of all children processes. * * To enable this, add the following lines into any config file: * * <Location /server-status> * SetHandler server-status * </Location> * * You may want to protect this location by password or domain so no one * else can look at it. Then you can access the statistics with a URL like: * * http://your_server_name/server-status * * /server-status - Returns page using tables * /server-status?notable - Returns page for browsers without table support * /server-status?refresh - Returns page with 1 second refresh * /server-status?refresh=6 - Returns page with refresh every 6 seconds * /server-status?auto - Returns page with data for automatic parsing * * Mark Cox, mark@ukweb.com, November 1995 * * 12.11.95 Initial version for www.telescope.org * 13.3.96 Updated to remove rprintf's [Mark] * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie] * 18.3.96 Make extra Scoreboard variables #definable * 25.3.96 Make short report have full precision [Ben Laurie suggested] * 25.3.96 Show uptime better [Mark/Ben Laurie] * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested] * 09.4.96 Added message for non-STATUS compiled version * 18.4.96 Added per child and per slot counters [Jim Jagielski] * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.] * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing * piece in short reports [Ben Laurie] * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if * extended STATUS is enabled) [George Burgyan/Jim J.] * 10.8.98 Allow for extended status info at runtime (no more STATUS) * [Jim J.]
*/
#ifdef HAVE_TIMES /* ugh... need to know if we're running with a pthread implementation * such as linuxthreads that treats individual threads as distinct * processes; that affects how we add up CPU time in a process
*/ static pid_t child_pid; #endif
/* add another state for slots above the MaxRequestWorkers setting */ #define SERVER_DISABLED SERVER_NUM_STATUS #define MOD_STATUS_NUM_STATUS (SERVER_NUM_STATUS+1)
staticchar status_flags[MOD_STATUS_NUM_STATUS];
staticint status_handler(request_rec *r)
{ constchar *loc;
apr_time_t nowtime;
apr_uint32_t up_time;
ap_loadavg_t t; int j, i, res, written; int idle; int graceful; int busy; unsignedlong count; unsignedlong lres, my_lres, conn_lres;
apr_off_t bytes, my_bytes, conn_bytes;
apr_off_t bcount, kbcount; long req_time;
apr_time_t duration_global;
apr_time_t duration_slot; int short_report; int no_table_report;
global_score *global_record;
worker_score *ws_record;
process_score *ps_record; char *stat_buffer;
pid_t *pid_buffer, worker_pid; int *thread_idle_buffer = NULL; int *thread_graceful_buffer = NULL; int *thread_busy_buffer = NULL;
clock_t tu, ts, tcu, tcs;
clock_t gu, gs, gcu, gcs;
ap_generation_t mpm_generation, worker_generation; #ifdef HAVE_TIMES float tick; int times_per_thread; #endif
if (strcmp(r->handler, STATUS_MAGIC_TYPE) && strcmp(r->handler, "server-status")) { return DECLINED;
}
/* * Simple table-driven form data set parser that lets you alter the header
*/
if (r->args) {
i = 0; while (status_options[i].id != STAT_OPT_END) { if ((loc = ap_strstr_c(r->args,
status_options[i].form_data_str)) != NULL) { switch (status_options[i].id) { case STAT_OPT_REFRESH: {
apr_size_t len = strlen(status_options[i].form_data_str); long t = 0;
if (*(loc + len ) == '=') {
t = atol(loc + len + 1);
}
apr_table_setn(r->headers_out,
status_options[i].hdr_out_str,
apr_ltoa(r->pool, t < 1 ? 10 : t)); break;
} case STAT_OPT_NOTABLE:
no_table_report = 1; break; case STAT_OPT_AUTO:
ap_set_content_type_ex(r, "text/plain; charset=ISO-8859-1", 1);
short_report = 1; break;
}
}
if (!ps_record->quiescing
&& ps_record->pid) { if (res == SERVER_READY) { if (ps_record->generation == mpm_generation)
idle++; if (is_async)
thread_idle_buffer[i]++;
} elseif (res != SERVER_DEAD &&
res != SERVER_STARTING &&
res != SERVER_IDLE_KILL) { if (res == SERVER_GRACEFUL) {
graceful++; if (is_async)
thread_graceful_buffer[i]++;
} else {
busy++; if (is_async)
thread_busy_buffer[i]++;
}
}
}
/* XXX what about the counters for quiescing/seg faulted * processes? should they be counted or not? GLA
*/ if (ap_extended_status) {
lres = ws_record->access_count;
bytes = ws_record->bytes_served;
if (!no_table_report) {
ap_rputs("</table>\n \
<hr /> \
<table>\n \
<tr><th>Srv</th><td>Child Server number - generation</td></tr>\n \
<tr><th>PID</th><td>OS process ID</td></tr>\n \
<tr><th>Acc</th><td>Number of accesses this connection / this child / this slot</td></tr>\n \
<tr><th>M</th><td>Mode of operation</td></tr>\n"
#ifdef HAVE_TIMES "<tr><th>CPU</th><td>CPU usage, number of seconds</td></tr>\n" #endif
"<tr><th>SS</th><td>Seconds since beginning of most recent request</td></tr>\n \
<tr><th>Req</th><td>Milliseconds required to process most recent request</td></tr>\n \
<tr><th>Dur</th><td>Sum of milliseconds required to process all requests</td></tr>\n \
<tr><th>Conn</th><td>Kilobytes transferred this connection</td></tr>\n \
<tr><th>Child</th><td>Megabytes transferred this child</td></tr>\n \
<tr><th>Slot</th><td>Total megabytes transferred this slot</td></tr>\n \
</table>\n", r);
}
} /* if (ap_extended_status && !short_report) */ else {
if (!short_report) {
ap_rputs("<hr />To obtain a full report with current status " "information you need to use the " "<code>ExtendedStatus On</code> directive.\n", r);
}
}
{ /* Run extension hooks to insert extra content. */ int flags =
(short_report ? AP_STATUS_SHORT : 0) |
(no_table_report ? AP_STATUS_NOTABLE : 0) |
(ap_extended_status ? AP_STATUS_EXTENDED : 0);
ap_run_status_hook(r, flags);
}
if (!short_report) {
ap_rputs(ap_psignature("<hr />\n",r), r);
ap_rputs("</body></html>\n", r);
}
return 0;
}
staticint status_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
{ /* When mod_status is loaded, default our ExtendedStatus to 'on' * other modules which prefer verbose scoreboards may play a similar game. * If left to their own requirements, mpm modules can make do with simple * scoreboard entries.
*/
ap_extended_status = 1; return OK;
}
staticint status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
server_rec *s)
{
status_flags[SERVER_DEAD] = '.'; /* We don't want to assume these are in */
status_flags[SERVER_READY] = '_'; /* any particular order in scoreboard.h */
status_flags[SERVER_STARTING] = 'S';
status_flags[SERVER_BUSY_READ] = 'R';
status_flags[SERVER_BUSY_WRITE] = 'W';
status_flags[SERVER_BUSY_KEEPALIVE] = 'K';
status_flags[SERVER_BUSY_LOG] = 'L';
status_flags[SERVER_BUSY_DNS] = 'D';
status_flags[SERVER_CLOSING] = 'C';
status_flags[SERVER_GRACEFUL] = 'G';
status_flags[SERVER_IDLE_KILL] = 'I';
status_flags[SERVER_DISABLED] = ' ';
ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
ap_mpm_query(AP_MPMQ_MAX_THREADS, &threads_per_child); /* work around buggy MPMs */ if (threads_per_child == 0)
threads_per_child = 1;
ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_servers);
ap_mpm_query(AP_MPMQ_IS_ASYNC, &is_async); return OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.