From 2dc85fc7519fe17550841919a6a1447495561e4c Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Mon, 24 Nov 2014 20:43:57 -0200 Subject: varnish - fixes for pfsense 2.2 and widget improvements --- config/varnish3/varnish.widget.php | 73 ++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 26 deletions(-) (limited to 'config/varnish3/varnish.widget.php') diff --git a/config/varnish3/varnish.widget.php b/config/varnish3/varnish.widget.php index b675f416..c6fdfe78 100755 --- a/config/varnish3/varnish.widget.php +++ b/config/varnish3/varnish.widget.php @@ -48,35 +48,56 @@ $img['Healthy']="
"; - print "Cache hits"; - print "Cache hits pass"; - print "Cache Missed"; +print "
";
+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();
 
-	$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 "".$cache['hits'] ."";
-	print "".$cache['hitsfor'] ."";
-	print "".$cache['misses']."";
- 	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 "Conn. Accepted";
-	print "Req. received";
-	print "Uptime";
-	print "".$client['connections'] ."";
-	print "".$client['requests'] ."";
-	print "".$client['uptime']."";
- 	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";
-- 
cgit v1.2.3