mod_status.c revision 3568de757bac0b47256647504c186d17ca272f85
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz/* ====================================================================
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * The Apache Software License, Version 1.1
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Copyright (c) 2000 The Apache Software Foundation. All rights
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Redistribution and use in source and binary forms, with or without
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * modification, are permitted provided that the following conditions
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 1. Redistributions of source code must retain the above copyright
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * notice, this list of conditions and the following disclaimer.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 2. Redistributions in binary form must reproduce the above copyright
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * notice, this list of conditions and the following disclaimer in
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * the documentation and/or other materials provided with the
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * distribution.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 3. The end-user documentation included with the redistribution,
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * if any, must include the following acknowledgment:
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * "This product includes software developed by the
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Apache Software Foundation (http://www.apache.org/)."
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Alternately, this acknowledgment may appear in the software itself,
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * if and wherever such third-party acknowledgments normally appear.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 4. The names "Apache" and "Apache Software Foundation" must
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * not be used to endorse or promote products derived from this
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * software without prior written permission. For written
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * permission, please contact apache@apache.org.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 5. Products derived from this software may not be called "Apache",
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * nor may "Apache" appear in their name, without prior written
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * permission of the Apache Software Foundation.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * SUCH DAMAGE.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * ====================================================================
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * This software consists of voluntary contributions made by many
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * individuals on behalf of the Apache Software Foundation. For more
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * information on the Apache Software Foundation, please see
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Portions of this software are based upon public domain software
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * originally written at the National Center for Supercomputing Applications,
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * University of Illinois, Urbana-Champaign.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz/* Status Module. Display lots of internal data about how Apache is
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * performing and the state of all children processes.
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * To enable this, add the following lines into any config file:
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * <Location /server-status>
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * SetHandler server-status
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * </Location>
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * You may want to protect this location by password or domain so no one
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * else can look at it. Then you can access the statistics with a URL like:
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * /server-status - Returns page using tables
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * /server-status?notable - Returns page for browsers without table support
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * /server-status?refresh - Returns page with 1 second refresh
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * /server-status?refresh=6 - Returns page with refresh every 6 seconds
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * /server-status?auto - Returns page with data for automatic parsing
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * Mark Cox, mark@ukweb.com, November 1995
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 12.11.95 Initial version for www.telescope.org
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 13.3.96 Updated to remove rprintf's [Mark]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 18.3.96 Make extra Scoreboard variables #definable
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 25.3.96 Make short report have full precision [Ben Laurie suggested]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 25.3.96 Show uptime better [Mark/Ben Laurie]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 09.4.96 Added message for non-STATUS compiled version
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 18.4.96 Added per child and per slot counters [Jim Jagielski]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * piece in short reports [Ben Laurie]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * extended STATUS is enabled) [George Burgyan/Jim J.]
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz * 10.8.98 Allow for extended status info at runtime (no more STATUS)
7af4df794a0e0f0cb927bd9371556ad098308983Ewaryst Schulz#endif /* NEXT */
#ifndef DEFAULT_TIME_FORMAT
return err;
return NULL;
{NULL}
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 j, i, res;
int ready = 0;
int busy = 0;
unsigned long count = 0;
unsigned short conn_lres;
unsigned long bcount = 0;
unsigned long kbcount = 0;
long req_time;
#ifndef NO_TIMES
#ifdef _SC_CLK_TCK
int short_report = 0;
int no_table_report = 0;
return DECLINED;
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:
if (r->header_only)
for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
ready++;
busy++;
if (ap_extended_status) {
#ifndef NO_TIMES
if (!short_report) {
if (ap_extended_status) {
if (short_report) {
#ifndef NO_TIMES
if (up_time > 0)
if (up_time > 0)
if (count > 0)
#ifndef NO_TIMES
if (up_time > 0)
if (up_time > 0) {
if (count > 0) {
if (!short_report)
if (!short_report)
for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
if (short_report)
if (!ap_extended_status) {
for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
for (k = 0; k < HARD_THREAD_LIMIT; ++k) {
if (ap_extended_status) {
if (!short_report) {
if (no_table_report)
#ifdef NO_TIMES
ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r);
ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r);
for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
#if defined(NO_GETTIMEOFDAY)
#ifndef NO_TIMES
req_time = 0L;
#ifndef NO_TIMES
req_time = 0L;
req_time =
if (req_time < 0L)
req_time = 0L;
if (!short_report) {
if (no_table_report) {
ap_rprintf(r,
ap_rprintf(r,
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_DEAD:
case SERVER_GRACEFUL:
#ifdef NO_TIMES
#ifdef OPTIMIZE_TIMEOUTS
(long) req_time);
ap_rprintf(r,
ap_rprintf(r,
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_DEAD:
case SERVER_GRACEFUL:
#ifdef NO_TIMES
#ifdef OPTIMIZE_TIMEOUTS
(long) req_time);
ap_rprintf(r,
ap_rprintf(r,
#ifdef NO_TIMES
if (!short_report) {
if (!short_report) {