";
echo"
";
}
function close_table(){
echo"
";
echo"";
echo "
";
}
$pfb_table=array();
$img['Sick']="";
$img['Healthy']="";
#var_dump($pfb_table);
#exit;
?>";
print "
Cache hits | ";
print "Cache hits pass | ";
print "Cache Missed | ";
$backends=exec("varnishstat -1",$debug);
foreach ($debug as $line){
if (preg_match("/(\S+)\s+(\d+)/",$line,$matches))
$vs[$matches[1]]=$matches[2];
}
print "".number_format($vs['cache_hit']) ." | ";
print "".number_format($vs['cache_hitpass']) ." | ";
print "".number_format($vs['cache_miss'])." | ";
close_table();
open_table();
print "Conn. Accepted | ";
print "Req. received | ";
print "Uptime | ";
print "".number_format($vs['client_conn']) ." | ";
print "".number_format($vs['client_req']) ." | ";
print "".(int)($vs['uptime'] / 86400) . "+ ". gmdate("H:i:s",($vs['uptime'] % 86400))." | ";
close_table();
open_table();
print "Host | ";
print "Header(Rx) | ";
print "Header(Tx) | ";
unset($debug);
$backends=exec("varnishtop -I '^Host:' -1",$debug);
foreach ($debug as $line){
if (preg_match("/(\S+)\s+(\w+)Header.Host: (\S+)/",$line,$lm))
$varnish_hosts[$lm[3]][$lm[2]]=$lm[1];
}
if (is_array($varnish_hosts)){
foreach ($varnish_hosts as $v_key=>$v_value){
print "". $v_key ." | ";
print "". number_format($v_value['Rx']) ." | ";
print "".number_format($v_value['Tx'])." | ";
}
}
else{
print "No traffic | | | ";
}
close_table();
if ($config['installedpackages']['varnishsettings']['config'][0])
$mgm=$config['installedpackages']['varnishsettings']['config'][0]['managment'];
if ($mgm != ""){
open_table();
print "Backend | ";
print "LB applied | ";
print "Status | ";
if (is_array($config['installedpackages']['varnishlbdirectors']['config']))
foreach($config['installedpackages']['varnishlbdirectors']['config'] as $lb){
foreach ($lb['row'] as $lb_backend){
${$lb_backend['backendname']}++;
}
}
$backends=exec("varnishadm -T " . escapeshellarg($mgm) . " debug.health",$debug);
foreach ($debug as $line){
if (preg_match("/Backend (.*) is (\w+)/",$line,$matches)){
$backend=preg_replace("/BACKEND$/","",$matches[1]);
print "". $backend ." | ";
print "". ${$backend} ." | ";
print "".$img[$matches[2]]." | ";
}
}
}
else{
print "Varnish Managment interface not set in config. | ";
}
echo" ";
echo"";
?>