Commit 5ac7358d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add exponential average of responsetime to output



git-svn-id: http://www.varnish-cache.org/svn/trunk@3103 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 60d0f497
......@@ -54,6 +54,9 @@
#include "vrt.h"
#include "cache_backend.h"
/* Default averaging rate, we want something pretty responsive */
#define AVG_RATE 4
struct vbp_target {
unsigned magic;
#define VBP_TARGET_MAGIC 0x6b7cb656
......@@ -71,6 +74,10 @@ struct vbp_target {
#include "cache_backend_poll.h"
#undef BITMAP
double last;
double avg;
double rate;
VTAILQ_ENTRY(vbp_target) list;
pthread_t thread;
};
......@@ -205,6 +212,7 @@ vbp_poke(struct vbp_target *vt)
TCP_close(&s);
t_now = TIM_real();
vt->last = t_now - t_start;
vt->good_recv |= 1;
/* XXX: Check reponse status */
vt->happy |= 1;
......@@ -255,8 +263,16 @@ vbp_wrk_poll_backend(void *priv)
#define BITMAP(n, c, t, b) vt->n <<= 1;
#include "cache_backend_poll.h"
#undef BITMAP
vt->last = 0;
vbp_poke(vt);
/* Calculate exponential average */
if (vt->happy & 1) {
if (vt->rate < AVG_RATE)
vt->rate += 1.0;
vt->avg += (vt->last - vt->avg) / vt->rate;
}
i = 0;
#define BITMAP(n, c, t, b) bits[i++] = (vt->n & 1) ? c : '-';
#include "cache_backend_poll.h"
......@@ -284,9 +300,10 @@ vbp_wrk_poll_backend(void *priv)
logmsg = "Still sick";
vt->backend->healthy = 0;
}
VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u",
VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f",
vt->backend->vcl_name, logmsg, bits,
vt->good, vt->probe.threshold, vt->probe.window);
vt->good, vt->probe.threshold, vt->probe.window,
vt->last, vt->avg);
if (!vt->stop)
dsleep(vt->probe.interval);
......@@ -325,6 +342,7 @@ vbp_health_one(struct cli *cli, const struct vbp_target *vt)
vt->backend->healthy ? "Healthy" : "Sick");
cli_out(cli, "Current states good: %2u threshold: %2u window: %2u\n",
vt->good, vt->probe.threshold, vt->probe.window);
cli_out(cli, "Average responsetime of good probes: %.6f\n", vt->avg);
cli_out(cli,
"Oldest "
" Newest\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment