mod_status.c revision aa616c3b5a4aa59867472cddf7d8e63693808f0e
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz/* ====================================================================
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * The Apache Software License, Version 1.1
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * reserved.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * are met:
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * notice, this list of conditions and the following disclaimer in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the documentation and/or other materials provided with the
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * distribution.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh *
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * 3. The end-user documentation included with the redistribution,
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * if any, must include the following acknowledgment:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * "This product includes software developed by the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Apache Software Foundation (http://www.apache.org/)."
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * Alternately, this acknowledgment may appear in the software itself,
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * if and wherever such third-party acknowledgments normally appear.
1b21d7b3d97def358b2e923655edeb16613a1c31gstein *
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * 4. The names "Apache" and "Apache Software Foundation" must
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * not be used to endorse or promote products derived from this
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * software without prior written permission. For written
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * permission, please contact apache@apache.org.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
2d71630471d1c23f0137309e3c3957c633ecbfd6rbb * 5. Products derived from this software may not be called "Apache",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * nor may "Apache" appear in their name, without prior written
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * permission of the Apache Software Foundation.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51af95bb51b5084e883bad250b2afa2838e9ceebfielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
d4f1d9c1ff112a8ab9bee31f196973761329b236rbb * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
7fae9cc4639013f3c04c085547256c68814aee8ftrawick * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7fae9cc4639013f3c04c085547256c68814aee8ftrawick * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7fae9cc4639013f3c04c085547256c68814aee8ftrawick * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
7fae9cc4639013f3c04c085547256c68814aee8ftrawick * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * SUCH DAMAGE.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ====================================================================
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This software consists of voluntary contributions made by many
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * individuals on behalf of the Apache Software Foundation. For more
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * information on the Apache Software Foundation, please see
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * <http://www.apache.org/>.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
785be1b6298010956622771c870ab3cd8ca57a2faaron * Portions of this software are based upon public domain software
785be1b6298010956622771c870ab3cd8ca57a2faaron * originally written at the National Center for Supercomputing Applications,
785be1b6298010956622771c870ab3cd8ca57a2faaron * University of Illinois, Urbana-Champaign.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Status Module. Display lots of internal data about how Apache is
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * performing and the state of all children processes.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * To enable this, add the following lines into any config file:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * <Location /server-status>
785be1b6298010956622771c870ab3cd8ca57a2faaron * SetHandler server-status
785be1b6298010956622771c870ab3cd8ca57a2faaron * </Location>
785be1b6298010956622771c870ab3cd8ca57a2faaron *
785be1b6298010956622771c870ab3cd8ca57a2faaron * You may want to protect this location by password or domain so no one
785be1b6298010956622771c870ab3cd8ca57a2faaron * else can look at it. Then you can access the statistics with a URL like:
785be1b6298010956622771c870ab3cd8ca57a2faaron *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * http://your_server_name/server-status
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
f4b96a996afbc46872f57ad1450e6ee1c8f13707jorton * /server-status - Returns page using tables
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * /server-status?notable - Returns page for browsers without table support
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * /server-status?refresh - Returns page with 1 second refresh
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * /server-status?refresh=6 - Returns page with refresh every 6 seconds
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * /server-status?auto - Returns page with data for automatic parsing
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Mark Cox, mark@ukweb.com, November 1995
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 12.11.95 Initial version for www.telescope.org
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 13.3.96 Updated to remove rprintf's [Mark]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 18.3.96 Make extra Scoreboard variables #definable
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 25.3.96 Make short report have full precision [Ben Laurie suggested]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 25.3.96 Show uptime better [Mark/Ben Laurie]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 09.4.96 Added message for non-STATUS compiled version
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 18.4.96 Added per child and per slot counters [Jim Jagielski]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * piece in short reports [Ben Laurie]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * extended STATUS is enabled) [George Burgyan/Jim J.]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 10.8.98 Allow for extended status info at runtime (no more STATUS)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * [Jim J.]
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define CORE_PRIVATE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "httpd.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_config.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_core.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_protocol.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_main.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "util_script.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include <time.h>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "scoreboard.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_log.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAVE_UNISTD_H
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include <unistd.h>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define APR_WANT_STRFUNC
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_want.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifdef NEXT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if (NX_CURRENT_COMPILER_RELEASE == 410)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifdef m68k
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define HZ 64
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define HZ 100
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
45acd673a68181802b112e97e84fa3813ddd3ec1stoddard#include <machine/param.h>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /* NEXT */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define STATUS_MAXLINE 64
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define KBYTE 1024
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define MBYTE 1048576L
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define GBYTE 1073741824L
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifndef DEFAULT_TIME_FORMAT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define STATUS_MAGIC_TYPE "application/x-httpd-status"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmmodule AP_MODULE_DECLARE_DATA status_module;
785be1b6298010956622771c870ab3cd8ca57a2faaron
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick/*
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *command-related code. This is here to prevent use of ExtendedStatus
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick * without status_module included.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawickstatic const char *set_extended_status(cmd_parms *cmd, void *dummy, int arg)
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick{
58fd79b56eb624bf011772994e9761d3c2e228c1orlikowski const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick if (err != NULL) {
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick return err;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_extended_status = arg;
785be1b6298010956622771c870ab3cd8ca57a2faaron return NULL;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding}
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawickstatic const command_rec status_module_cmds[] =
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames{
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF,
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames "\"On\" to enable extended status information, \"Off\" to disable"),
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames {NULL}
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames};
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames/* Format the number of bytes nicely */
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregamesstatic void format_byte_out(request_rec *r, unsigned long bytes)
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames{
e160b861b50a3a8dcc013b8cd3ef849fe777e52fgregames if (bytes < (5 * KBYTE))
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, "%d B", (int) bytes);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick else if (bytes < (MBYTE / 2))
560f6ac786d611b858b2bad932713d9e971f0716trawick ap_rprintf(r, "%.1f kB", (float) bytes / KBYTE);
560f6ac786d611b858b2bad932713d9e971f0716trawick else if (bytes < (GBYTE / 2))
560f6ac786d611b858b2bad932713d9e971f0716trawick ap_rprintf(r, "%.1f MB", (float) bytes / MBYTE);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick else
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, "%.1f GB", (float) bytes / GBYTE);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick}
7bf77d70b6830636bc36e6b76a228c301be23ff7brianp
7bf77d70b6830636bc36e6b76a228c301be23ff7brianpstatic void format_kbyte_out(request_rec *r, unsigned long kbytes)
7bf77d70b6830636bc36e6b76a228c301be23ff7brianp{
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick if (kbytes < KBYTE)
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, "%d kB", (int) kbytes);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick else if (kbytes < MBYTE)
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, "%.1f MB", (float) kbytes / KBYTE);
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "%.1f GB", (float) kbytes / MBYTE);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding}
eae32ab3fb398ca408bc2d45b22adf1b67a75471rbb
39b76a07959a0a332366c735a23894d9e8ed6872trawickstatic void show_time(request_rec *r, apr_interval_time_t tsecs)
de00ec7378227d05be63ecd2053ebbb01b940023jorton{
f3aa436e29aa30e29695a18b7f469dd66b39b7e4jorton int days, hrs, mins, secs;
de00ec7378227d05be63ecd2053ebbb01b940023jorton
de00ec7378227d05be63ecd2053ebbb01b940023jorton secs = tsecs % 60;
785be1b6298010956622771c870ab3cd8ca57a2faaron tsecs /= 60;
785be1b6298010956622771c870ab3cd8ca57a2faaron mins = tsecs % 60;
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick tsecs /= 60;
39b76a07959a0a332366c735a23894d9e8ed6872trawick hrs = tsecs % 24;
de00ec7378227d05be63ecd2053ebbb01b940023jorton days = tsecs / 24;
f3aa436e29aa30e29695a18b7f469dd66b39b7e4jorton if (days)
de00ec7378227d05be63ecd2053ebbb01b940023jorton ap_rprintf(r, " %d day%s", days, days == 1 ? "" : "s");
de00ec7378227d05be63ecd2053ebbb01b940023jorton if (hrs)
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, " %d hour%s", hrs, hrs == 1 ? "" : "s");
785be1b6298010956622771c870ab3cd8ca57a2faaron if (mins)
066877f1a045103acfdd376d48cdd473c33f409bdougm ap_rprintf(r, " %d minute%s", mins, mins == 1 ? "" : "s");
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick if (secs)
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, " %d second%s", secs, secs == 1 ? "" : "s");
f3aa436e29aa30e29695a18b7f469dd66b39b7e4jorton}
74b39333600dee3260355ad3a06e36ef6c61c8f1dreid
74b39333600dee3260355ad3a06e36ef6c61c8f1dreid/* Main handler for x-httpd-status requests */
74b39333600dee3260355ad3a06e36ef6c61c8f1dreid
74b39333600dee3260355ad3a06e36ef6c61c8f1dreid/* ID values for command table */
97c78987224dcd037076d393aad1867c26b2c8cftrawick
97c78987224dcd037076d393aad1867c26b2c8cftrawick#define STAT_OPT_END -1
97c78987224dcd037076d393aad1867c26b2c8cftrawick#define STAT_OPT_REFRESH 0
97c78987224dcd037076d393aad1867c26b2c8cftrawick#define STAT_OPT_NOTABLE 1
97c78987224dcd037076d393aad1867c26b2c8cftrawick#define STAT_OPT_AUTO 2
97c78987224dcd037076d393aad1867c26b2c8cftrawick
97c78987224dcd037076d393aad1867c26b2c8cftrawickstruct stat_opt {
97c78987224dcd037076d393aad1867c26b2c8cftrawick int id;
97c78987224dcd037076d393aad1867c26b2c8cftrawick const char *form_data_str;
97c78987224dcd037076d393aad1867c26b2c8cftrawick const char *hdr_out_str;
97c78987224dcd037076d393aad1867c26b2c8cftrawick};
97c78987224dcd037076d393aad1867c26b2c8cftrawick
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic const struct stat_opt status_options[] = /* see #defines above */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding{
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding {STAT_OPT_REFRESH, "refresh", "Refresh"},
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding {STAT_OPT_NOTABLE, "notable", NULL},
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding {STAT_OPT_AUTO, "auto", NULL},
785be1b6298010956622771c870ab3cd8ca57a2faaron {STAT_OPT_END, NULL, NULL}
785be1b6298010956622771c870ab3cd8ca57a2faaron};
785be1b6298010956622771c870ab3cd8ca57a2faaron
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic char status_flags[SERVER_NUM_STATUS];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic int status_handler(request_rec *r)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding{
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *loc;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_time_t nowtime;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t up_time;
785be1b6298010956622771c870ab3cd8ca57a2faaron int j, i, res;
785be1b6298010956622771c870ab3cd8ca57a2faaron int ready = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron int busy = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron unsigned long count = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron unsigned long lres, bytes;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding unsigned long my_lres, my_bytes, conn_bytes;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding unsigned short conn_lres;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding unsigned long bcount = 0;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding unsigned long kbcount = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron long req_time;
785be1b6298010956622771c870ab3cd8ca57a2faaron#ifdef HAVE_TIMES
785be1b6298010956622771c870ab3cd8ca57a2faaron#ifdef _SC_CLK_TCK
785be1b6298010956622771c870ab3cd8ca57a2faaron float tick = sysconf(_SC_CLK_TCK);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding float tick = HZ;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int short_report = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron int no_table_report = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron worker_score ws_record;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding process_score ps_record;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char stat_buffer[HARD_SERVER_LIMIT * HARD_THREAD_LIMIT];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding pid_t pid_buffer[HARD_SERVER_LIMIT * HARD_THREAD_LIMIT];
785be1b6298010956622771c870ab3cd8ca57a2faaron clock_t tu, ts, tcu, tcs;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *vhost;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (strcmp(r->handler, STATUS_MAGIC_TYPE) && strcmp(r->handler, "server-status")) {
f4b96a996afbc46872f57ad1450e6ee1c8f13707jorton return DECLINED;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding nowtime = apr_time_now();
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding tu = ts = tcu = tcs = 0;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (!ap_exists_scoreboard_image()) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "Server status unavailable in inetd mode");
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return HTTP_INTERNAL_SERVER_ERROR;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding r->allowed = (1 << M_GET);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (r->method_number != M_GET)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return DECLINED;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding r->content_type = "text/html";
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /*
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Simple table-driven form data set parser that lets you alter the header
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
785be1b6298010956622771c870ab3cd8ca57a2faaron if (r->args) {
785be1b6298010956622771c870ab3cd8ca57a2faaron i = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron while (status_options[i].id != STAT_OPT_END) {
785be1b6298010956622771c870ab3cd8ca57a2faaron if ((loc = ap_strstr_c(r->args, status_options[i].form_data_str)) != NULL) {
785be1b6298010956622771c870ab3cd8ca57a2faaron switch (status_options[i].id) {
785be1b6298010956622771c870ab3cd8ca57a2faaron case STAT_OPT_REFRESH:
785be1b6298010956622771c870ab3cd8ca57a2faaron if (*(loc + strlen(status_options[i].form_data_str)) == '='
785be1b6298010956622771c870ab3cd8ca57a2faaron && atol(loc + strlen(status_options[i].form_data_str)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding + 1) > 0)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_table_set(r->headers_out,
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm status_options[i].hdr_out_str,
785be1b6298010956622771c870ab3cd8ca57a2faaron loc + strlen(status_options[i].hdr_out_str) + 1);
785be1b6298010956622771c870ab3cd8ca57a2faaron else
785be1b6298010956622771c870ab3cd8ca57a2faaron apr_table_set(r->headers_out,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_options[i].hdr_out_str, "1");
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case STAT_OPT_NOTABLE:
785be1b6298010956622771c870ab3cd8ca57a2faaron no_table_report = 1;
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case STAT_OPT_AUTO:
785be1b6298010956622771c870ab3cd8ca57a2faaron r->content_type = "text/plain";
785be1b6298010956622771c870ab3cd8ca57a2faaron short_report = 1;
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm i++;
785be1b6298010956622771c870ab3cd8ca57a2faaron }
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (r->header_only)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return 0;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* ap_sync_scoreboard_image(); */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int indx = (i * HARD_THREAD_LIMIT) + j;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ws_record = ap_scoreboard_image->servers[i][j];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ps_record = ap_scoreboard_image->parent[i];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding res = ws_record.status;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding stat_buffer[indx] = status_flags[res];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding pid_buffer[indx] = ps_record.pid;
a7ed9c525f9460187f327cea953bf90ecf1bdc51gstein if (res == SERVER_READY)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ready++;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding else if (res != SERVER_DEAD)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding busy++;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ap_extended_status) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding lres = ws_record.access_count;
a7ed9c525f9460187f327cea953bf90ecf1bdc51gstein bytes = ws_record.bytes_served;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) {
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick#ifdef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding tu += ws_record.times.tms_utime;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick ts += ws_record.times.tms_stime;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick tcu += ws_record.times.tms_cutime;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick tcs += ws_record.times.tms_cstime;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick#endif /* HAVE_TIMES */
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick count += lres;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick bcount += bytes;
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick if (bcount >= KBYTE) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding kbcount += (bcount >> 10);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm bcount = bcount & 0x3ff;
785be1b6298010956622771c870ab3cd8ca57a2faaron }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* up_time in seconds */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding up_time = (apr_uint32_t) ((nowtime - ap_restart_time)/APR_USEC_PER_SEC);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (!short_report) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs(DOCTYPE_HTML_3_2
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "<HTML><HEAD>\n<TITLE>Apache Status</TITLE>\n</HEAD><BODY>\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<H1>Apache Server Status for ", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rvputs(r, ap_get_server_name(r), "</H1>\n\n", NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rvputs(r, "Server Version: ",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_get_server_version(), "<br>\n", NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rvputs(r, "Server Built: ",
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm ap_get_server_built(), "<br>\n<hr>\n", NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rvputs(r, "Current Time: ",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0), "<br>\n", NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rvputs(r, "Restart Time: ",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_ht_time(r->pool, ap_restart_time, DEFAULT_TIME_FORMAT, 0),
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "<br>\n", NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "Parent Server Generation: %d <br>\n", (int) ap_my_generation);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("Server uptime: ", r);
a7ed9c525f9460187f327cea953bf90ecf1bdc51gstein show_time(r, up_time);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("<br>\n", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ap_extended_status) {
f4b96a996afbc46872f57ad1450e6ee1c8f13707jorton if (short_report) {
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding count, kbcount);
785be1b6298010956622771c870ab3cd8ca57a2faaron
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick#ifdef HAVE_TIMES
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick /* Allow for OS/2 not having CPU stats */
39b76a07959a0a332366c735a23894d9e8ed6872trawick if (ts || tu || tcu || tcs)
8fd7c5046d164fb0959222497e5925dfc6a52ff3trawick ap_rprintf(r, "CPULoad: %g\n",
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick (tu + ts + tcu + tcs) / tick / up_time * 100.);
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick#endif
17f3ba69f65182426ad4e568bb2d6f192ccd2ed5trawick
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "Uptime: %ld\n", (long) (up_time));
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (up_time > 0)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "ReqPerSec: %g\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (float) count / (float) up_time);
8f8ec0957334f50b7ac11359f90490ee467258eedreid
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (up_time > 0)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "BytesPerSec: %g\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding KBYTE * (float) kbcount / (float) up_time);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (count > 0)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "BytesPerReq: %g\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding KBYTE * (float) kbcount / (float) count);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
785be1b6298010956622771c870ab3cd8ca57a2faaron else { /* !short_report */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding format_kbyte_out(r, kbcount);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifdef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Allow for OS/2 not having CPU stats */
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("<br>\n", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding tu / tick, ts / tick, tcu / tick, tcs / tick);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ts || tu || tcu || tcs)
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick ap_rprintf(r, " - %.3g%% CPU load",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (tu + ts + tcu + tcs) / tick / up_time * 100.);
39b76a07959a0a332366c735a23894d9e8ed6872trawick#endif
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<br>\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if (up_time > 0)
39b76a07959a0a332366c735a23894d9e8ed6872trawick ap_rprintf(r, "%.3g requests/sec - ",
6b38fca3ec543a0f72efd5683e91a0b30fc752d1trawick (float) count / (float) up_time);
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron if (up_time > 0) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf format_byte_out(r, KBYTE * (float) kbcount / (float) up_time);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("/second - ", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron }
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if (count > 0) {
785be1b6298010956622771c870ab3cd8ca57a2faaron format_byte_out(r, KBYTE * (float) kbcount / (float) count);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("/request", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf }
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<br>\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron } /* short_report */
785be1b6298010956622771c870ab3cd8ca57a2faaron } /* ap_extended_status */
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
066877f1a045103acfdd376d48cdd473c33f409bdougm if (!short_report)
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, "\n%d requests currently being processed, %d idle servers\n"
785be1b6298010956622771c870ab3cd8ca57a2faaron ,busy, ready);
785be1b6298010956622771c870ab3cd8ca57a2faaron else
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rprintf(r, "BusyServers: %d\nIdleServers: %d\n", busy, ready);
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron /* send the scoreboard 'table' out */
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron if (!short_report)
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<PRE>", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron else
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("Scoreboard: ", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf int indx = (i * HARD_THREAD_LIMIT) + j;
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputc(stat_buffer[indx], r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if ((indx % STATUS_MAXLINE == (STATUS_MAXLINE - 1)) && !short_report)
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf }
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf }
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
066877f1a045103acfdd376d48cdd473c33f409bdougm if (short_report)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron else {
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("</PRE>\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("Scoreboard Key: <br>\n", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("\"<B><code>_</code></B>\" Waiting for Connection, \n", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("\"<B><code>S</code></B>\" Starting up, \n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\"<B><code>R</code></B>\" Reading Request,<BR>\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\"<B><code>W</code></B>\" Sending Reply, \n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\"<B><code>K</code></B>\" Keepalive (read), \n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\"<B><code>D</code></B>\" DNS Lookup,<BR>\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("\"<B><code>L</code></B>\" Logging, \n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("\"<B><code>G</code></B>\" Gracefully finishing, \n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("\"<B><code>I</code></B>\" Idle cleanup of worker, \n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("\"<B><code>.</code></B>\" Open slot with no current process<P>\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("<P>\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if (!ap_extended_status) {
785be1b6298010956622771c870ab3cd8ca57a2faaron int j;
785be1b6298010956622771c870ab3cd8ca57a2faaron int k = 0;
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("PID Key: <br>\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("<PRE>\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf int indx = (i * HARD_THREAD_LIMIT) + j;
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if (stat_buffer[indx] != '.') {
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, " %" APR_OS_PROC_T_FMT
785be1b6298010956622771c870ab3cd8ca57a2faaron " in state: %c ", pid_buffer[i],
785be1b6298010956622771c870ab3cd8ca57a2faaron stat_buffer[indx]);
785be1b6298010956622771c870ab3cd8ca57a2faaron if (++k >= 3) {
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron k = 0;
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick } else
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs(",", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron }
785be1b6298010956622771c870ab3cd8ca57a2faaron }
785be1b6298010956622771c870ab3cd8ca57a2faaron }
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("</PRE>\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron }
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf }
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf
785be1b6298010956622771c870ab3cd8ca57a2faaron if (ap_extended_status) {
785be1b6298010956622771c870ab3cd8ca57a2faaron if (!short_report) {
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf if (no_table_report)
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r);
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf else
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf#ifndef HAVE_TIMES
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf /* Allow for OS/2 not having CPU stats */
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf 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);
785be1b6298010956622771c870ab3cd8ca57a2faaron#else
785be1b6298010956622771c870ab3cd8ca57a2faaron 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);
785be1b6298010956622771c870ab3cd8ca57a2faaron#endif
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick }
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
785be1b6298010956622771c870ab3cd8ca57a2faaron for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
785be1b6298010956622771c870ab3cd8ca57a2faaron ws_record = ap_scoreboard_image->servers[i][j];
785be1b6298010956622771c870ab3cd8ca57a2faaron ps_record = ap_scoreboard_image->parent[i];
785be1b6298010956622771c870ab3cd8ca57a2faaron vhost = ws_record.vhostrec;
785be1b6298010956622771c870ab3cd8ca57a2faaron if (ps_record.generation != ap_my_generation) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding vhost = NULL;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if defined(NO_GETTIMEOFDAY)
ebc18d48bea83ee5ed7a1b4e30007e5192539829wrowe#ifdef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ws_record.start_time == (clock_t) 0)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /* HAVE_TIMES */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding req_time = 0L;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifdef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding else {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding req_time = ws_record.stop_time - ws_record.start_time;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding req_time = (req_time * 1000) / (int) tick;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /* HAVE_TIMES */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ws_record.start_time == 0L &&
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ws_record.start_time == 0L)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding req_time = 0L;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding else
785be1b6298010956622771c870ab3cd8ca57a2faaron req_time =
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ((ws_record.stop_time - ws_record.start_time) * 1000) +
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ((ws_record.stop_time - ws_record.start_time) / 1000);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (req_time < 0L)
785be1b6298010956622771c870ab3cd8ca57a2faaron req_time = 0L;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding lres = ws_record.access_count;
f4b96a996afbc46872f57ad1450e6ee1c8f13707jorton my_lres = ws_record.my_access_count;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conn_lres = ws_record.conn_count;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding bytes = ws_record.bytes_served;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding my_bytes = ws_record.my_bytes_served;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conn_bytes = ws_record.conn_bytes;
5f08a022a210f4e511561e89f500621a15e6177dtrawick if (lres != 0 || (ws_record.status != SERVER_READY
785be1b6298010956622771c870ab3cd8ca57a2faaron && ws_record.status != SERVER_DEAD)) {
785be1b6298010956622771c870ab3cd8ca57a2faaron if (!short_report) {
785be1b6298010956622771c870ab3cd8ca57a2faaron if (no_table_report) {
5f08a022a210f4e511561e89f500621a15e6177dtrawick if (ws_record.status == SERVER_DEAD)
5f08a022a210f4e511561e89f500621a15e6177dtrawick ap_rprintf(r,
785be1b6298010956622771c870ab3cd8ca57a2faaron "<b>Server %d-%d</b> (-): %d|%lu|%lu [",
785be1b6298010956622771c870ab3cd8ca57a2faaron i, (int) ps_record.generation, (int) conn_lres,
785be1b6298010956622771c870ab3cd8ca57a2faaron my_lres, lres);
785be1b6298010956622771c870ab3cd8ca57a2faaron else
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r,
785be1b6298010956622771c870ab3cd8ca57a2faaron "<b>Server %d-%d</b> (%" APR_OS_PROC_T_FMT
785be1b6298010956622771c870ab3cd8ca57a2faaron "): %d|%lu|%lu [",
785be1b6298010956622771c870ab3cd8ca57a2faaron i, (int) ps_record.generation,
785be1b6298010956622771c870ab3cd8ca57a2faaron ps_record.pid,
785be1b6298010956622771c870ab3cd8ca57a2faaron (int) conn_lres, my_lres, lres);
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron switch (ws_record.status) {
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_READY:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("Ready", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding case SERVER_STARTING:
f4b96a996afbc46872f57ad1450e6ee1c8f13707jorton ap_rputs("Starting", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding case SERVER_BUSY_READ:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("<b>Read</b>", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding case SERVER_BUSY_WRITE:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("<b>Write</b>", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_BUSY_KEEPALIVE:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<b>Keepalive</b>", r);
900127764fb985c340ee4979cac97146a330c694trawick break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_BUSY_LOG:
900127764fb985c340ee4979cac97146a330c694trawick ap_rputs("<b>Logging</b>", r);
900127764fb985c340ee4979cac97146a330c694trawick break;
900127764fb985c340ee4979cac97146a330c694trawick case SERVER_BUSY_DNS:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<b>DNS lookup</b>", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_DEAD:
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick ap_rputs("Dead", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_GRACEFUL:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("Graceful", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron default:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("?STATE?", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron }
785be1b6298010956622771c870ab3cd8ca57a2faaron#ifndef HAVE_TIMES
785be1b6298010956622771c870ab3cd8ca57a2faaron /* Allow for OS/2 not having CPU stats */
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, "]\n %.0f %ld (",
785be1b6298010956622771c870ab3cd8ca57a2faaron#else
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, "] u%g s%g cu%g cs%g\n %ld %ld (",
785be1b6298010956622771c870ab3cd8ca57a2faaron ws_record.times.tms_utime / tick,
785be1b6298010956622771c870ab3cd8ca57a2faaron ws_record.times.tms_stime / tick,
785be1b6298010956622771c870ab3cd8ca57a2faaron ws_record.times.tms_cutime / tick,
785be1b6298010956622771c870ab3cd8ca57a2faaron ws_record.times.tms_cstime / tick,
785be1b6298010956622771c870ab3cd8ca57a2faaron#endif
785be1b6298010956622771c870ab3cd8ca57a2faaron (long)((nowtime - ws_record.last_used) / APR_USEC_PER_SEC),
785be1b6298010956622771c870ab3cd8ca57a2faaron (long) req_time);
785be1b6298010956622771c870ab3cd8ca57a2faaron format_byte_out(r, conn_bytes);
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick ap_rputs("|", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron format_byte_out(r, my_bytes);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("|", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron format_byte_out(r, bytes);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs(")\n", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, " <i>%s {%s}</i> <b>[%s]</b><br>\n\n",
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_escape_html(r->pool, ws_record.client),
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_escape_html(r->pool, ws_record.request),
785be1b6298010956622771c870ab3cd8ca57a2faaron vhost ? ap_escape_html(r->pool,
785be1b6298010956622771c870ab3cd8ca57a2faaron vhost->server_hostname) : "(unavailable)");
785be1b6298010956622771c870ab3cd8ca57a2faaron }
785be1b6298010956622771c870ab3cd8ca57a2faaron else { /* !no_table_report */
785be1b6298010956622771c870ab3cd8ca57a2faaron if (ws_record.status == SERVER_DEAD)
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r,
785be1b6298010956622771c870ab3cd8ca57a2faaron "<tr><td><b>%d-%d</b><td>-<td>%d/%lu/%lu",
785be1b6298010956622771c870ab3cd8ca57a2faaron i, (int) ps_record.generation,
785be1b6298010956622771c870ab3cd8ca57a2faaron (int) conn_lres, my_lres, lres);
785be1b6298010956622771c870ab3cd8ca57a2faaron else
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r,
785be1b6298010956622771c870ab3cd8ca57a2faaron "<tr><td><b>%d-%d</b><td>%" APR_OS_PROC_T_FMT
785be1b6298010956622771c870ab3cd8ca57a2faaron "<td>%d/%lu/%lu",
785be1b6298010956622771c870ab3cd8ca57a2faaron i, (int) ps_record.generation,
785be1b6298010956622771c870ab3cd8ca57a2faaron ps_record.pid, (int) conn_lres,
785be1b6298010956622771c870ab3cd8ca57a2faaron my_lres, lres);
785be1b6298010956622771c870ab3cd8ca57a2faaron
785be1b6298010956622771c870ab3cd8ca57a2faaron switch (ws_record.status) {
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_READY:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td>_", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_STARTING:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td><b>S</b>", r);
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding case SERVER_BUSY_READ:
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick ap_rputs("<td><b>R</b>", r);
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick break;
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick case SERVER_BUSY_WRITE:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td><b>W</b>", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_BUSY_KEEPALIVE:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td><b>K</b>", r);
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick break;
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick case SERVER_BUSY_LOG:
066877f1a045103acfdd376d48cdd473c33f409bdougm ap_rputs("<td><b>L</b>", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick case SERVER_BUSY_DNS:
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick ap_rputs("<td><b>D</b>", r);
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick break;
8a261a9f7d18d1e862d63f68e93f288d3e1f0d94trawick case SERVER_DEAD:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td>.", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
785be1b6298010956622771c870ab3cd8ca57a2faaron case SERVER_GRACEFUL:
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rputs("<td>G", r);
785be1b6298010956622771c870ab3cd8ca57a2faaron break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding default:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("<td>?", r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding break;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding }
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifndef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Allow for OS/2 not having CPU stats */
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, "\n<td>%.0f<td>%ld",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
b88f887ed5554d9050d97f9a56a89ae62bdbd906fanf ap_rprintf(r, "\n<td>%.2f<td>%ld<td>%ld",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (ws_record.times.tms_utime +
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ws_record.times.tms_stime +
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ws_record.times.tms_cutime +
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ws_record.times.tms_cstime) / tick,
bbbf8f0e622ad5a37ccf70f35660fc755575278arbb#endif
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm (long)((nowtime - ws_record.last_used) / APR_USEC_PER_SEC),
066877f1a045103acfdd376d48cdd473c33f409bdougm (long) req_time);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_rprintf(r, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (float) bytes / MBYTE);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (ws_record.status == SERVER_BUSY_READ)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "<td>?<td nowrap>?<td nowrap>..reading.. </tr>\n\n");
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rprintf(r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n",
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf ap_escape_html(r->pool, ws_record.client),
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf vhost ? ap_escape_html(r->pool,
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf vhost->server_hostname) : "(unavailable)",
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf ap_escape_html(r->pool, ws_record.request));
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf } /* no_table_report */
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf } /* !short_report */
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf } /* if (<active child>) */
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf } /* for () */
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf }
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf if (!(short_report || no_table_report)) {
91583d2e9c0550f539ea6f4dedf051979ad1ad88fanf#ifndef HAVE_TIMES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_rputs("</table>\n \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<hr> \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<table>\n \
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick<tr><th>Srv<td>Child Server number - generation\n \
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf<tr><th>PID<td>OS process ID\n \
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick<tr><th>Acc<td>Number of accesses this connection / this child / this slot\n \
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick<tr><th>M<td>Mode of operation\n \
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf<tr><th>SS<td>Seconds since beginning of most recent request\n \
9c518951a46c7a12e20876827bb2e84ef87d3c11jerenkrantz<tr><th>Req<td>Milliseconds required to process most recent request\n \
9c518951a46c7a12e20876827bb2e84ef87d3c11jerenkrantz<tr><th>Conn<td>Kilobytes transferred this connection\n \
9c518951a46c7a12e20876827bb2e84ef87d3c11jerenkrantz<tr><th>Child<td>Megabytes transferred this child\n \
9c518951a46c7a12e20876827bb2e84ef87d3c11jerenkrantz<tr><th>Slot<td>Total megabytes transferred this slot\n \
9c518951a46c7a12e20876827bb2e84ef87d3c11jerenkrantz</table>\n", r);
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick#else
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick ap_rputs("</table>\n \
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick<hr> \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<table>\n \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<tr><th>Srv<td>Child Server number - generation\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>PID<td>OS process ID\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>Acc<td>Number of accesses this connection / this child / this slot\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>M<td>Mode of operation\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>CPU<td>CPU usage, number of seconds\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>SS<td>Seconds since beginning of most recent request\n \
d40fc22d54d5969fa330e4983cf07f450f7029cebrianp<tr><th>Req<td>Milliseconds required to process most recent request\n \
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick<tr><th>Conn<td>Kilobytes transferred this connection\n \
644be6f54749d2d9950d2c4d2ac448f7af016d26martin<tr><th>Child<td>Megabytes transferred this child\n \
644be6f54749d2d9950d2c4d2ac448f7af016d26martin<tr><th>Slot<td>Total megabytes transferred this slot\n \
43c3e6a4b559b76b750c245ee95e2782c15b4296jim</table>\n", r);
644be6f54749d2d9950d2c4d2ac448f7af016d26martin#endif
43c3e6a4b559b76b750c245ee95e2782c15b4296jim }
43c3e6a4b559b76b750c245ee95e2782c15b4296jim
644be6f54749d2d9950d2c4d2ac448f7af016d26martin } else {
43c3e6a4b559b76b750c245ee95e2782c15b4296jim
644be6f54749d2d9950d2c4d2ac448f7af016d26martin if (!short_report) {
0db1b9810f06c0e3c537e0e0dfbc30160c308526trawick ap_rputs("<hr>To obtain a full report with current status information ", r);
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick ap_rputs("you need to use the <code>ExtendedStatus On</code> directive. \n", r);
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick }
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick }
71715c646d5231de578431f8961e711764b899d3fanf
3c8b3749225668f06abbb2b023a833a2cef46931brianp if (!short_report) {
3c8b3749225668f06abbb2b023a833a2cef46931brianp ap_rputs(ap_psignature("<HR>\n",r), r);
3c8b3749225668f06abbb2b023a833a2cef46931brianp ap_rputs("</BODY></HTML>\n", r);
3c8b3749225668f06abbb2b023a833a2cef46931brianp }
ccad4fdc6c75a352157a413bd3bbaf4d0c8a6f72brianp
785be1b6298010956622771c870ab3cd8ca57a2faaron return 0;
ccad4fdc6c75a352157a413bd3bbaf4d0c8a6f72brianp}
785be1b6298010956622771c870ab3cd8ca57a2faaron
3c8b3749225668f06abbb2b023a833a2cef46931brianp
3c8b3749225668f06abbb2b023a833a2cef46931brianpstatic void status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
3c8b3749225668f06abbb2b023a833a2cef46931brianp{
785be1b6298010956622771c870ab3cd8ca57a2faaron status_flags[SERVER_DEAD] = '.'; /* We don't want to assume these are in */
785be1b6298010956622771c870ab3cd8ca57a2faaron status_flags[SERVER_READY] = '_'; /* any particular order in scoreboard.h */
785be1b6298010956622771c870ab3cd8ca57a2faaron status_flags[SERVER_STARTING] = 'S';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_BUSY_READ] = 'R';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_BUSY_WRITE] = 'W';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_BUSY_KEEPALIVE] = 'K';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_BUSY_LOG] = 'L';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_BUSY_DNS] = 'D';
3c48210f662a2ab8ed90708989e04c09aae33cb2trawick status_flags[SERVER_GRACEFUL] = 'G';
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_flags[SERVER_IDLE_KILL] = 'I';
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf}
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanfstatic void register_hooks(apr_pool_t *p)
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf{
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE);
785be1b6298010956622771c870ab3cd8ca57a2faaron ap_hook_post_config(status_init, NULL, NULL, APR_HOOK_MIDDLE);
3926b3b7716683a1241c1ff6f8dd2f9c5073665afanf}
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingmodule AP_MODULE_DECLARE_DATA status_module =
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding{
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding STANDARD20_MODULE_STUFF,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding NULL, /* dir config creater */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding NULL, /* dir merger --- default is to override */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding NULL, /* server config */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm NULL, /* merge server config */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_module_cmds, /* command table */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding register_hooks /* register_hooks */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
785be1b6298010956622771c870ab3cd8ca57a2faaron
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding