mod_status.c revision dcd19776e8e3d73519ffb0201d6dfea67f0aeb3e
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh/* Licensed to the Apache Software Foundation (ASF) under one or more
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * contributor license agreements. See the NOTICE file distributed with
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * this work for additional information regarding copyright ownership.
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * The ASF licenses this file to You under the Apache License, Version 2.0
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * (the "License"); you may not use this file except in compliance with
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * the License. You may obtain a copy of the License at
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * Unless required by applicable law or agreed to in writing, software
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * distributed under the License is distributed on an "AS IS" BASIS,
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * See the License for the specific language governing permissions and
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * limitations under the License.
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh/* Status Module. Display lots of internal data about how Apache is
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * performing and the state of all children processes.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * To enable this, add the following lines into any config file:
1e252d105bda0f46b625809d3c219656ec2408e7jorton * <Location /server-status>
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * SetHandler server-status
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * </Location>
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * You may want to protect this location by password or domain so no one
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * else can look at it. Then you can access the statistics with a URL like:
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * /server-status - Returns page using tables
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * /server-status?notable - Returns page for browsers without table support
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * /server-status?refresh - Returns page with 1 second refresh
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * /server-status?refresh=6 - Returns page with refresh every 6 seconds
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * /server-status?auto - Returns page with data for automatic parsing
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * Mark Cox, mark@ukweb.com, November 1995
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 12.11.95 Initial version for www.telescope.org
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 13.3.96 Updated to remove rprintf's [Mark]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 18.3.96 Added CPU usage, process information, and tidied [Ben Laurie]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 18.3.96 Make extra Scoreboard variables #definable
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 25.3.96 Make short report have full precision [Ben Laurie suggested]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 25.3.96 Show uptime better [Mark/Ben Laurie]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 29.3.96 Better HTML and explanation [Mark/Rob Hartill suggested]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 09.4.96 Added message for non-STATUS compiled version
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 18.4.96 Added per child and per slot counters [Jim Jagielski]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 18.5.96 Adapted to use new rprintf() routine, incidentally fixing a missing
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * piece in short reports [Ben Laurie]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * extended STATUS is enabled) [George Burgyan/Jim J.]
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * 10.8.98 Allow for extended status info at runtime (no more STATUS)
c1f462d7c99794eaeaeab3940aa84f36ede3e587bjh * [Jim J.]
#include "http_config.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_main.h"
#include "ap_mpm.h"
#include "util_script.h"
#include <time.h>
#include "scoreboard.h"
#include "http_log.h"
#include "mod_status.h"
#include <unistd.h>
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "apr_strings.h"
#ifndef DEFAULT_TIME_FORMAT
(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_loadavg_t t;
DEFAULT_TIME_FORMAT, 0),
(int)mpm_generation);
ap_get_loadavg(&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