⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_status.c

📁 Apache官方在今天放出产品系列2.2的最新版本2.2.11的源码包 最流行的HTTP服务器软件之一
💻 C
📖 第 1 页 / 共 3 页
字号:
        i = 0;        while (status_options[i].id != STAT_OPT_END) {            if ((loc = ap_strstr_c(r->args,                                   status_options[i].form_data_str)) != NULL) {                switch (status_options[i].id) {                case STAT_OPT_REFRESH: {                    apr_size_t len = strlen(status_options[i].form_data_str);                    long t = 0;                    if (*(loc + len ) == '=') {                        t = atol(loc + len + 1);                    }                    apr_table_set(r->headers_out,                                  status_options[i].hdr_out_str,                                  apr_ltoa(r->pool, t < 1 ? 10 : t));                    break;                }                case STAT_OPT_NOTABLE:                    no_table_report = 1;                    break;                case STAT_OPT_AUTO:                    ap_set_content_type(r, "text/plain; charset=ISO-8859-1");                    short_report = 1;                    break;                }            }            i++;        }    }    for (i = 0; i < server_limit; ++i) {#ifdef HAVE_TIMES        clock_t proc_tu = 0, proc_ts = 0, proc_tcu = 0, proc_tcs = 0;        clock_t tmp_tu, tmp_ts, tmp_tcu, tmp_tcs;#endif        ps_record = ap_get_scoreboard_process(i);        for (j = 0; j < thread_limit; ++j) {            int indx = (i * thread_limit) + j;            ws_record = ap_get_scoreboard_worker(i, j);            res = ws_record->status;            stat_buffer[indx] = status_flags[res];            if (!ps_record->quiescing                && ps_record->pid) {                if (res == SERVER_READY                    && ps_record->generation == ap_my_generation)                    ready++;                else if (res != SERVER_DEAD &&                         res != SERVER_STARTING &&                         res != SERVER_IDLE_KILL)                    busy++;            }            /* XXX what about the counters for quiescing/seg faulted             * processes?  should they be counted or not?  GLA             */            if (ap_extended_status) {                lres = ws_record->access_count;                bytes = ws_record->bytes_served;                if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) {#ifdef HAVE_TIMES                    tmp_tu = ws_record->times.tms_utime;                    tmp_ts = ws_record->times.tms_stime;                    tmp_tcu = ws_record->times.tms_cutime;                    tmp_tcs = ws_record->times.tms_cstime;                    if (times_per_thread) {                        proc_tu += tmp_tu;                        proc_ts += tmp_ts;                        proc_tcu += tmp_tcu;                        proc_tcs += proc_tcs;                    }                    else {                        if (tmp_tu > proc_tu ||                            tmp_ts > proc_ts ||                            tmp_tcu > proc_tcu ||                            tmp_tcs > proc_tcs) {                            proc_tu = tmp_tu;                            proc_ts = tmp_ts;                            proc_tcu = tmp_tcu;                            proc_tcs = proc_tcs;                        }                    }#endif /* HAVE_TIMES */                    count += lres;                    bcount += bytes;                    if (bcount >= KBYTE) {                        kbcount += (bcount >> 10);                        bcount = bcount & 0x3ff;                    }                }            }        }#ifdef HAVE_TIMES        tu += proc_tu;        ts += proc_ts;        tcu += proc_tcu;        tcs += proc_tcs;#endif        pid_buffer[i] = ps_record->pid;    }    /* up_time in seconds */    up_time = (apr_uint32_t) apr_time_sec(nowtime -                               ap_scoreboard_image->global->restart_time);    if (!short_report) {        ap_rputs(DOCTYPE_HTML_3_2                 "<html><head>\n<title>Apache Status</title>\n</head><body>\n",                 r);        ap_rputs("<h1>Apache Server Status for ", r);        ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);        ap_rvputs(r, "<dl><dt>Server Version: ",                  ap_get_server_description(), "</dt>\n", NULL);        ap_rvputs(r, "<dt>Server Built: ",                  ap_get_server_built(), "\n</dt></dl><hr /><dl>\n", NULL);        ap_rvputs(r, "<dt>Current Time: ",                  ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0),                             "</dt>\n", NULL);        ap_rvputs(r, "<dt>Restart Time: ",                  ap_ht_time(r->pool,                             ap_scoreboard_image->global->restart_time,                             DEFAULT_TIME_FORMAT, 0),                  "</dt>\n", NULL);        ap_rprintf(r, "<dt>Parent Server Generation: %d</dt>\n",                   (int)ap_my_generation);        ap_rputs("<dt>Server uptime: ", r);        show_time(r, up_time);        ap_rputs("</dt>\n", r);    }    if (ap_extended_status) {        if (short_report) {            ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %"                       APR_OFF_T_FMT "\n",                       count, kbcount);#ifdef HAVE_TIMES            /* Allow for OS/2 not having CPU stats */            if (ts || tu || tcu || tcs)                ap_rprintf(r, "CPULoad: %g\n",                           (tu + ts + tcu + tcs) / tick / up_time * 100.);#endif            ap_rprintf(r, "Uptime: %ld\n", (long) (up_time));            if (up_time > 0)                ap_rprintf(r, "ReqPerSec: %g\n",                           (float) count / (float) up_time);            if (up_time > 0)                ap_rprintf(r, "BytesPerSec: %g\n",                           KBYTE * (float) kbcount / (float) up_time);            if (count > 0)                ap_rprintf(r, "BytesPerReq: %g\n",                           KBYTE * (float) kbcount / (float) count);        }        else { /* !short_report */            ap_rprintf(r, "<dt>Total accesses: %lu - Total Traffic: ", count);            format_kbyte_out(r, kbcount);            ap_rputs("</dt>\n", r);#ifdef HAVE_TIMES            /* Allow for OS/2 not having CPU stats */            ap_rprintf(r, "<dt>CPU Usage: u%g s%g cu%g cs%g",                       tu / tick, ts / tick, tcu / tick, tcs / tick);            if (ts || tu || tcu || tcs)                ap_rprintf(r, " - %.3g%% CPU load</dt>\n",                           (tu + ts + tcu + tcs) / tick / up_time * 100.);#endif            if (up_time > 0)                ap_rprintf(r, "<dt>%.3g requests/sec - ",                           (float) count / (float) up_time);            if (up_time > 0) {                format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount                                                   / (float) up_time));                ap_rputs("/second - ", r);            }            if (count > 0) {                format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount                                                   / (float) count));                ap_rputs("/request", r);            }            ap_rputs("</dt>\n", r);        } /* short_report */    } /* ap_extended_status */    if (!short_report)        ap_rprintf(r, "<dt>%d requests currently being processed, "                      "%d idle workers</dt>\n", busy, ready);    else        ap_rprintf(r, "BusyWorkers: %d\nIdleWorkers: %d\n", busy, ready);    /* send the scoreboard 'table' out */    if (!short_report)        ap_rputs("</dl><pre>", r);    else        ap_rputs("Scoreboard: ", r);    for (i = 0; i < server_limit; ++i) {        for (j = 0; j < thread_limit; ++j) {            int indx = (i * thread_limit) + j;            ap_rputc(stat_buffer[indx], r);            if ((indx % STATUS_MAXLINE == (STATUS_MAXLINE - 1))                && !short_report)                ap_rputs("\n", r);        }    }    if (short_report)        ap_rputs("\n", r);    else {        ap_rputs("</pre>\n", r);        ap_rputs("<p>Scoreboard Key:<br />\n", r);        ap_rputs("\"<b><code>_</code></b>\" Waiting for Connection, \n", r);        ap_rputs("\"<b><code>S</code></b>\" Starting up, \n", r);        ap_rputs("\"<b><code>R</code></b>\" Reading Request,<br />\n", r);        ap_rputs("\"<b><code>W</code></b>\" Sending Reply, \n", r);        ap_rputs("\"<b><code>K</code></b>\" Keepalive (read), \n", r);        ap_rputs("\"<b><code>D</code></b>\" DNS Lookup,<br />\n", r);        ap_rputs("\"<b><code>C</code></b>\" Closing connection, \n", r);        ap_rputs("\"<b><code>L</code></b>\" Logging, \n", r);        ap_rputs("\"<b><code>G</code></b>\" Gracefully finishing,<br /> \n", r);        ap_rputs("\"<b><code>I</code></b>\" Idle cleanup of worker, \n", r);        ap_rputs("\"<b><code>.</code></b>\" Open slot with no current process</p>\n", r);        ap_rputs("<p />\n", r);        if (!ap_extended_status) {            int j;            int k = 0;            ap_rputs("PID Key: <br />\n", r);            ap_rputs("<pre>\n", r);            for (i = 0; i < server_limit; ++i) {                for (j = 0; j < thread_limit; ++j) {                    int indx = (i * thread_limit) + j;                    if (stat_buffer[indx] != '.') {                        ap_rprintf(r, "   %" APR_PID_T_FMT                                   " in state: %c ", pid_buffer[i],                                   stat_buffer[indx]);                        if (++k >= 3) {                            ap_rputs("\n", r);                            k = 0;                        } else                            ap_rputs(",", r);                    }                }            }            ap_rputs("\n", r);            ap_rputs("</pre>\n", r);        }    }    if (ap_extended_status && !short_report) {        if (no_table_report)            ap_rputs("<hr /><h2>Server Details</h2>\n\n", r);        else            ap_rputs("\n\n<table border=\"0\"><tr>"                     "<th>Srv</th><th>PID</th><th>Acc</th>"                     "<th>M</th>"#ifdef HAVE_TIMES                     "<th>CPU\n</th>"#endif                     "<th>SS</th><th>Req</th>"                     "<th>Conn</th><th>Child</th><th>Slot</th>"                     "<th>Client</th><th>VHost</th>"                     "<th>Request</th></tr>\n\n", r);        for (i = 0; i < server_limit; ++i) {            for (j = 0; j < thread_limit; ++j) {                ws_record = ap_get_scoreboard_worker(i, j);                if (ws_record->access_count == 0 &&                    (ws_record->status == SERVER_READY ||                     ws_record->status == SERVER_DEAD)) {                    continue;                }                ps_record = ap_get_scoreboard_process(i);                if (ws_record->start_time == 0L)                    req_time = 0L;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -