From 21b94a54441c0a9e04b8e6452ebeb4a1e07cbaf0 Mon Sep 17 00:00:00 2001 From: Michele Di Maria Date: Tue, 29 Jan 2013 21:37:02 +0100 Subject: Feature #2781: Hierarchical view of "Status-Queues" page First version of the new "Status-Queue" page. Requires the pfsense-tools/pfPorts/qstats/files/stats.c file to be recompiled. --- usr/local/www/status_queues.php | 230 ++++++++++++++++++++++++---------------- 1 file changed, 136 insertions(+), 94 deletions(-) (limited to 'usr') diff --git a/usr/local/www/status_queues.php b/usr/local/www/status_queues.php index 21908ef..8a08547 100755 --- a/usr/local/www/status_queues.php +++ b/usr/local/www/status_queues.php @@ -48,16 +48,22 @@ header("Cache-Control: post-check=0, pre-check=0", FALSE ); header("Pragma: no-cache"); // HTTP/1.0 require("guiconfig.inc"); - +class QueueStats { + public $queuename; + public $pps; + public $bandwidth; + public $borrows; + 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 */ - mwexec_bg("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid"); + /* 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 */ sleep(1); } - $fd = @fsockopen("unix://{$g['varrun_path']}/qstats"); -if (!$fd) { + if (!$fd) { $error = "Something wrong happened during comunication with stat gathering"; } else { $stats = ""; @@ -69,119 +75,155 @@ if (!$fd) { if ($altqstats == -1) $error = "No queue statistics could be read."; } -if ($_REQUEST['getactivity']) { - /* calculate total packets being moved through all queues. */ - $total_packets_s = 0; - foreach($altqstats['queue'] as $q) { - if (strstr($q['name'], "root_")) - continue; - $total_packets_s = $total_packets_s + intval($q['pkts']); - } - +if ($_REQUEST['getactivity']) { + $statistics = array(); + $bigger_packets = 0; + /* build the queue stats. */ + foreach($altqstats['queue'] as $q) { + statsQueues($q); + } + /* calculate the bigger amount of packets being moved through all queues. */ + foreach($statistics as $q) { + if ($bigger_packets < $q->pps) + {$bigger_packets = $q->pps;} + } $finscript = ""; - foreach($altqstats['queue'] as $q) { - if (strstr($q['name'], "root_")) - continue; - - $packet_s = round(400 * (1 - $q['pkts']/ $total_packets_s), 0); - - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}widthb').width('{$packet_s}');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}widtha').width('" . (400 - $packet_s) . "');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}pps').val('{$q['measured']}/pps');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}bps').val('{$q['measuredspeed']}');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}borrows').val('{$q['borrows']} borrows');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}suspends').val('{$q['suspends']} suspends');"; - $finscript .= "jQuery('#queue{$q['name']}{$q['interface']}drops').val('{$q['droppedpkts']} drops');"; - } + foreach($statistics as $q) { + $packet_s = round(200 * (1 - $q->pps / $bigger_packets), 0); + if ($packet_s < 0) {$packet_s = 0;} + $finscript .= "jQuery('#queue{$q->queuename}widthb').width('{$packet_s}');"; + $finscript .= "jQuery('#queue{$q->queuename}widtha').width('" . (200 - $packet_s) . "');"; + $finscript .= "jQuery('#queue{$q->queuename}pps').val('{$q->pps}');"; + $finscript .= "jQuery('#queue{$q->queuename}bps').val('" . str_replace("bytes", "B", format_bytes($q->bandwidth)) . "ps');"; + $finscript .= "jQuery('#queue{$q->queuename}borrows').val('{$q->borrows}');"; + $finscript .= "jQuery('#queue{$q->queuename}suspends').val('{$q->suspends}');"; + $finscript .= "jQuery('#queue{$q->queuename}drops').val('{$q->drops}');"; + } header("Content-type: text/javascript"); echo $finscript; exit; } - $pgtitle = array(gettext("Status"),gettext("Traffic shaper"),gettext("Queues")); $shortcut_section = "trafficshaper"; include("head.inc"); - ?> -
- +
- + - - - - - - - - - "; - echo " - - - + + + + + + + + + + -
 
-    " . htmlspecialchars($q['name'] . " on " . convert_real_interface_to_friendly_descr($q['interface'])) . "";?>    - -"; - echo ""; - echo ""; - echo " "; - echo "
"; - echo "                "; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; -?> - -
 
-

- :
- .
- . -

+ +

+ :
+ .
+ . +

+ + + + + " . htmlspecialchars(convert_real_interface_to_friendly_descr($q['interface'])) . ""; + } + else + { + echo "" . htmlspecialchars($q['name']) . ""; + } + ?> + + + "; + echo ""; + echo ""; + echo ""; + echo " "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?> + + queuename = $xml['name'] . $xml['interface']; + $current->pps = intval($xml['pkts']); + $current->bandwidth = intval($xml['measuredspeedint']); + $current->borrows = intval($xml['borrows']); + $current->suspends = intval($xml['suspends']); + $current->drops = intval($xml['drops']); + if (is_array($xml['queue'])) + { + foreach($xml['queue'] as $q) { + $child = statsQueues($q); + $current->pps += $child->pps; + $current->bandwidth += $child->bandwidth; + $current->borrows += $child->borrows; + $current->suspends += $child->suspends; + $current->drops += $child->drops; + } + } + $statistics[] = $current; + return $current; +} +?> \ No newline at end of file -- cgit v1.1