mod_status.c revision 98cd3186185bb28ae6c95a3f159899fcf56a663f
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding/* ====================================================================
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * The Apache Software License, Version 1.1
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding *
bc8fd1b0b1afdf89b8d28eefa8cd74e26ba97986fielding * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * reserved.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Redistribution and use in source and binary forms, with or without
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * modification, are permitted provided that the following conditions
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * are met:
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 1. Redistributions of source code must retain the above copyright
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * notice, this list of conditions and the following disclaimer.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 2. Redistributions in binary form must reproduce the above copyright
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * notice, this list of conditions and the following disclaimer in
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * the documentation and/or other materials provided with the
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * distribution.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * 3. The end-user documentation included with the redistribution,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * if any, must include the following acknowledgment:
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * "This product includes software developed by the
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * Apache Software Foundation (http://www.apache.org/)."
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * Alternately, this acknowledgment may appear in the software itself,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * if and wherever such third-party acknowledgments normally appear.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * 4. The names "Apache" and "Apache Software Foundation" must
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * not be used to endorse or promote products derived from this
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * software without prior written permission. For written
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * permission, please contact apache@apache.org.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * 5. Products derived from this software may not be called "Apache",
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * nor may "Apache" appear in their name, without prior written
64185f9824e42f21ca7b9ae6c004484215c031a7rbb * permission of the Apache Software Foundation.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * SUCH DAMAGE.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * ====================================================================
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * This software consists of voluntary contributions made by many
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * individuals on behalf of the Apache Software Foundation. For more
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * information on the Apache Software Foundation, please see
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * <http://www.apache.org/>.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding *
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * Portions of this software are based upon public domain software
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * originally written at the National Center for Supercomputing Applications,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * University of Illinois, Urbana-Champaign.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
3568de757bac0b47256647504c186d17ca272f85rbb/* Status Module. Display lots of internal data about how Apache is
3568de757bac0b47256647504c186d17ca272f85rbb * performing and the state of all children processes.
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * To enable this, add the following lines into any config file:
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * <Location /server-status>
3568de757bac0b47256647504c186d17ca272f85rbb * SetHandler server-status
3568de757bac0b47256647504c186d17ca272f85rbb * </Location>
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * You may want to protect this location by password or domain so no one
3568de757bac0b47256647504c186d17ca272f85rbb * else can look at it. Then you can access the statistics with a URL like:
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * http://your_server_name/server-status
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * /server-status - Returns page using tables
3568de757bac0b47256647504c186d17ca272f85rbb * /server-status?notable - Returns page for browsers without table support
3568de757bac0b47256647504c186d17ca272f85rbb * /server-status?refresh - Returns page with 1 second refresh
3568de757bac0b47256647504c186d17ca272f85rbb * /server-status?refresh=6 - Returns page with refresh every 6 seconds
3568de757bac0b47256647504c186d17ca272f85rbb * /server-status?auto - Returns page with data for automatic parsing
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * Mark Cox, mark@ukweb.com, November 1995
3568de757bac0b47256647504c186d17ca272f85rbb *
3568de757bac0b47256647504c186d17ca272f85rbb * 12.11.95 Initial version for www.telescope.org
3568de757bac0b47256647504c186d17ca272f85rbb * 13.3.96 Updated to remove rprintf's [Mark]
3568de757bac0b47256647504c186d17ca272f85rbb * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
3568de757bac0b47256647504c186d17ca272f85rbb * 18.3.96 Make extra Scoreboard variables #definable
3568de757bac0b47256647504c186d17ca272f85rbb * 25.3.96 Make short report have full precision [Ben Laurie suggested]
3568de757bac0b47256647504c186d17ca272f85rbb * 25.3.96 Show uptime better [Mark/Ben Laurie]
3568de757bac0b47256647504c186d17ca272f85rbb * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
3568de757bac0b47256647504c186d17ca272f85rbb * 09.4.96 Added message for non-STATUS compiled version
3568de757bac0b47256647504c186d17ca272f85rbb * 18.4.96 Added per child and per slot counters [Jim Jagielski]
3568de757bac0b47256647504c186d17ca272f85rbb * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
3568de757bac0b47256647504c186d17ca272f85rbb * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
3568de757bac0b47256647504c186d17ca272f85rbb * piece in short reports [Ben Laurie]
3568de757bac0b47256647504c186d17ca272f85rbb * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
3568de757bac0b47256647504c186d17ca272f85rbb * extended STATUS is enabled) [George Burgyan/Jim J.]
3568de757bac0b47256647504c186d17ca272f85rbb * 10.8.98 Allow for extended status info at runtime (no more STATUS)
3568de757bac0b47256647504c186d17ca272f85rbb * [Jim J.]
3568de757bac0b47256647504c186d17ca272f85rbb */
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb#define CORE_PRIVATE
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "httpd.h"
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "http_config.h"
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "http_core.h"
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "http_protocol.h"
3568de757bac0b47256647504c186d17ca272f85rbb#include "http_main.h"
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick#include "ap_mpm.h"
3568de757bac0b47256647504c186d17ca272f85rbb#include "util_script.h"
3568de757bac0b47256647504c186d17ca272f85rbb#include <time.h>
3568de757bac0b47256647504c186d17ca272f85rbb#include "scoreboard.h"
3568de757bac0b47256647504c186d17ca272f85rbb#include "http_log.h"
db12cd62083041bf90945eeb90cc40fbd2340797trawick#if APR_HAVE_UNISTD_H
db12cd62083041bf90945eeb90cc40fbd2340797trawick#include <unistd.h>
db12cd62083041bf90945eeb90cc40fbd2340797trawick#endif
333eac96e4fb7d6901cb75e6ca7bb22b2ccb84cetrawick#define APR_WANT_STRFUNC
333eac96e4fb7d6901cb75e6ca7bb22b2ccb84cetrawick#include "apr_want.h"
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb#ifdef NEXT
3568de757bac0b47256647504c186d17ca272f85rbb#if (NX_CURRENT_COMPILER_RELEASE == 410)
3568de757bac0b47256647504c186d17ca272f85rbb#ifdef m68k
3568de757bac0b47256647504c186d17ca272f85rbb#define HZ 64
3568de757bac0b47256647504c186d17ca272f85rbb#else
3568de757bac0b47256647504c186d17ca272f85rbb#define HZ 100
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb#else
3568de757bac0b47256647504c186d17ca272f85rbb#include <machine/param.h>
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb#endif /* NEXT */
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define STATUS_MAXLINE 64
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define KBYTE 1024
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define MBYTE 1048576L
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define GBYTE 1073741824L
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#ifndef DEFAULT_TIME_FORMAT
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#endif
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
8f3ec4772d2aeb347cf40e87c77627bb784dd018rbb#define STATUS_MAGIC_TYPE "application/x-httpd-status"
8f3ec4772d2aeb347cf40e87c77627bb784dd018rbb
3d96ee83babeec32482c9082c9426340cee8c44dwrowemodule AP_MODULE_DECLARE_DATA status_module;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawickint server_limit, thread_limit;
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick
3568de757bac0b47256647504c186d17ca272f85rbb/*
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * command-related code. This is here to prevent use of ExtendedStatus
3568de757bac0b47256647504c186d17ca272f85rbb * without status_module included.
3568de757bac0b47256647504c186d17ca272f85rbb */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzstatic const char *set_extended_status(cmd_parms *cmd, void *dummy, int arg)
3568de757bac0b47256647504c186d17ca272f85rbb{
3568de757bac0b47256647504c186d17ca272f85rbb const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
3568de757bac0b47256647504c186d17ca272f85rbb if (err != NULL) {
3568de757bac0b47256647504c186d17ca272f85rbb return err;
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb ap_extended_status = arg;
3568de757bac0b47256647504c186d17ca272f85rbb return NULL;
3568de757bac0b47256647504c186d17ca272f85rbb}
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbbstatic const command_rec status_module_cmds[] =
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding{
3568de757bac0b47256647504c186d17ca272f85rbb AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF,
3568de757bac0b47256647504c186d17ca272f85rbb "\"On\" to enable extended status information, \"Off\" to disable"),
3568de757bac0b47256647504c186d17ca272f85rbb {NULL}
3568de757bac0b47256647504c186d17ca272f85rbb};
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb/* Format the number of bytes nicely */
41634f717c623556a16b27b25d7d909a66fe20f8wrowestatic void format_byte_out(request_rec *r, apr_off_t bytes)
3568de757bac0b47256647504c186d17ca272f85rbb{
3568de757bac0b47256647504c186d17ca272f85rbb if (bytes < (5 * KBYTE))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%d B", (int) bytes);
3568de757bac0b47256647504c186d17ca272f85rbb else if (bytes < (MBYTE / 2))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%.1f kB", (float) bytes / KBYTE);
3568de757bac0b47256647504c186d17ca272f85rbb else if (bytes < (GBYTE / 2))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%.1f MB", (float) bytes / MBYTE);
3568de757bac0b47256647504c186d17ca272f85rbb else
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%.1f GB", (float) bytes / GBYTE);
3568de757bac0b47256647504c186d17ca272f85rbb}
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
41634f717c623556a16b27b25d7d909a66fe20f8wrowestatic void format_kbyte_out(request_rec *r, apr_off_t kbytes)
3568de757bac0b47256647504c186d17ca272f85rbb{
3568de757bac0b47256647504c186d17ca272f85rbb if (kbytes < KBYTE)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%d kB", (int) kbytes);
3568de757bac0b47256647504c186d17ca272f85rbb else if (kbytes < MBYTE)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%.1f MB", (float) kbytes / KBYTE);
3568de757bac0b47256647504c186d17ca272f85rbb else
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "%.1f GB", (float) kbytes / MBYTE);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding}
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzstatic void show_time(request_rec *r, apr_interval_time_t tsecs)
3568de757bac0b47256647504c186d17ca272f85rbb{
fc1efab92032301e317f07e1b3a00082d9d71f3frbb int days, hrs, mins, secs;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
24b534291150023e6b68eca89ddd33e475ccddc0wrowe secs = (int)(tsecs % 60);
3568de757bac0b47256647504c186d17ca272f85rbb tsecs /= 60;
24b534291150023e6b68eca89ddd33e475ccddc0wrowe mins = (int)(tsecs % 60);
3568de757bac0b47256647504c186d17ca272f85rbb tsecs /= 60;
24b534291150023e6b68eca89ddd33e475ccddc0wrowe hrs = (int)(tsecs % 24);
24b534291150023e6b68eca89ddd33e475ccddc0wrowe days = (int)(tsecs / 24);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
3568de757bac0b47256647504c186d17ca272f85rbb if (days)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, " %d day%s", days, days == 1 ? "" : "s");
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
3568de757bac0b47256647504c186d17ca272f85rbb if (hrs)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, " %d hour%s", hrs, hrs == 1 ? "" : "s");
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
3568de757bac0b47256647504c186d17ca272f85rbb if (mins)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, " %d minute%s", mins, mins == 1 ? "" : "s");
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
3568de757bac0b47256647504c186d17ca272f85rbb if (secs)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, " %d second%s", secs, secs == 1 ? "" : "s");
3568de757bac0b47256647504c186d17ca272f85rbb}
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb/* Main handler for x-httpd-status requests */
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb/* ID values for command table */
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define STAT_OPT_END -1
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define STAT_OPT_REFRESH 0
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define STAT_OPT_NOTABLE 1
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#define STAT_OPT_AUTO 2
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbbstruct stat_opt {
3568de757bac0b47256647504c186d17ca272f85rbb int id;
3568de757bac0b47256647504c186d17ca272f85rbb const char *form_data_str;
3568de757bac0b47256647504c186d17ca272f85rbb const char *hdr_out_str;
3568de757bac0b47256647504c186d17ca272f85rbb};
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzstatic const struct stat_opt status_options[] = /* see #defines above */
3568de757bac0b47256647504c186d17ca272f85rbb{
3568de757bac0b47256647504c186d17ca272f85rbb {STAT_OPT_REFRESH, "refresh", "Refresh"},
3568de757bac0b47256647504c186d17ca272f85rbb {STAT_OPT_NOTABLE, "notable", NULL},
3568de757bac0b47256647504c186d17ca272f85rbb {STAT_OPT_AUTO, "auto", NULL},
3568de757bac0b47256647504c186d17ca272f85rbb {STAT_OPT_END, NULL, NULL}
3568de757bac0b47256647504c186d17ca272f85rbb};
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbbstatic char status_flags[SERVER_NUM_STATUS];
3568de757bac0b47256647504c186d17ca272f85rbb
0f081398cf0eef8cc7c66a535d450110a92dc8aefieldingstatic int status_handler(request_rec *r)
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding{
3568de757bac0b47256647504c186d17ca272f85rbb const char *loc;
239f998fbee5ac5b114b965bb76e217cce0003edstoddard apr_time_t nowtime;
78ae889ffe0fdfab72f56c6993b0f302cb48da55rbb apr_interval_time_t up_time;
3568de757bac0b47256647504c186d17ca272f85rbb int j, i, res;
3568de757bac0b47256647504c186d17ca272f85rbb int ready = 0;
3568de757bac0b47256647504c186d17ca272f85rbb int busy = 0;
3568de757bac0b47256647504c186d17ca272f85rbb unsigned long count = 0;
41634f717c623556a16b27b25d7d909a66fe20f8wrowe unsigned long lres, my_lres, conn_lres;
41634f717c623556a16b27b25d7d909a66fe20f8wrowe apr_off_t bytes, my_bytes, conn_bytes;
41634f717c623556a16b27b25d7d909a66fe20f8wrowe apr_off_t bcount = 0, kbcount = 0;
3568de757bac0b47256647504c186d17ca272f85rbb long req_time;
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard#ifdef HAVE_TIMES
3568de757bac0b47256647504c186d17ca272f85rbb#ifdef _SC_CLK_TCK
3568de757bac0b47256647504c186d17ca272f85rbb float tick = sysconf(_SC_CLK_TCK);
3568de757bac0b47256647504c186d17ca272f85rbb#else
3568de757bac0b47256647504c186d17ca272f85rbb float tick = HZ;
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb int short_report = 0;
3568de757bac0b47256647504c186d17ca272f85rbb int no_table_report = 0;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm worker_score *ws_record;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm process_score *ps_record;
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick char *stat_buffer;
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick pid_t *pid_buffer;
3568de757bac0b47256647504c186d17ca272f85rbb clock_t tu, ts, tcu, tcs;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if (strcmp(r->handler, STATUS_MAGIC_TYPE) &&
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz strcmp(r->handler, "server-status")) {
ca53a74f4012a45cbad48e940eddf27d866981f9dougm return DECLINED;
ca53a74f4012a45cbad48e940eddf27d866981f9dougm }
ca53a74f4012a45cbad48e940eddf27d866981f9dougm
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick pid_buffer = apr_palloc(r->pool, server_limit * sizeof(pid_t));
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick stat_buffer = apr_palloc(r->pool, server_limit * thread_limit * sizeof(char));
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick
239f998fbee5ac5b114b965bb76e217cce0003edstoddard nowtime = apr_time_now();
3568de757bac0b47256647504c186d17ca272f85rbb tu = ts = tcu = tcs = 0;
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (!ap_exists_scoreboard_image()) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard "Server status unavailable in inetd mode");
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard return HTTP_INTERNAL_SERVER_ERROR;
3568de757bac0b47256647504c186d17ca272f85rbb }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
48d2edbfb84e5559b5da0f8d614ccab805cc67a8rbb r->allowed = (AP_METHOD_BIT << M_GET);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding if (r->method_number != M_GET)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard return DECLINED;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
e0d102c882a7ed34d3eec24b36da49f097066a36stoddard ap_set_content_type(r, "text/html");
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
3568de757bac0b47256647504c186d17ca272f85rbb /*
3568de757bac0b47256647504c186d17ca272f85rbb * Simple table-driven form data set parser that lets you alter the header
3568de757bac0b47256647504c186d17ca272f85rbb */
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (r->args) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard i = 0;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard while (status_options[i].id != STAT_OPT_END) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if ((loc = ap_strstr_c(r->args,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz status_options[i].form_data_str)) != NULL) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard switch (status_options[i].id) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard case STAT_OPT_REFRESH:
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (*(loc + strlen(status_options[i].form_data_str)) == '='
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz && atol(loc + strlen(status_options[i].form_data_str)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard + 1) > 0)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard apr_table_set(r->headers_out,
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard status_options[i].hdr_out_str,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz loc +
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz strlen(status_options[i].hdr_out_str) +
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz 1);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard else
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard apr_table_set(r->headers_out,
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard status_options[i].hdr_out_str, "1");
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard break;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard case STAT_OPT_NOTABLE:
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard no_table_report = 1;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard break;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard case STAT_OPT_AUTO:
e0d102c882a7ed34d3eec24b36da49f097066a36stoddard ap_set_content_type(r, "text/plain");
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard short_report = 1;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard break;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard i++;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding if (r->header_only)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard return 0;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick for (i = 0; i < server_limit; ++i) {
98cd3186185bb28ae6c95a3f159899fcf56a663ftrawick ps_record = ap_get_scoreboard_process(i);
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick for (j = 0; j < thread_limit; ++j) {
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick int indx = (i * thread_limit) + j;
3568de757bac0b47256647504c186d17ca272f85rbb
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record = ap_get_scoreboard_worker(i, j);
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm res = ws_record->status;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard stat_buffer[indx] = status_flags[res];
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (!ps_record->quiescing
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm && ps_record->generation == ap_my_generation
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm && ps_record->pid) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (res == SERVER_READY)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ready++;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard else if (res != SERVER_DEAD && res != SERVER_IDLE_KILL)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard busy++;
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames /* XXX what about the counters for quiescing/seg faulted
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames * processes? should they be counted or not? GLA
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (ap_extended_status) {
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm lres = ws_record->access_count;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm bytes = ws_record->bytes_served;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) {
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard#ifdef HAVE_TIMES
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm tu += ws_record->times.tms_utime;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ts += ws_record->times.tms_stime;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm tcu += ws_record->times.tms_cutime;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm tcs += ws_record->times.tms_cstime;
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard#endif /* HAVE_TIMES */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard count += lres;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard bcount += bytes;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (bcount >= KBYTE) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard kbcount += (bcount >> 10);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard bcount = bcount & 0x3ff;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm pid_buffer[i] = ps_record->pid;
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
74fd6d9aeadb9022086259c5c1ae00bc0dda9c9astoddard /* up_time in seconds */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz up_time = (apr_uint32_t) ((nowtime -
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_scoreboard_image->global->restart_time)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz / APR_USEC_PER_SEC);
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (!short_report) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs(DOCTYPE_HTML_3_2
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard "<html><head>\n<title>Apache Status</title>\n</head><body>\n",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("<h1>Apache Server Status for ", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rvputs(r, "<dl><dt>Server Version: ",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_get_server_version(), "</dt>\n", NULL);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rvputs(r, "<dt>Server Built: ",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_get_server_built(), "\n</dt></dl><hr /><dl>\n", NULL);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rvputs(r, "<dt>Current Time: ",
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0),
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz "</dt>\n", NULL);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rvputs(r, "<dt>Restart Time: ",
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_ht_time(r->pool,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_scoreboard_image->global->restart_time,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz DEFAULT_TIME_FORMAT, 0),
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard "</dt>\n", NULL);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "<dt>Parent Server Generation: %d</dt>\n",
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz (int)ap_my_generation);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("<dt>Server uptime: ", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard show_time(r, up_time);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</dt>\n", r);
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (ap_extended_status) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (short_report) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %"
f714f1a7002928d785e53e70349700a7f595fee3trawick APR_OFF_T_FMT "\n",
f714f1a7002928d785e53e70349700a7f595fee3trawick count, kbcount);
3568de757bac0b47256647504c186d17ca272f85rbb
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard#ifdef HAVE_TIMES
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz /* Allow for OS/2 not having CPU stats */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if (ts || tu || tcu || tcs)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "CPULoad: %g\n",
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz (tu + ts + tcu + tcs) / tick / up_time * 100.);
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "Uptime: %ld\n", (long) (up_time));
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (up_time > 0)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "ReqPerSec: %g\n",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard (float) count / (float) up_time);
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (up_time > 0)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "BytesPerSec: %g\n",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard KBYTE * (float) kbcount / (float) up_time);
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (count > 0)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "BytesPerReq: %g\n",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard KBYTE * (float) kbcount / (float) count);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz else { /* !short_report */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "<dt>Total accesses: %lu - Total Traffic: ", count);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard format_kbyte_out(r, kbcount);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</dt>\n", r);
3568de757bac0b47256647504c186d17ca272f85rbb
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard#ifdef HAVE_TIMES
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* Allow for OS/2 not having CPU stats */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "<dt>CPU Usage: u%g s%g cu%g cs%g",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard tu / tick, ts / tick, tcu / tick, tcs / tick);
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (ts || tu || tcu || tcs)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, " - %.3g%% CPU load</dt>\n",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard (tu + ts + tcu + tcs) / tick / up_time * 100.);
3568de757bac0b47256647504c186d17ca272f85rbb#endif
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (up_time > 0)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "<dt>%.3g requests/sec - ",
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard (float) count / (float) up_time);
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (up_time > 0) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard / (float) up_time));
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("/second - ", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (count > 0) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard / (float) count));
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("/request", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</dt>\n", r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz } /* short_report */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz } /* ap_extended_status */
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (!short_report)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rprintf(r, "<dt>%d requests currently being processed, "
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz "%d idle workers</dt>\n", busy, ready);
3568de757bac0b47256647504c186d17ca272f85rbb else
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rprintf(r, "BusyWorkers: %d\nIdleWorkers: %d\n", busy, ready);
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb /* send the scoreboard 'table' out */
3568de757bac0b47256647504c186d17ca272f85rbb if (!short_report)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</dl><pre>", r);
3568de757bac0b47256647504c186d17ca272f85rbb else
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("Scoreboard: ", r);
3568de757bac0b47256647504c186d17ca272f85rbb
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick for (i = 0; i < server_limit; ++i) {
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick for (j = 0; j < thread_limit; ++j) {
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick int indx = (i * thread_limit) + j;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputc(stat_buffer[indx], r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if ((indx % STATUS_MAXLINE == (STATUS_MAXLINE - 1))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz && !short_report)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\n", r);
beb70d51e435dc36c56a72b6cd83556c04db9283wrowe }
fe6baec9bbcd36f932b71a355120cd7b5a685d6cfielding }
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (short_report)
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\n", r);
3568de757bac0b47256647504c186d17ca272f85rbb else {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</pre>\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("<p>Scoreboard Key:<br />\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>_</code></b>\" Waiting for Connection, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>S</code></b>\" Starting up, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>R</code></b>\" Reading Request,<br />\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>W</code></b>\" Sending Reply, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>K</code></b>\" Keepalive (read), \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>D</code></b>\" DNS Lookup,<br />\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>C</code></b>\" Closing connection, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>L</code></b>\" Logging, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>G</code></b>\" Gracefully finishing,<br /> \n", r);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe ap_rputs("\"<b><code>I</code></b>\" Idle cleanup of worker, \n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\"<b><code>.</code></b>\" Open slot with no current process</p>\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("<p />\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (!ap_extended_status) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard int j;
8e9734d1a4af74c141e2a0f880bb51bb061fa03atrawick int k = 0;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("PID Key: <br />\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("<pre>\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard for (i = 0; i < server_limit; ++i) {
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick for (j = 0; j < thread_limit; ++j) {
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick int indx = (i * thread_limit) + j;
3568de757bac0b47256647504c186d17ca272f85rbb
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (stat_buffer[indx] != '.') {
cb97ae2ff6969c2789b8e03f1bc4187fa73b6bafwrowe ap_rprintf(r, " %" APR_PID_T_FMT
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawick " in state: %c ", pid_buffer[i],
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawick stat_buffer[indx]);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (++k >= 3) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard k = 0;
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard } else
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs(",", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb }
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ap_rputs("</pre>\n", r);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard }
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (ap_extended_status && !short_report) {
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (no_table_report)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<hr /><h2>Server Details</h2>\n\n", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick else
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("\n\n<table border=\"0\"><tr>"
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>Srv</th><th>PID</th><th>Acc</th>"
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>M</th>"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>CPU\n</th>"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#endif
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>SS</th><th>Req</th>"
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>Conn</th><th>Child</th><th>Slot</th>"
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>Client</th><th>VHost</th>"
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<th>Request</th></tr>\n\n", r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz for (i = 0; i < server_limit; ++i) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz for (j = 0; j < thread_limit; ++j) {
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record = ap_get_scoreboard_worker(i, j);
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (ws_record->access_count == 0 &&
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm (ws_record->status == SERVER_READY ||
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->status == SERVER_DEAD)) {
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick continue;
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick }
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ps_record = ap_get_scoreboard_process(i);
3568de757bac0b47256647504c186d17ca272f85rbb
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (ws_record->start_time == 0L)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz req_time = 0L;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz else
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz req_time = (long)
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ((ws_record->stop_time -
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->start_time) / 1000);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if (req_time < 0L)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz req_time = 0L;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm lres = ws_record->access_count;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm my_lres = ws_record->my_access_count;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm conn_lres = ws_record->conn_count;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm bytes = ws_record->bytes_served;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm my_bytes = ws_record->my_bytes_served;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm conn_bytes = ws_record->conn_bytes;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (no_table_report) {
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (ws_record->status == SERVER_DEAD)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<b>Server %d-%d</b> (-): %d|%lu|%lu [",
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm i, (int)ps_record->generation,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (int)conn_lres, my_lres, lres);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick else
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<b>Server %d-%d</b> (%"
cb97ae2ff6969c2789b8e03f1bc4187fa73b6bafwrowe APR_PID_T_FMT "): %d|%lu|%lu [",
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm i, (int) ps_record->generation,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ps_record->pid,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (int)conn_lres, my_lres, lres);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm switch (ws_record->status) {
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_READY:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("Ready", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_STARTING:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("Starting", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_READ:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>Read</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_WRITE:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>Write</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_KEEPALIVE:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>Keepalive</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_LOG:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>Logging</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_DNS:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>DNS lookup</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_CLOSING:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("<b>Closing</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_DEAD:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("Dead", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_GRACEFUL:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("Graceful", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_IDLE_KILL:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("Dying", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick default:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("?STATE?", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick }
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r, "] "
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "u%g s%g cu%g cs%g"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#endif
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "\n %ld %ld (",
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_utime / tick,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_stime / tick,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_cutime / tick,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_cstime / tick,
3568de757bac0b47256647504c186d17ca272f85rbb#endif
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm (long)((nowtime - ws_record->last_used) /
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick APR_USEC_PER_SEC),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (long) req_time);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick format_byte_out(r, conn_bytes);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("|", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick format_byte_out(r, my_bytes);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("|", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick format_byte_out(r, bytes);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs(")\n", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick " <i>%s {%s}</i> <b>[%s]</b><br />\n\n",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->client),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->request),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->vhost));
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick }
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick else { /* !no_table_report */
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (ws_record->status == SERVER_DEAD)
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<tr><td><b>%d-%d</b></td><td>-</td><td>%d/%lu/%lu",
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm i, (int)ps_record->generation,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (int)conn_lres, my_lres, lres);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick else
f886987cd0bd4220c14043c4d9be77ec22902e73trawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<tr><td><b>%d-%d</b></td><td>%"
cb97ae2ff6969c2789b8e03f1bc4187fa73b6bafwrowe APR_PID_T_FMT
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "</td><td>%d/%lu/%lu",
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm i, (int)ps_record->generation,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ps_record->pid, (int)conn_lres,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick my_lres, lres);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm switch (ws_record->status) {
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_READY:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td>_", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_STARTING:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>S</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_READ:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>R</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_WRITE:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>W</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_KEEPALIVE:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>K</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_LOG:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>L</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_BUSY_DNS:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>D</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_CLOSING:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td><b>C</b>", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_DEAD:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td>.", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_GRACEFUL:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td>G", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick case SERVER_IDLE_KILL:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td>I", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick default:
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rputs("</td><td>?", r);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick break;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick }
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "\n</td>"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<td>%.2f</td>"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#endif
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "<td>%ld</td><td>%ld",
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm (ws_record->times.tms_utime +
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_stime +
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_cutime +
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->times.tms_cstime) / tick,
3568de757bac0b47256647504c186d17ca272f85rbb#endif
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm (long)((nowtime - ws_record->last_used) /
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick APR_USEC_PER_SEC),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (long)req_time);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r, "</td><td>%-1.1f</td><td>%-2.2f</td><td>%-2.2f\n",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (float)bytes / MBYTE);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (ws_record->status == SERVER_BUSY_READ)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "</td><td>?</td><td nowrap>?</td><td nowrap>..reading.. </td></tr>\n\n");
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick else
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_rprintf(r,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick "</td><td>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>\n\n",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->client),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->vhost),
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick ap_escape_html(r->pool,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm ws_record->request));
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick } /* no_table_report */
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick } /* for (j...) */
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick } /* for (i...) */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (!no_table_report) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rputs("</table>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<hr /> \
3568de757bac0b47256647504c186d17ca272f85rbb<table>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Srv</th><td>Child Server number - generation</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>PID</th><td>OS process ID</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Acc</th><td>Number of accesses this connection / this child / this slot</td></tr>\n \
f886987cd0bd4220c14043c4d9be77ec22902e73trawick<tr><th>M</th><td>Mode of operation</td></tr>\n"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#ifdef HAVE_TIMES
f886987cd0bd4220c14043c4d9be77ec22902e73trawick"<tr><th>CPU</th><td>CPU usage, number of seconds</td></tr>\n"
f886987cd0bd4220c14043c4d9be77ec22902e73trawick#endif
f886987cd0bd4220c14043c4d9be77ec22902e73trawick
f886987cd0bd4220c14043c4d9be77ec22902e73trawick"<tr><th>SS</th><td>Seconds since beginning of most recent request</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Req</th><td>Milliseconds required to process most recent request</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Conn</th><td>Kilobytes transferred this connection</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Child</th><td>Megabytes transferred this child</td></tr>\n \
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe<tr><th>Slot</th><td>Total megabytes transferred this slot</td></tr>\n \
3568de757bac0b47256647504c186d17ca272f85rbb</table>\n", r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz }
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick } /* if (ap_extended_status && !short_report) */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz else {
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if (!short_report) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rputs("<hr />To obtain a full report with current status "
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz "information you need to use the "
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz "<code>ExtendedStatus On</code> directive.\n", r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz }
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
3568de757bac0b47256647504c186d17ca272f85rbb if (!short_report) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rputs(ap_psignature("<hr />\n",r), r);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz ap_rputs("</body></html>\n", r);
3568de757bac0b47256647504c186d17ca272f85rbb }
3568de757bac0b47256647504c186d17ca272f85rbb
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding return 0;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding}
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
3568de757bac0b47256647504c186d17ca272f85rbb
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzstatic int status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz server_rec *s)
3568de757bac0b47256647504c186d17ca272f85rbb{
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz status_flags[SERVER_DEAD] = '.'; /* We don't want to assume these are in */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz status_flags[SERVER_READY] = '_'; /* any particular order in scoreboard.h */
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_STARTING] = 'S';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_BUSY_READ] = 'R';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_BUSY_WRITE] = 'W';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_BUSY_KEEPALIVE] = 'K';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_BUSY_LOG] = 'L';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_BUSY_DNS] = 'D';
ec020ca384efb30d501a5af796ddc3bb237d7b8fgregames status_flags[SERVER_CLOSING] = 'C';
3568de757bac0b47256647504c186d17ca272f85rbb status_flags[SERVER_GRACEFUL] = 'G';
ce03576b2434cec77f2921db9d5b6a0510581c23rederpj status_flags[SERVER_IDLE_KILL] = 'I';
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
9d0665da83d1e22c0ea0e5f6f940f70f75bf5237ianh return OK;
3568de757bac0b47256647504c186d17ca272f85rbb}
3568de757bac0b47256647504c186d17ca272f85rbb
73e8b26287de5c06fa470d36162e103dbac9c7e5wrowestatic void register_hooks(apr_pool_t *p)
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding{
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE);
3568de757bac0b47256647504c186d17ca272f85rbb ap_hook_post_config(status_init, NULL, NULL, APR_HOOK_MIDDLE);
ca53a74f4012a45cbad48e940eddf27d866981f9dougm}
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding
3d96ee83babeec32482c9082c9426340cee8c44dwrowemodule AP_MODULE_DECLARE_DATA status_module =
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding{
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanoj STANDARD20_MODULE_STUFF,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz NULL, /* dir config creater */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz NULL, /* dir merger --- default is to override */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz NULL, /* server config */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz NULL, /* merge server config */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz status_module_cmds, /* command table */
3568de757bac0b47256647504c186d17ca272f85rbb register_hooks /* register_hooks */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding};
3568de757bac0b47256647504c186d17ca272f85rbb