Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as C by aspel ( 16 years ago )
#include "httpd.h"
#include "http_config.h"
#include "apr_strings.h"
#include "scoreboard.h"
#include "ap_mpm.h"
#include <unistd.h>


static int server_limit, thread_limit;

static int ru_fixup(request_rec *r)
{
    apr_pool_t *rp = r->pool;
    worker_score *ws_record;
    process_score *ps_record;
    int tick;
    tick = sysconf(_SC_CLK_TCK);
    pid_t worker_pid;
    clock_t tmp_tu, tmp_ts, tmp_tcu, tmp_tcs;

    ws_record = ap_get_scoreboard_worker(r->connection->id, 0);
    ps_record = ap_get_scoreboard_process(r->connection->id);
    worker_pid = ps_record->pid;
    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;

    apr_table_set(r->notes, "cpu", apr_psprintf(rp, "%s pid:%lu child:%lu req:'%s' cpu:%lu",
         ws_record->vhost, ps_record->pid, r->connection->id, ws_record->request,(tmp_tu + tmp_ts + tmp_tcs + tmp_tcu ) / tick ));

    return DECLINED;

}

static int status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
    ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread;_limit);
    ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server;_limit);
    return OK;
}

static void myRegisterHooks(apr_pool_t *p) {
    ap_hook_post_read_request(status_init, NULL, NULL, APR_HOOK_MIDDLE);
    ap_hook_handler(ru_fixup, NULL, NULL, APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA myhits_module = {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    myRegisterHooks
};

 

Revise this Paste

Children: 18747
Your Name: Code Language: