From a0e6733ec5638d12bdef256bdba7b1439cd56bfe Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Mon, 24 Nov 2014 17:30:04 -0200 Subject: varnish3 - indent / spaces fixes --- config/varnish3/varnish.widget.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'config/varnish3/varnish.widget.php') diff --git a/config/varnish3/varnish.widget.php b/config/varnish3/varnish.widget.php index 35723e95..b675f416 100755 --- a/config/varnish3/varnish.widget.php +++ b/config/varnish3/varnish.widget.php @@ -1,7 +1,7 @@ -
"; print "Cache hits"; - print "Cache hits pass"; + print "Cache hits pass"; print "Cache Missed"; - - $backends=exec("varnishadm -T " . escapeshellarg($mgm) . " stats",$debug); + + $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]; + $client[$matches[2]]=$matches[1]; } print "".$cache['hits'] .""; print "".$cache['hitsfor'] .""; - print "".$cache['misses'].""; + print "".$cache['misses'].""; close_table(); - + open_table(); - print "Conn. Accepted"; + print "Conn. Accepted"; print "Req. received"; print "Uptime"; print "".$client['connections'] .""; print "".$client['requests'] .""; print "".$client['uptime'].""; close_table(); - + open_table(); print "Backend"; print "LB applied"; @@ -86,20 +86,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 "". $backend .""; print "". ${$backend} .""; - print "".$img[$matches[2]].""; + print "".$img[$matches[2]].""; } } } else{ print "Varnish Managment interface not set in config."; -} +} echo" "; echo"
"; -- cgit v1.2.3 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