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