aboutsummaryrefslogtreecommitdiffstats
path: root/config/varnish3/varnish.widget.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/varnish3/varnish.widget.php')
-rwxr-xr-xconfig/varnish3/varnish.widget.php89
1 files changed, 55 insertions, 34 deletions
diff --git a/config/varnish3/varnish.widget.php b/config/varnish3/varnish.widget.php
index 35723e95..c6fdfe78 100755
--- a/config/varnish3/varnish.widget.php
+++ b/config/varnish3/varnish.widget.php
@@ -1,7 +1,7 @@
-<?php
+<?php
/*
Copyright 2011 Thomas Schaefer - Tomschaefer.org
- Copyright 2011 Marcello Coutinho
+ Copyright 2011-2014 Marcello Coutinho
Part of pfSense widgets (www.pfsense.org)
Redistribution and use in source and binary forms, with or without
@@ -45,38 +45,59 @@ $img['Healthy']="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_up
#var_dump($pfb_table);
#exit;
-?><div id='varnish'><?php
+?><div id='varnish'><?php
open_table();
+print "<pre>";
+print "<td class=\"vncellt\"width=30%><strong>Cache hits</strong></td>";
+print "<td class=\"vncellt\"width=30%><strong>Cache hits pass</strong></td>";
+print "<td class=\"vncellt\"width=30%><strong>Cache Missed</strong></td></tr>";
+$backends=exec("varnishstat -1",$debug);
+foreach ($debug as $line){
+ if (preg_match("/(\S+)\s+(\d+)/",$line,$matches))
+ $vs[$matches[1]]=$matches[2];
+ }
+print "<td class=\"listlr\">".number_format($vs['cache_hit']) ."</td>";
+print "<td class=\"listlr\">".number_format($vs['cache_hitpass']) ."</td>";
+print "<td class=\"listlr\">".number_format($vs['cache_miss'])."</td></tr>";
+close_table();
+
+open_table();
+print "<td class=\"vncellt\" width=30%><strong>Conn. Accepted</strong></td>";
+print "<td class=\"vncellt\" width=30%><strong>Req. received</strong></td>";
+print "<td class=\"vncellt\" width=30%><strong>Uptime</strong></td></tr>";
+print "<td class=\"listlr\">".number_format($vs['client_conn']) ."</td>";
+print "<td class=\"listlr\">".number_format($vs['client_req']) ."</td>";
+print "<td class=\"listlr\">".(int)($vs['uptime'] / 86400) . "+ ". gmdate("H:i:s",($vs['uptime'] % 86400))."</td></tr>";
+close_table();
+
+open_table();
+print "<td class=\"vncellt\" width=70%><strong>Host</strong></td>";
+print "<td class=\"vncellt\" width=15%><strong>Header(Rx)</strong></td>";
+print "<td class=\"vncellt\" width=15%><strong>Header(Tx)</strong></td></tr>";
+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 "<td class=\"listlr\">". $v_key ."</td>";
+ print "<td class=\"listlr\" align=\"Right\">". number_format($v_value['Rx']) ."</td>";
+ print "<td class=\"listlr\" align=\"Right\">".number_format($v_value['Tx'])."</td></tr>";
+ }
+}
+else{
+ print "<td class=\"listlr\">No traffic</td><td class=\"listlr\"></td><td class=\"listlr\"></td></tr>";
+}
+
+close_table();
+
+
if ($config['installedpackages']['varnishsettings']['config'][0])
- $mgm=$config['installedpackages']['varnishsettings']['config'][0]['managment'];
+ $mgm=$config['installedpackages']['varnishsettings']['config'][0]['managment'];
if ($mgm != ""){
- print "<pre>";
- print "<td class=\"vncellt\"width=30%><strong>Cache hits</strong></td>";
- print "<td class=\"vncellt\"width=30%><strong>Cache hits pass</strong></td>";
- print "<td class=\"vncellt\"width=30%><strong>Cache Missed</strong></td></tr>";
-
- $backends=exec("varnishadm -T " . escapeshellarg($mgm) . " stats",$debug);
- foreach ($debug as $line){
- if (preg_match("/(\d+)\s+Cache\s+(hits.for|hits|misses)/",$line,$matches))
- $cache[preg_replace("/\s+/","",$matches[2])]=$matches[1];
- if (preg_match("/(\d+)\s+Client\s+(\w+)/",$line,$matches))
- $client[$matches[2]]=$matches[1];
- }
- print "<td class=\"listlr\">".$cache['hits'] ."</td>";
- print "<td class=\"listlr\">".$cache['hitsfor'] ."</td>";
- print "<td class=\"listlr\">".$cache['misses']."</td></tr>";
- close_table();
-
- open_table();
- print "<td class=\"vncellt\" width=30%><strong>Conn. Accepted</strong></td>";
- print "<td class=\"vncellt\" width=30%><strong>Req. received</strong></td>";
- print "<td class=\"vncellt\" width=30%><strong>Uptime</strong></td></tr>";
- print "<td class=\"listlr\">".$client['connections'] ."</td>";
- print "<td class=\"listlr\">".$client['requests'] ."</td>";
- print "<td class=\"listlr\">".$client['uptime']."</td></tr>";
- close_table();
-
open_table();
print "<td class=\"vncellt\" width=30%><strong>Backend</strong></td>";
print "<td class=\"vncellt\" width=30%><strong>LB applied</strong></td>";
@@ -86,20 +107,20 @@ if ($mgm != ""){
foreach ($lb['row'] as $lb_backend){
${$lb_backend['backendname']}++;
}
- }
- $backends=exec("varnishadm -T " . escapeshellarg($mgm) . " debug.health",$debug);
+ }
+ $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 "<td class=\"listlr\">". $backend ."</td>";
print "<td class=\"listlr\">". ${$backend} ."</td>";
- print "<td class=\"listlr\">".$img[$matches[2]]."</td></tr>";
+ print "<td class=\"listlr\">".$img[$matches[2]]."</td></tr>";
}
}
}
else{
print "<td class=\"listlr\">Varnish Managment interface not set in config.</td></tr>";
-}
+}
echo" </tr>";
echo"</table></div>";