mod_status.c revision 95e04bdfdb8fbb70158afd18bbf0acc340615d65
b43f840409794ed298e8634f6284741f193b6c4ftakashi/* Licensed to the Apache Software Foundation (ASF) under one or more
b43f840409794ed298e8634f6284741f193b6c4ftakashi * contributor license agreements. See the NOTICE file distributed with
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * this work for additional information regarding copyright ownership.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * The ASF licenses this file to You under the Apache License, Version 2.0
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * (the "License"); you may not use this file except in compliance with
b43f840409794ed298e8634f6284741f193b6c4ftakashi * the License. You may obtain a copy of the License at
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * Unless required by applicable law or agreed to in writing, software
b43f840409794ed298e8634f6284741f193b6c4ftakashi * distributed under the License is distributed on an "AS IS" BASIS,
b43f840409794ed298e8634f6284741f193b6c4ftakashi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
2e545ce2450a9953665f701bb05350f0d3f26275nd * limitations under the License.
b43f840409794ed298e8634f6284741f193b6c4ftakashi/* Status Module. Display lots of internal data about how Apache is
b43f840409794ed298e8634f6284741f193b6c4ftakashi * performing and the state of all children processes.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * To enable this, add the following lines into any config file:
b43f840409794ed298e8634f6284741f193b6c4ftakashi * <Location /server-status>
b43f840409794ed298e8634f6284741f193b6c4ftakashi * SetHandler server-status
b43f840409794ed298e8634f6284741f193b6c4ftakashi * </Location>
b43f840409794ed298e8634f6284741f193b6c4ftakashi * You may want to protect this location by password or domain so no one
b43f840409794ed298e8634f6284741f193b6c4ftakashi * else can look at it. Then you can access the statistics with a URL like:
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * /server-status - Returns page using tables
b43f840409794ed298e8634f6284741f193b6c4ftakashi * /server-status?notable - Returns page for browsers without table support
b43f840409794ed298e8634f6284741f193b6c4ftakashi * /server-status?refresh - Returns page with 1 second refresh
b43f840409794ed298e8634f6284741f193b6c4ftakashi * /server-status?refresh=6 - Returns page with refresh every 6 seconds
b43f840409794ed298e8634f6284741f193b6c4ftakashi * /server-status?auto - Returns page with data for automatic parsing
b43f840409794ed298e8634f6284741f193b6c4ftakashi * Mark Cox, mark@ukweb.com, November 1995
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 12.11.95 Initial version for www.telescope.org
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 13.3.96 Updated to remove rprintf's [Mark]
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 18.3.96 Make extra Scoreboard variables #definable
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 25.3.96 Make short report have full precision [Ben Laurie suggested]
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 25.3.96 Show uptime better [Mark/Ben Laurie]
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 09.4.96 Added message for non-STATUS compiled version
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 18.4.96 Added per child and per slot counters [Jim Jagielski]
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar * piece in short reports [Ben Laurie]
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
b43f840409794ed298e8634f6284741f193b6c4ftakashi * extended STATUS is enabled) [George Burgyan/Jim J.]
b43f840409794ed298e8634f6284741f193b6c4ftakashi * 10.8.98 Allow for extended status info at runtime (no more STATUS)
727872d18412fc021f03969b8641810d8896820bhumbedooh#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
0d0ba3a410038e179b695446bb149cce6264e0abndstatic int server_limit, thread_limit, threads_per_child, max_servers,
0d0ba3a410038e179b695446bb149cce6264e0abnd/* Implement 'ap_run_status_hook'. */
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedoohAPR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook,
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd/* ugh... need to know if we're running with a pthread implementation
b43f840409794ed298e8634f6284741f193b6c4ftakashi * such as linuxthreads that treats individual threads as distinct
if (days)
if (hrs)
if (mins)
if (secs)
#define STAT_OPT_REFRESH 0
struct stat_opt {
int id;
const char *form_data_str;
const char *hdr_out_str;
const char *loc;
int ready;
int busy;
unsigned long count;
long req_time;
int short_report;
int no_table_report;
char *stat_buffer;
#ifdef HAVE_TIMES
float tick;
int times_per_thread;
return DECLINED;
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
#ifdef _SC_CLK_TCK
ready = 0;
busy = 0;
count = 0;
bcount = 0;
kbcount = 0;
short_report = 0;
no_table_report = 0;
if (is_async) {
if (!ap_exists_scoreboard_image()) {
return HTTP_INTERNAL_SERVER_ERROR;
return DECLINED;
if (r->args) {
case STAT_OPT_REFRESH: {
case STAT_OPT_NOTABLE:
case STAT_OPT_AUTO:
for (i = 0; i < server_limit; ++i) {
#ifdef HAVE_TIMES
if (is_async) {
thread_idle_buffer[i] = 0;
thread_busy_buffer[i] = 0;
for (j = 0; j < thread_limit; ++j) {
ready++;
if (is_async)
thread_idle_buffer[i]++;
busy++;
if (is_async) {
thread_idle_buffer[i]++;
thread_busy_buffer[i]++;
if (ap_extended_status) {
#ifdef HAVE_TIMES
if (times_per_thread) {
#ifdef HAVE_TIMES
if (!short_report) {
ap_loadavg_t t;
DEFAULT_TIME_FORMAT, 0),
(int)mpm_generation);
ap_get_loadavg(&t);
if (ap_extended_status) {
if (short_report) {
#ifdef HAVE_TIMES
if (up_time > 0) {
if (count > 0)
#ifdef HAVE_TIMES
if (up_time > 0) {
/ (float) up_time));
if (count > 0) {
/ (float) count));
if (!short_report)
if (!short_report)
if (is_async) {
connections = 0;
if (!short_report)
for (i = 0; i < server_limit; ++i) {
if (!short_report)
if (!short_report) {
if (!short_report)
written = 0;
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
&& !short_report)
written++;
if (short_report)
if (!ap_extended_status) {
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
if (no_table_report)
#ifdef HAVE_TIMES
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
req_time = 0L;
req_time = (long)
if (req_time < 0L)
req_time = 0L;
if (no_table_report) {
ap_rprintf(r,
i, (int)worker_generation,
ap_rprintf(r,
i, (int) worker_generation,
case SERVER_READY:
case SERVER_STARTING:
case SERVER_BUSY_READ:
case SERVER_BUSY_WRITE:
case SERVER_BUSY_KEEPALIVE:
case SERVER_BUSY_LOG:
case SERVER_BUSY_DNS:
case SERVER_CLOSING:
case SERVER_DEAD:
case SERVER_GRACEFUL:
case SERVER_IDLE_KILL:
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
(long) req_time);
ap_rprintf(r,
ap_rprintf(r,
i, (int)worker_generation,
ap_rprintf(r,
i, (int)worker_generation,
(int)conn_lres,
case SERVER_READY:
case SERVER_STARTING:
case SERVER_BUSY_READ:
case SERVER_BUSY_WRITE:
case SERVER_BUSY_KEEPALIVE:
case SERVER_BUSY_LOG:
case SERVER_BUSY_DNS:
case SERVER_CLOSING:
case SERVER_DEAD:
case SERVER_GRACEFUL:
case SERVER_IDLE_KILL:
ap_rprintf(r,
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
(long)req_time);
if (!no_table_report) {
#ifdef HAVE_TIMES
if (!short_report) {
int flags =
if (!short_report) {
return OK;
server_rec *s)
if (threads_per_child == 0)
return OK;
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES