aboutsummaryrefslogtreecommitdiffstats
path: root/config/varnish3/varnish.widget.php
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2014-11-24 20:43:57 -0200
committerMarcello Coutinho <marcellocoutinho@gmail.com>2014-11-24 20:43:57 -0200
commit2dc85fc7519fe17550841919a6a1447495561e4c (patch)
tree256566dd05f3682b5a24de8375ee4101eae97581 /config/varnish3/varnish.widget.php
parenta0e6733ec5638d12bdef256bdba7b1439cd56bfe (diff)
downloadpfsense-packages-2dc85fc7519fe17550841919a6a1447495561e4c.tar.gz
pfsense-packages-2dc85fc7519fe17550841919a6a1447495561e4c.tar.bz2
pfsense-packages-2dc85fc7519fe17550841919a6a1447495561e4c.zip
varnish - fixes for pfsense 2.2 and widget improvements
Diffstat (limited to 'config/varnish3/varnish.widget.php')
-rwxr-xr-xconfig/varnish3/varnish.widget.php73
1 files changed, 47 insertions, 26 deletions
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']="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_up
?><div id='varnish'><?php
open_table();
-if ($config['installedpackages']['varnishsettings']['config'][0])
- $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>";
+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();
- $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\">".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=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=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'];
+if ($mgm != ""){
open_table();
print "<td class=\"vncellt\" width=30%><strong>Backend</strong></td>";
print "<td class=\"vncellt\" width=30%><strong>LB applied</strong></td>";