From 78f7be7ec9ea368bc26bd06208f80d9ffb290347 Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Thu, 10 Nov 2011 20:03:20 -0200 Subject: varnish - include widget --- config/varnish64/varnish.widget.php | 126 ++++++++++++++++++++++++++++++++++ config/varnish64/varnish_backends.xml | 5 ++ 2 files changed, 131 insertions(+) create mode 100755 config/varnish64/varnish.widget.php (limited to 'config/varnish64') diff --git a/config/varnish64/varnish.widget.php b/config/varnish64/varnish.widget.php new file mode 100755 index 00000000..f2b68aec --- /dev/null +++ b/config/varnish64/varnish.widget.php @@ -0,0 +1,126 @@ +"; + 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("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 "".$client['connections'] .""; + print "".$client['requests'] .""; + print "".$client['uptime'].""; + close_table(); + + 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"
"; + +?> + diff --git a/config/varnish64/varnish_backends.xml b/config/varnish64/varnish_backends.xml index 417cc8a1..d9597dd3 100644 --- a/config/varnish64/varnish_backends.xml +++ b/config/varnish64/varnish_backends.xml @@ -60,6 +60,11 @@ 0755 http://www.pfsense.com/packages/config/varnish64/varnish_custom_vcl.xml + + /usr/local/www/widgets/widgets + 0755 + http://www.pfsense.com/packages/config/varnish64/varnish.widget.php + /usr/local/pkg/ 0755 -- cgit v1.2.3