2
0
Fork 0

[core] Record peak values of worker stats

personal/stbuehler/wip
Thomas Porzelt 2009-11-07 15:42:03 +01:00
parent 175db515a6
commit 6bf284b754
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}