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