From 299ae40e78848d9def19e7be959ee11d11a2c5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 17 Jan 2008 09:54:00 +0000 Subject: [PATCH] - add IdleServers and Scoreboard directives in ?auto mode for mod_status (#1507) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2045 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/mod_status.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/NEWS b/NEWS index 08d13e9e..35fee7b3 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ NEWS * print error if X-LIGHTTPD-send-file cannot be done; reset header Content-Length for send-file. Patches by Stefan Buhler * prevent crash in certain php-fcgi configurations (#841) + * add IdleServers and Scoreboard directives in ?auto mode for mod_status (#1507) - 1.4.18 - 2007-09-09 diff --git a/src/mod_status.c b/src/mod_status.c index 80c00401..028cbc7a 100644 --- a/src/mod_status.c +++ b/src/mod_status.c @@ -560,6 +560,8 @@ static handler_t mod_status_handle_server_status_text(server *srv, connection *c double avg; time_t ts; char buf[32]; + unsigned int k; + unsigned int l; b = chunkqueue_get_append_buffer(con->write_queue); @@ -588,6 +590,22 @@ static handler_t mod_status_handle_server_status_text(server *srv, connection *c buffer_append_long(b, srv->conns->used); BUFFER_APPEND_STRING_CONST(b, "\n"); + BUFFER_APPEND_STRING_CONST(b, "IdleServers: "); + buffer_append_long(b, srv->conns->size - srv->conns->used); + BUFFER_APPEND_STRING_CONST(b, "\n"); + + /* output scoreboard */ + BUFFER_APPEND_STRING_CONST(b, "Scoreboard: "); + for (k = 0; k < srv->conns->used; k++) { + connection *c = srv->conns->ptr[k]; + const char *state = connection_get_short_state(c->state); + buffer_append_string_len(b, state, 1); + } + for (l = 0; l < srv->conns->size - srv->conns->used; l++) { + BUFFER_APPEND_STRING_CONST(b, "_"); + } + BUFFER_APPEND_STRING_CONST(b, "\n"); + /* set text/plain output */ response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));