Browse Source

[core] Record peak values of worker stats

personal/stbuehler/wip
Thomas Porzelt 13 years ago
parent
commit
6bf284b754
  1. 8
      include/lighttpd/worker.h
  2. 6
      src/main/worker.c

8
include/lighttpd/worker.h

@ -27,6 +27,14 @@ struct liStatistics {
guint active_cons_5s;
ev_tstamp last_avg;
/* peak values from 5s avg */
struct {
guint64 requests;
guint64 bytes_out;
guint64 bytes_in;
guint active_cons;
} peak;
/* updated in timer */
guint64 last_requests;
double requests_per_sec;

6
src/main/worker.c

@ -338,22 +338,26 @@ static void worker_stats_watcher_cb(struct ev_loop *loop, ev_timer *w, int reven
#endif
}
/* 5s averages */
/* 5s averages and peak values */
if ((now - wrk->stats.last_avg) > 5) {
/* bytes in */
wrk->stats.bytes_in_5s_diff = wrk->stats.bytes_in - wrk->stats.bytes_in_5s;
wrk->stats.bytes_in_5s = wrk->stats.bytes_in;
wrk->stats.peak.bytes_in = MAX(wrk->stats.peak.bytes_in, wrk->stats.bytes_in_5s_diff / 5);
/* bytes out */
wrk->stats.bytes_out_5s_diff = wrk->stats.bytes_out - wrk->stats.bytes_out_5s;
wrk->stats.bytes_out_5s = wrk->stats.bytes_out;
wrk->stats.peak.bytes_out = MAX(wrk->stats.peak.bytes_out, wrk->stats.bytes_out_5s_diff / 5);
/* requests */
wrk->stats.requests_5s_diff = wrk->stats.requests - wrk->stats.requests_5s;
wrk->stats.requests_5s = wrk->stats.requests;
wrk->stats.peak.requests = MAX(wrk->stats.peak.requests, wrk->stats.requests_5s_diff / 5);
/* active connections */
wrk->stats.active_cons_5s = wrk->connections_active;
wrk->stats.peak.active_cons = MAX(wrk->stats.peak.active_cons, wrk->connections_active);
wrk->stats.last_avg = now;
}

Loading…
Cancel
Save