diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2015-09-21 14:51:31 -0400 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2015-09-21 14:52:01 -0400 |
commit | 9c1bbdef57160e9437e5aa33d3002dd81b406d3b (patch) | |
tree | b63f50944bd0608ba8afad59a168edf5cf5d01d3 /src/usr/local/www/status_queues.php | |
parent | 6bb806c65bce62e73f9c5cc618f9260c1e34549b (diff) | |
download | pfsense-9c1bbdef57160e9437e5aa33d3002dd81b406d3b.zip pfsense-9c1bbdef57160e9437e5aa33d3002dd81b406d3b.tar.gz |
Revision to teh file to fix header issues
Diffstat (limited to 'src/usr/local/www/status_queues.php')
-rw-r--r-- | src/usr/local/www/status_queues.php | 223 |
1 files changed, 107 insertions, 116 deletions
diff --git a/src/usr/local/www/status_queues.php b/src/usr/local/www/status_queues.php index e5e7f2a..022cd59 100644 --- a/src/usr/local/www/status_queues.php +++ b/src/usr/local/www/status_queues.php @@ -6,7 +6,7 @@ /* ==================================================================== * Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved. * Copyright (c) 2004, 2005 Scott Ullrich - * Copyright (c) 2009 Ermal Luçi + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * @@ -65,7 +65,6 @@ ##|*DESCR=Allow access to the 'Status: Traffic shaper: Queues' page. ##|*MATCH=status_queues.php* ##|-PRIV - /* header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT"); header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT"); @@ -74,7 +73,6 @@ header("Pragma: no-cache"); // HTTP/1.0 */ require("guiconfig.inc"); - class QueueStats { public $queuename; public $queuelength; @@ -84,16 +82,13 @@ class QueueStats { public $suspends; public $drops; } - if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid")) { - // Start in the background so we don't hang up the GUI + /* Start in the background so we don't hang up the GUI */ mwexec_bg("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid"); - // Give it a moment to start up + /* Give it a moment to start up */ sleep(1); } - $fd = @fsockopen("unix://{$g['varrun_path']}/qstats"); - if (!$fd) { $error = "Something wrong happened during communication with stat gathering"; } else { @@ -108,16 +103,15 @@ if (!$fd) { $error = "No queue statistics could be read."; } } - if ($_REQUEST['getactivity']) { $statistics = array(); $bigger_stat = 0; $stat_type = $_REQUEST['stats']; - // build the queue stats. + /* build the queue stats. */ foreach ($altqstats['queue'] as $q) { statsQueues($q); } - // calculate the bigger amount of packets or bandwidth being moved through all queues. + /* calculate the bigger amount of packets or bandwidth being moved through all queues. */ if ($stat_type == "0") { foreach ($statistics as $q) { if ($bigger_stat < $q->pps) { @@ -131,7 +125,6 @@ if ($_REQUEST['getactivity']) { } } } - $finscript = ""; foreach ($statistics as $q) { if ($stat_type == "0") { @@ -142,9 +135,6 @@ if ($_REQUEST['getactivity']) { if ($packet_s < 0) { $packet_s = 0; } - - $finscript .= '<script src="/jquery/jquery-1.11.2.min.js"></script>'; - $finscript .= '<script>'; $finscript .= "jQuery('#queue{$q->queuename}width').css('width','{$packet_s}%');"; $finscript .= "jQuery('#queue{$q->queuename}pps').val('" . number_format($q->pps, 1) . "');"; $finscript .= "jQuery('#queue{$q->queuename}bps').val('" . format_bits($q->bandwidth) . "');"; @@ -152,14 +142,112 @@ if ($_REQUEST['getactivity']) { $finscript .= "jQuery('#queue{$q->queuename}suspends').val('{$q->suspends}');"; $finscript .= "jQuery('#queue{$q->queuename}drops').val('{$q->drops}');"; $finscript .= "jQuery('#queue{$q->queuename}length').val('{$q->queuelength}');"; - $finscript .= '</script>'; } - unset($statistics, $altqstats); -// header("Content-type: text/javascript"); + header("Content-type: text/javascript"); echo $finscript; exit; } +$pgtitle = array(gettext("Status"), gettext("Traffic shaper"), gettext("Queues")); +$shortcut_section = "trafficshaper"; +include("head.inc"); +?> +<body> +<script src="/jquery/jquery-1.11.2.min.js"></script> +<?php +if (!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) { + print_info_box(gettext("Traffic shaping is not configured.")); + include("foot.inc"); + exit; +} +?> +<?php if (!$error): ?> +<form action="status_queues.php" method="post"> +<script type="text/javascript"> +//<![CDATA[ + function getqueueactivity() { + var url = "/status_queues.php"; + var pars = "getactivity=yes&stats=" + jQuery("#selStatistic").val(); + jQuery.ajax( + url, + { + type: 'post', + data: pars, + complete: activitycallback + }); + } + function activitycallback(transport) { + setTimeout('getqueueactivity()', 5100); + } + jQuery(document).ready(function() { + setTimeout('getqueueactivity()', 150); + }); +//]]> +</script> +<?php endif; + +if ($error): + print_info_box($error); +else: ?> + <div class="panel panel-default"> + <div class="panel-heading"><h2 class="panel-title"><?=gettext("Status Queues"); ?></h2></div> + <div class="panel-body table-responsive"> + <table class="table table-striped table-hover"> + <thead> + <tr> + <th><?=gettext("Queue"); ?></th> + <th><?=gettext("Statistics"); ?> + <select id="selStatistic"> + <option value="0">PPS</option> + <option value="1">Bandwidth</option> + </select> + </th> + <th><?=gettext("PPS"); ?></th> + <th><?=gettext("Bandwidth"); ?></th> + <th><?=gettext("Borrows"); ?></th> + <th><?=gettext("Suspends"); ?></th> + <th><?=gettext("Drops"); ?></th> + <th><?=gettext("Length"); ?></th> + </tr> + </thead> + <tbody> +<?php + $if_queue_list = get_configured_interface_list_by_realif(false, true); + processQueues($altqstats, 0, ""); +?> +<?php endif; ?> + </tbody> + </table> + <br /> +<?php + print_info_box(gettext("Queue graphs take 5 seconds to sample data")); +?> + </div> + </div> +</br> + +<?php + + + +?> + +<script type="text/javascript"> +//<![CDATA[ + function StatsShowHide(classname) { + var firstrow = jQuery("." + classname).first(); + if (firstrow.is(':visible')) { + jQuery("." + classname).hide(); + } else { + jQuery("." + classname).show(); + } + } +//]]> +</script> +</form> +<?php + +include("foot.inc"); function processQueues($altqstats, $level, $parent_name) { global $g; @@ -171,7 +259,6 @@ function processQueues($altqstats, $level, $parent_name) { $row_background = str_repeat(dechex($gray_value), 3); $parent_name = $parent_name . " queuerow" . $altqstats['name'] . $altqstats['interface']; $prev_if = $altqstats['interface']; - foreach ($altqstats['queue'] as $q) { $if_name = ""; foreach ($if_queue_list as $oif => $real_name) { @@ -180,7 +267,6 @@ function processQueues($altqstats, $level, $parent_name) { break; } } - if ($prev_if != $q['interface']) { echo "<tr><td><b>Interface ". htmlspecialchars(convert_real_interface_to_friendly_descr($q['interface'])) . "</b></td></tr>"; $prev_if = $q['interface']; @@ -220,7 +306,7 @@ function processQueues($altqstats, $level, $parent_name) { if (is_array($q['queue'])) { processQueues($q, $level + 1, $parent_name); } - } + }; } function statsQueues($xml) { @@ -245,12 +331,10 @@ function statsQueues($xml) { $current->drops += $child->drops; } } - unset($child); $statistics[] = $current; return $current; } - function format_bits($bits) { if ($bits >= 1000000000) { return sprintf("%.2f Gbps", $bits/1000000000); @@ -262,97 +346,4 @@ function format_bits($bits) { return sprintf("%d bps", $bits); } } - -$pgtitle = array(gettext("Status"), gettext("Traffic shaper"), gettext("Queues")); -$shortcut_section = "trafficshaper"; -include("head.inc"); - -/* -if (!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) { - print_info_box(gettext("Traffic shaping is not configured.")); - include("foot.inc"); - exit; -} -*/ -if (!$error): - print_info_box($error, 'danger'); -else: ?> -<form action="status_queues.php" method="post"> - <div class="panel panel-default"> - <div class="panel-heading"><h2 class="panel-title"><?=gettext("Status Queues"); ?></h2></div> - <div class="panel-body table-responsive"> - <table class="table table-striped table-hover"> - <thead> - <tr> - <th><?=gettext("Queue"); ?></th> - <th><?=gettext("Statistics"); ?> - <select id="selStatistic"> - <option value="0">PPS</option> - <option value="1">Bandwidth</option> - </select> - </th> - <th><?=gettext("PPS"); ?></th> - <th><?=gettext("Bandwidth"); ?></th> - <th><?=gettext("Borrows"); ?></th> - <th><?=gettext("Suspends"); ?></th> - <th><?=gettext("Drops"); ?></th> - <th><?=gettext("Length"); ?></th> - </tr> - </thead> - <tbody> -<?php - $if_queue_list = get_configured_interface_list_by_realif(false, true); - processQueues($altqstats, 0, ""); -?> - </tbody> - </table> - </div> - </div> -</form> -<?php - print_info_box(gettext("Queue graphs take 5 seconds to sample data")); -endif; - -?> - -<script type="text/javascript"> -//<![CDATA[ -events.push(function(){ - function StatsShowHide(classname) { - var firstrow = jQuery("." + classname).first(); - if (firstrow.is(':visible')) { - jQuery("." + classname).hide(); - } else { - jQuery("." + classname).show(); - } - } - - function getqueueactivity() { - var url = "/status_queues.php"; - var pars = "getactivity=yes&stats=" + jQuery("#selStatistic").val(); - - jQuery.ajax( - url, - { - type: 'post', - data: pars, - complete: activitycallback - } - ); - } - - function activitycallback(transport) { - setTimeout(function(){getqueueactivity()}, 5100); - } - - setTimeout(function(){getqueueactivity()}, 150); -}); - -//]]> -</script> - -<?php - -include("foot.inc"); - |