MCPcopy Create free account
hub / github.com/apache/httpd / ap_get_sload

Function ap_get_sload

server/util.c:3305–3358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3303#endif /* APR_HAS_THREADS */
3304
3305AP_DECLARE(void) ap_get_sload(ap_sload_t *ld)
3306{
3307 int i, j, server_limit, thread_limit;
3308 int ready = 0;
3309 int busy = 0;
3310 int total;
3311 ap_generation_t mpm_generation;
3312
3313 /* preload errored fields, we overwrite */
3314 ld->idle = -1;
3315 ld->busy = -1;
3316 ld->bytes_served = 0;
3317 ld->access_count = 0;
3318
3319 ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation);
3320 ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
3321 ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
3322
3323 for (i = 0; i < server_limit; i++) {
3324 process_score *ps;
3325 ps = ap_get_scoreboard_process(i);
3326
3327 for (j = 0; j < thread_limit; j++) {
3328 int res;
3329 worker_score *ws = NULL;
3330 ws = &ap_scoreboard_image->servers[i][j];
3331 res = ws->status;
3332
3333 if (!ps->quiescing && ps->pid) {
3334 if (res == SERVER_READY && ps->generation == mpm_generation) {
3335 ready++;
3336 }
3337 else if (res != SERVER_DEAD &&
3338 res != SERVER_STARTING && res != SERVER_IDLE_KILL &&
3339 ps->generation == mpm_generation) {
3340 busy++;
3341 }
3342 }
3343
3344 if (ap_extended_status && !ps->quiescing && ps->pid) {
3345 if (ws->access_count != 0
3346 || (res != SERVER_READY && res != SERVER_DEAD)) {
3347 ld->access_count += ws->access_count;
3348 ld->bytes_served += ws->bytes_served;
3349 }
3350 }
3351 }
3352 }
3353 total = busy + ready;
3354 if (total) {
3355 ld->idle = ready * 100 / total;
3356 ld->busy = busy * 100 / total;
3357 }
3358}
3359
3360AP_DECLARE(void) ap_get_loadavg(ap_loadavg_t *ld)
3361{

Callers 4

systemd_monitorFunction · 0.85
header_request_idleFunction · 0.85
header_request_busyFunction · 0.85
httpd.hFile · 0.85

Calls 2

ap_mpm_queryFunction · 0.85

Tested by

no test coverage detected