mod_status.c revision 89da6eb70c41422a20e5f871dbf5950140d128ab
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin/* Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * the License. You may obtain a copy of the License at
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * Unless required by applicable law or agreed to in writing, software
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * distributed under the License is distributed on an "AS IS" BASIS,
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * See the License for the specific language governing permissions and
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * limitations under the License.
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin/* Status Module. Display lots of internal data about how Apache is
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * performing and the state of all children processes.
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * To enable this, add the following lines into any config file:
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * <Location /server-status>
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * SetHandler server-status
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * </Location>
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * You may want to protect this location by password or domain so no one
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * else can look at it. Then you can access the statistics with a URL like:
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * /server-status - Returns page using tables
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * /server-status?notable - Returns page for browsers without table support
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * /server-status?refresh - Returns page with 1 second refresh
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * /server-status?refresh=6 - Returns page with refresh every 6 seconds
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * /server-status?auto - Returns page with data for automatic parsing
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * Mark Cox, mark@ukweb.com, November 1995
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 12.11.95 Initial version for www.telescope.org
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 13.3.96 Updated to remove rprintf's [Mark]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 18.3.96 Make extra Scoreboard variables #definable
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 25.3.96 Make short report have full precision [Ben Laurie suggested]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 25.3.96 Show uptime better [Mark/Ben Laurie]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 09.4.96 Added message for non-STATUS compiled version
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 18.4.96 Added per child and per slot counters [Jim Jagielski]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * piece in short reports [Ben Laurie]
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin * extended STATUS is enabled) [George Burgyan/Jim J.]
7f0324120039aae80561410da14aa9086c65b601minfrin * 10.8.98 Allow for extended status info at runtime (no more STATUS)
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin#define STATUS_MAGIC_TYPE "application/x-httpd-status"
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrinstatic int server_limit, thread_limit, threads_per_child, max_servers,
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin/* Implement 'ap_run_status_hook'. */
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrinAPR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook,
(r, flags),
#ifdef HAVE_TIMES
if (days)
if (hrs)
if (mins)
if (secs)
#define STAT_OPT_REFRESH 0
struct stat_opt {
int id;
const char *form_data_str;
const char *hdr_out_str;
const char *loc;
int ready;
int busy;
unsigned long count;
long req_time;
int short_report;
int no_table_report;
char *stat_buffer;
#ifdef HAVE_TIMES
float tick;
int times_per_thread;
return DECLINED;
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
#ifdef _SC_CLK_TCK
ready = 0;
busy = 0;
count = 0;
bcount = 0;
kbcount = 0;
short_report = 0;
no_table_report = 0;
if (is_async) {
if (!ap_exists_scoreboard_image()) {
return HTTP_INTERNAL_SERVER_ERROR;
return DECLINED;
if (r->args) {
case STAT_OPT_REFRESH: {
case STAT_OPT_NOTABLE:
case STAT_OPT_AUTO:
for (i = 0; i < server_limit; ++i) {
#ifdef HAVE_TIMES
if (is_async) {
thread_idle_buffer[i] = 0;
thread_busy_buffer[i] = 0;
for (j = 0; j < thread_limit; ++j) {
ready++;
if (is_async)
thread_idle_buffer[i]++;
busy++;
if (is_async) {
thread_idle_buffer[i]++;
thread_busy_buffer[i]++;
if (ap_extended_status) {
#ifdef HAVE_TIMES
if (times_per_thread) {
#ifdef HAVE_TIMES
if (!short_report) {
ap_sload_t t;
DEFAULT_TIME_FORMAT, 0),
(int)mpm_generation);
ap_get_sload(&t);
if (ap_extended_status) {
if (short_report) {
#ifdef HAVE_TIMES
if (up_time > 0) {
if (count > 0)
#ifdef HAVE_TIMES
if (up_time > 0) {
/ (float) up_time));
if (count > 0) {
/ (float) count));
if (!short_report)
if (!short_report)
if (is_async) {
connections = 0;
if (!short_report)
for (i = 0; i < server_limit; ++i) {
if (!short_report)
if (!short_report) {
if (!short_report)
written = 0;
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
&& !short_report)
written++;
if (short_report)
if (!ap_extended_status) {
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
if (no_table_report)
#ifdef HAVE_TIMES
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
req_time = 0L;
req_time = (long)
if (req_time < 0L)
req_time = 0L;
if (no_table_report) {
ap_rprintf(r,
i, (int)worker_generation,
ap_rprintf(r,
i, (int) worker_generation,
case SERVER_READY:
case SERVER_STARTING:
case SERVER_BUSY_READ:
case SERVER_BUSY_WRITE:
case SERVER_BUSY_KEEPALIVE:
case SERVER_BUSY_LOG:
case SERVER_BUSY_DNS:
case SERVER_CLOSING:
case SERVER_DEAD:
case SERVER_GRACEFUL:
case SERVER_IDLE_KILL:
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
(long) req_time);
ap_rprintf(r,
ap_rprintf(r,
i, (int)worker_generation,
ap_rprintf(r,
i, (int)worker_generation,
(int)conn_lres,
case SERVER_READY:
case SERVER_STARTING:
case SERVER_BUSY_READ:
case SERVER_BUSY_WRITE:
case SERVER_BUSY_KEEPALIVE:
case SERVER_BUSY_LOG:
case SERVER_BUSY_DNS:
case SERVER_CLOSING:
case SERVER_DEAD:
case SERVER_GRACEFUL:
case SERVER_IDLE_KILL:
ap_rprintf(r,
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES
(long)req_time);
if (!no_table_report) {
#ifdef HAVE_TIMES
if (!short_report) {
int flags =
if (!short_report) {
return OK;
server_rec *s)
if (threads_per_child == 0)
return OK;
#ifdef HAVE_TIMES
#ifdef HAVE_TIMES