Hi everyone,
it may be useful to know when a backend's health changed.
Please find attached a patch that expose last_changed in "varnishadm
backend.list".

This is 5.0 material because this patch could break any parser using
the actual 4.x varnishadm.(I.E. the varnish-agent)

-- 
Arianna Aondio
Field Engineer | Varnish Software Group
Mobile: +47 98062619
We Make Websites Fly
www.varnish-software.com
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 21f0782..f58f192 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -327,6 +327,7 @@ static int __match_proto__()
 do_list(struct cli *cli, struct backend *b, void *priv)
 {
 	int *probes;
+	char time_str[VTIM_FORMAT_SIZE];
 
 	AN(priv);
 	probes = priv;
@@ -337,16 +338,17 @@ do_list(struct cli *cli, struct backend *b, void *priv)
 	VCLI_Out(cli, " %-10s", b->admin_health);
 
 	if (b->probe == NULL)
-		VCLI_Out(cli, " %s", "Healthy (no probe)");
+		VCLI_Out(cli, " %-20s", "Healthy (no probe)");
 	else {
 		if (b->healthy)
-			VCLI_Out(cli, " %s", "Healthy ");
+			VCLI_Out(cli, " %-20s", "Healthy ");
 		else
-			VCLI_Out(cli, " %s", "Sick ");
+			VCLI_Out(cli, " %-20s", "Sick ");
 		VBP_Status(cli, b, *probes);
 	}
 
-	/* XXX: report b->health_changed */
+	VTIM_format(b->health_changed, time_str);
+	VCLI_Out(cli, " %s", time_str);
 
 	return (0);
 }
@@ -370,7 +372,8 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv)
 		VCLI_SetResult(cli, CLIS_PARAM);
 		return;
 	}
-	VCLI_Out(cli, "%-30s %-10s %s", "Backend name", "Admin", "Probe");
+	VCLI_Out(cli, "%-30s %-10s %-20s %s", "Backend name", "Admin",
+	    "Probe", "Last updated");
 	(void)backend_find(cli, av[2], do_list, &probes);
 }
 
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to