Monitoring backend status

Rob S rtshilston at
Wed Dec 9 12:31:28 CET 2009

Poul-Henning Kamp wrote:
> In message <4B1F7FED.4020501 at>, Mark Plomer writes:
>> Hi,
>> is it possible to retrieve some more details about the current backend 
>> status via the telnet interface?
>> A list of all backends with current status (up/down) would be very 
>> helpful for monitoring.
>> For the beginning, it would be enough to have the count of backends and 
>> the count of up-/down- backends
>> in the "stats" output.
> There is an undocumented "" command you can try.
> Ideas for a final version of this are most welcom.
Brilliant.  At the moment we tail the varnishlog, post process, and 
write out to disk for further monitoring.  Here's the PHP we're using:


$p = popen('varnishlog -u -i Backend_health','r');
$health = array();
while (!feof($p)) {
        $l = fgets($p);
        if ($m = preg_match("/^.*Backend_health - ([^ ]+) [^ ]+ ([^ ]+) 
/Uis", $l, $matches)) {
                if ($matches[2] != $health[$matches[1]]) {
                        $health[$matches[1]] = $matches[2];


Our monitoring then records "grep -c healthy /tmp/varnishbackendhealth"

However, it looks like we can now use the far simpler:

  echo '' | nc localhost 6082 |grep -c Healthy

So - thanks for the change!


More information about the varnish-misc mailing list