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