1 |
aa280d10
|
Bill Marquette
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
status_queues.php
|
4 |
|
|
*/
|
5 |
39881492
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
9c1bbdef
|
Stephen Beaver
|
*
|
8 |
39881492
|
Stephen Beaver
|
* Redistribution and use in source and binary forms, with or without modification,
|
9 |
|
|
* are permitted provided that the following conditions are met:
|
10 |
|
|
*
|
11 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
* this list of conditions and the following disclaimer.
|
13 |
|
|
*
|
14 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
* notice, this list of conditions and the following disclaimer in
|
16 |
|
|
* the documentation and/or other materials provided with the
|
17 |
|
|
* distribution.
|
18 |
|
|
*
|
19 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
20 |
|
|
* must display the following acknowledgment:
|
21 |
|
|
* "This product includes software developed by the pfSense Project
|
22 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23 |
|
|
*
|
24 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25 |
|
|
* endorse or promote products derived from this software without
|
26 |
|
|
* prior written permission. For written permission, please contact
|
27 |
|
|
* coreteam@pfsense.org.
|
28 |
|
|
*
|
29 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
30 |
|
|
* nor may "pfSense" appear in their names without prior written
|
31 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
32 |
|
|
*
|
33 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
34 |
|
|
* acknowledgment:
|
35 |
|
|
*
|
36 |
|
|
* "This product includes software developed by the pfSense Project
|
37 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38 |
|
|
*
|
39 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51 |
|
|
*
|
52 |
|
|
* ====================================================================
|
53 |
|
|
*
|
54 |
|
|
*/
|
55 |
aa280d10
|
Bill Marquette
|
|
56 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
57 |
|
|
##|*IDENT=page-status-trafficshaper-queues
|
58 |
5230f468
|
jim-p
|
##|*NAME=Status: Traffic shaper: Queues
|
59 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: Traffic shaper: Queues' page.
|
60 |
|
|
##|*MATCH=status_queues.php*
|
61 |
|
|
##|-PRIV
|
62 |
39881492
|
Stephen Beaver
|
/*
|
63 |
42b0c921
|
Phil Davis
|
header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
|
64 |
|
|
header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
|
65 |
|
|
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP/1.1
|
66 |
5f471c95
|
Ermal
|
header("Pragma: no-cache"); // HTTP/1.0
|
67 |
39881492
|
Stephen Beaver
|
*/
|
68 |
5f471c95
|
Ermal
|
|
69 |
aa280d10
|
Bill Marquette
|
require("guiconfig.inc");
|
70 |
21b94a54
|
Michele Di Maria
|
class QueueStats {
|
71 |
|
|
public $queuename;
|
72 |
2c5fda82
|
Jose Luis Duran
|
public $queuelength;
|
73 |
6ba3121b
|
Michele Di Maria
|
public $pps;
|
74 |
|
|
public $bandwidth;
|
75 |
21b94a54
|
Michele Di Maria
|
public $borrows;
|
76 |
|
|
public $suspends;
|
77 |
|
|
public $drops;
|
78 |
|
|
}
|
79 |
3a1e12cf
|
jim-p
|
if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid")) {
|
80 |
9c1bbdef
|
Stephen Beaver
|
/* Start in the background so we don't hang up the GUI */
|
81 |
a3eab908
|
Michele Di Maria
|
mwexec_bg("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid");
|
82 |
9c1bbdef
|
Stephen Beaver
|
/* Give it a moment to start up */
|
83 |
3a1e12cf
|
jim-p
|
sleep(1);
|
84 |
|
|
}
|
85 |
5f471c95
|
Ermal
|
$fd = @fsockopen("unix://{$g['varrun_path']}/qstats");
|
86 |
42b0c921
|
Phil Davis
|
if (!$fd) {
|
87 |
8545adde
|
k-paulius
|
$error = gettext("Something wrong happened during communication with stat gathering.");
|
88 |
3a1e12cf
|
jim-p
|
} else {
|
89 |
|
|
$stats = "";
|
90 |
6c07db48
|
Phil Davis
|
while (!feof($fd)) {
|
91 |
3a1e12cf
|
jim-p
|
$stats .= fread($fd, 4096);
|
92 |
42b0c921
|
Phil Davis
|
}
|
93 |
3a1e12cf
|
jim-p
|
fclose($fd);
|
94 |
|
|
@file_put_contents("{$g['tmp_path']}/qstats", $stats);
|
95 |
|
|
$altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats"));
|
96 |
42b0c921
|
Phil Davis
|
if ($altqstats == -1) {
|
97 |
3bd74348
|
bruno
|
$error = gettext("No queue statistics could be read.");
|
98 |
42b0c921
|
Phil Davis
|
}
|
99 |
5f471c95
|
Ermal
|
}
|
100 |
2c5fda82
|
Jose Luis Duran
|
if ($_REQUEST['getactivity']) {
|
101 |
21b94a54
|
Michele Di Maria
|
$statistics = array();
|
102 |
87428ee8
|
Michele Di Maria
|
$bigger_stat = 0;
|
103 |
|
|
$stat_type = $_REQUEST['stats'];
|
104 |
9c1bbdef
|
Stephen Beaver
|
/* build the queue stats. */
|
105 |
42b0c921
|
Phil Davis
|
foreach ($altqstats['queue'] as $q) {
|
106 |
21b94a54
|
Michele Di Maria
|
statsQueues($q);
|
107 |
|
|
}
|
108 |
9c1bbdef
|
Stephen Beaver
|
/* calculate the bigger amount of packets or bandwidth being moved through all queues. */
|
109 |
6c07db48
|
Phil Davis
|
if ($stat_type == "0") {
|
110 |
42b0c921
|
Phil Davis
|
foreach ($statistics as $q) {
|
111 |
|
|
if ($bigger_stat < $q->pps) {
|
112 |
87428ee8
|
Michele Di Maria
|
$bigger_stat = $q->pps;
|
113 |
42b0c921
|
Phil Davis
|
}
|
114 |
87428ee8
|
Michele Di Maria
|
}
|
115 |
6c07db48
|
Phil Davis
|
} else {
|
116 |
42b0c921
|
Phil Davis
|
foreach ($statistics as $q) {
|
117 |
|
|
if ($bigger_stat < $q->bandwidth) {
|
118 |
87428ee8
|
Michele Di Maria
|
$bigger_stat = $q->bandwidth;
|
119 |
42b0c921
|
Phil Davis
|
}
|
120 |
87428ee8
|
Michele Di Maria
|
}
|
121 |
2c5fda82
|
Jose Luis Duran
|
}
|
122 |
f2b8daad
|
Ermal Lu?i
|
$finscript = "";
|
123 |
42b0c921
|
Phil Davis
|
foreach ($statistics as $q) {
|
124 |
|
|
if ($stat_type == "0") {
|
125 |
9f605c1c
|
Hari
|
$packet_s = round(100 * ($q->pps / $bigger_stat), 0);
|
126 |
42b0c921
|
Phil Davis
|
} else {
|
127 |
9f605c1c
|
Hari
|
$packet_s = round(100 * ($q->bandwidth / $bigger_stat), 0);
|
128 |
42b0c921
|
Phil Davis
|
}
|
129 |
|
|
if ($packet_s < 0) {
|
130 |
|
|
$packet_s = 0;
|
131 |
|
|
}
|
132 |
3f98044a
|
Francisco Cavalcante
|
$finscript .= "$('#queue{$q->queuename}width').css('width','{$packet_s}%');";
|
133 |
|
|
$finscript .= "$('#queue{$q->queuename}pps').val('" . number_format($q->pps, 1) . "');";
|
134 |
|
|
$finscript .= "$('#queue{$q->queuename}bps').val('" . format_bits($q->bandwidth) . "');";
|
135 |
|
|
$finscript .= "$('#queue{$q->queuename}borrows').val('{$q->borrows}');";
|
136 |
|
|
$finscript .= "$('#queue{$q->queuename}suspends').val('{$q->suspends}');";
|
137 |
|
|
$finscript .= "$('#queue{$q->queuename}drops').val('{$q->drops}');";
|
138 |
|
|
$finscript .= "$('#queue{$q->queuename}length').val('{$q->queuelength}');";
|
139 |
21b94a54
|
Michele Di Maria
|
}
|
140 |
b06abfe3
|
Michele Di Maria
|
unset($statistics, $altqstats);
|
141 |
9c1bbdef
|
Stephen Beaver
|
header("Content-type: text/javascript");
|
142 |
f2b8daad
|
Ermal Lu?i
|
echo $finscript;
|
143 |
c5d63426
|
Bill Marquette
|
exit;
|
144 |
|
|
}
|
145 |
f4741421
|
k-paulius
|
$pgtitle = array(gettext("Status"), gettext("Queues"));
|
146 |
9c1bbdef
|
Stephen Beaver
|
$shortcut_section = "trafficshaper";
|
147 |
|
|
include("head.inc");
|
148 |
625c4a8b
|
Stephen Beaver
|
|
149 |
9c1bbdef
|
Stephen Beaver
|
if (!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) {
|
150 |
|
|
print_info_box(gettext("Traffic shaping is not configured."));
|
151 |
|
|
include("foot.inc");
|
152 |
|
|
exit;
|
153 |
|
|
}
|
154 |
625c4a8b
|
Stephen Beaver
|
|
155 |
|
|
if (!$error): ?>
|
156 |
9c1bbdef
|
Stephen Beaver
|
<form action="status_queues.php" method="post">
|
157 |
|
|
<script type="text/javascript">
|
158 |
|
|
//<![CDATA[
|
159 |
625c4a8b
|
Stephen Beaver
|
events.push(function() {
|
160 |
|
|
|
161 |
9c1bbdef
|
Stephen Beaver
|
function getqueueactivity() {
|
162 |
|
|
var url = "/status_queues.php";
|
163 |
3f98044a
|
Francisco Cavalcante
|
var pars = "getactivity=yes&stats=" + $("#selStatistic").val();
|
164 |
|
|
$.ajax(
|
165 |
9c1bbdef
|
Stephen Beaver
|
url,
|
166 |
|
|
{
|
167 |
|
|
type: 'post',
|
168 |
|
|
data: pars,
|
169 |
|
|
complete: activitycallback
|
170 |
|
|
});
|
171 |
|
|
}
|
172 |
625c4a8b
|
Stephen Beaver
|
|
173 |
9c1bbdef
|
Stephen Beaver
|
function activitycallback(transport) {
|
174 |
625c4a8b
|
Stephen Beaver
|
setTimeout(getqueueactivity, 5100);
|
175 |
9c1bbdef
|
Stephen Beaver
|
}
|
176 |
625c4a8b
|
Stephen Beaver
|
|
177 |
3f98044a
|
Francisco Cavalcante
|
$(document).ready(function() {
|
178 |
625c4a8b
|
Stephen Beaver
|
setTimeout(getqueueactivity, 150);
|
179 |
9c1bbdef
|
Stephen Beaver
|
});
|
180 |
625c4a8b
|
Stephen Beaver
|
});
|
181 |
9c1bbdef
|
Stephen Beaver
|
//]]>
|
182 |
|
|
</script>
|
183 |
|
|
<?php endif;
|
184 |
|
|
|
185 |
|
|
if ($error):
|
186 |
|
|
print_info_box($error);
|
187 |
|
|
else: ?>
|
188 |
|
|
<div class="panel panel-default">
|
189 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Status Queues"); ?></h2></div>
|
190 |
|
|
<div class="panel-body table-responsive">
|
191 |
|
|
<table class="table table-striped table-hover">
|
192 |
|
|
<thead>
|
193 |
|
|
<tr>
|
194 |
|
|
<th><?=gettext("Queue"); ?></th>
|
195 |
|
|
<th><?=gettext("Statistics"); ?>
|
196 |
e9feb2d4
|
Stephen Beaver
|
<select id="selStatistic" class="form-control">
|
197 |
3bd74348
|
bruno
|
<option value="0"><?=gettext("PPS");?></option>
|
198 |
|
|
<option value="1"><?=gettext("Bandwidth");?></option>
|
199 |
9c1bbdef
|
Stephen Beaver
|
</select>
|
200 |
|
|
</th>
|
201 |
|
|
<th><?=gettext("PPS"); ?></th>
|
202 |
|
|
<th><?=gettext("Bandwidth"); ?></th>
|
203 |
|
|
<th><?=gettext("Borrows"); ?></th>
|
204 |
|
|
<th><?=gettext("Suspends"); ?></th>
|
205 |
|
|
<th><?=gettext("Drops"); ?></th>
|
206 |
|
|
<th><?=gettext("Length"); ?></th>
|
207 |
|
|
</tr>
|
208 |
|
|
</thead>
|
209 |
|
|
<tbody>
|
210 |
|
|
<?php
|
211 |
|
|
$if_queue_list = get_configured_interface_list_by_realif(false, true);
|
212 |
|
|
processQueues($altqstats, 0, "");
|
213 |
|
|
?>
|
214 |
|
|
<?php endif; ?>
|
215 |
|
|
</tbody>
|
216 |
|
|
</table>
|
217 |
f78bbe16
|
Phil Davis
|
<br />
|
218 |
c95dabdd
|
Stephen Beaver
|
<div class="infoblock blockopen">
|
219 |
9c1bbdef
|
Stephen Beaver
|
<?php
|
220 |
8545adde
|
k-paulius
|
print_info_box(gettext("Queue graphs take 5 seconds to sample data."), 'info', false);
|
221 |
9c1bbdef
|
Stephen Beaver
|
?>
|
222 |
f78bbe16
|
Phil Davis
|
</div>
|
223 |
9c1bbdef
|
Stephen Beaver
|
</div>
|
224 |
|
|
</div>
|
225 |
9cad1b8e
|
Colin Fleming
|
<br/>
|
226 |
9c1bbdef
|
Stephen Beaver
|
|
227 |
|
|
<script type="text/javascript">
|
228 |
|
|
//<![CDATA[
|
229 |
|
|
function StatsShowHide(classname) {
|
230 |
3f98044a
|
Francisco Cavalcante
|
var firstrow = $("." + classname).first();
|
231 |
9c1bbdef
|
Stephen Beaver
|
if (firstrow.is(':visible')) {
|
232 |
3f98044a
|
Francisco Cavalcante
|
$("." + classname).hide();
|
233 |
9c1bbdef
|
Stephen Beaver
|
} else {
|
234 |
3f98044a
|
Francisco Cavalcante
|
$("." + classname).show();
|
235 |
9c1bbdef
|
Stephen Beaver
|
}
|
236 |
|
|
}
|
237 |
|
|
//]]>
|
238 |
|
|
</script>
|
239 |
|
|
</form>
|
240 |
|
|
<?php
|
241 |
|
|
|
242 |
|
|
include("foot.inc");
|
243 |
9f605c1c
|
Hari
|
|
244 |
42b0c921
|
Phil Davis
|
function processQueues($altqstats, $level, $parent_name) {
|
245 |
21b94a54
|
Michele Di Maria
|
global $g;
|
246 |
6ba3121b
|
Michele Di Maria
|
global $if_queue_list;
|
247 |
ebfbb1b3
|
Stephen Beaver
|
|
248 |
ff3003df
|
Michele Di Maria
|
$parent_name = $parent_name . " queuerow" . $altqstats['name'] . $altqstats['interface'];
|
249 |
1679b68c
|
Michele Di Maria
|
$prev_if = $altqstats['interface'];
|
250 |
6ba3121b
|
Michele Di Maria
|
foreach ($altqstats['queue'] as $q) {
|
251 |
|
|
$if_name = "";
|
252 |
1679b68c
|
Michele Di Maria
|
foreach ($if_queue_list as $oif => $real_name) {
|
253 |
|
|
if ($oif == $q['interface']) {
|
254 |
6ba3121b
|
Michele Di Maria
|
$if_name = $real_name;
|
255 |
|
|
break;
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
1679b68c
|
Michele Di Maria
|
if ($prev_if != $q['interface']) {
|
259 |
9cad1b8e
|
Colin Fleming
|
echo "<tr><td colspan=\"8\"><b>Interface " . htmlspecialchars(convert_real_interface_to_friendly_descr($q['interface'])) . "</b></td></tr>\n";
|
260 |
1679b68c
|
Michele Di Maria
|
$prev_if = $q['interface'];
|
261 |
|
|
}
|
262 |
42b0c921
|
Phil Davis
|
?>
|
263 |
5c0ab3cd
|
NewEraCracker
|
<tr class="<?=$parent_name;?>">
|
264 |
ebfbb1b3
|
Stephen Beaver
|
<td class="<?=$row_class?>" style="padding-left:<?=$level * 20?>px;">
|
265 |
9cad1b8e
|
Colin Fleming
|
<?php
|
266 |
|
|
if (is_array($q['queue'])) {
|
267 |
|
|
echo "<a href=\"#\" onclick=\"StatsShowHide('queuerow{$q['name']}{$q['interface']}');return false\">+/-</a>";
|
268 |
|
|
}
|
269 |
|
|
if (strstr($q['name'], "root_")) {
|
270 |
|
|
echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$if_name}&action=show\">Root queue</a>";
|
271 |
|
|
} else {
|
272 |
|
|
echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$q['name']}&action=show\">" . htmlspecialchars($q['name']) . "</a>";
|
273 |
|
|
}
|
274 |
|
|
?>
|
275 |
ff3003df
|
Michele Di Maria
|
</td>
|
276 |
42b0c921
|
Phil Davis
|
<?php
|
277 |
|
|
$cpuUsage = 0;
|
278 |
6c961924
|
Stephen Beaver
|
print('<td>');
|
279 |
ebfbb1b3
|
Stephen Beaver
|
print('<div class="progress" style="height: 7px;width: 170px;">');
|
280 |
|
|
print(' <div class="progress-bar" role="progressbar" id="queue' . $q['name'] . $q['interface'] . 'width" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: ' . $cpuUsage*100 . '%;\"></div>');
|
281 |
|
|
print(' </div>');
|
282 |
|
|
print('</td>');
|
283 |
6c961924
|
Stephen Beaver
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'pps" id="queue' . $q['name'] . $q['interface'] . 'pps" value="(' . gettext("Loading") . ')" /></td>');
|
284 |
|
|
print('<td><input readonly style="border:0;width:80px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'bps" id="queue' . $q['name'] . $q['interface'] . 'bps" value="" /></td>');
|
285 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'borrows" id="queue' . $q['name'] . $q['interface'] . 'borrows" value="" /></td>');
|
286 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'suspends" id="queue' . $q['name'] . $q['interface'] . 'suspends" value="" /></td>');
|
287 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'drops" id="queue' . $q['name'] . $q['interface'] . 'drops" value="" /></td>');
|
288 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="queue' . $q['name'] . $q['interface'] . 'length" id="queue' . $q['name'] . $q['interface'] . 'length" value="" /></td>');
|
289 |
42b0c921
|
Phil Davis
|
?>
|
290 |
21b94a54
|
Michele Di Maria
|
</tr>
|
291 |
42b0c921
|
Phil Davis
|
<?php
|
292 |
|
|
if (is_array($q['queue'])) {
|
293 |
ff3003df
|
Michele Di Maria
|
processQueues($q, $level + 1, $parent_name);
|
294 |
42b0c921
|
Phil Davis
|
}
|
295 |
9c1bbdef
|
Stephen Beaver
|
};
|
296 |
21b94a54
|
Michele Di Maria
|
}
|
297 |
39881492
|
Stephen Beaver
|
|
298 |
42b0c921
|
Phil Davis
|
function statsQueues($xml) {
|
299 |
21b94a54
|
Michele Di Maria
|
global $statistics;
|
300 |
b06abfe3
|
Michele Di Maria
|
|
301 |
21b94a54
|
Michele Di Maria
|
$current = new QueueStats();
|
302 |
|
|
$child = new QueueStats();
|
303 |
|
|
$current->queuename = $xml['name'] . $xml['interface'];
|
304 |
2c5fda82
|
Jose Luis Duran
|
$current->queuelength = $xml['qlength'];
|
305 |
ff3003df
|
Michele Di Maria
|
$current->pps = $xml['measured'];
|
306 |
|
|
$current->bandwidth = $xml['measuredspeedint'];
|
307 |
21b94a54
|
Michele Di Maria
|
$current->borrows = intval($xml['borrows']);
|
308 |
|
|
$current->suspends = intval($xml['suspends']);
|
309 |
8e006931
|
Michele Di Maria
|
$current->drops = intval($xml['droppedpkts']);
|
310 |
1679b68c
|
Michele Di Maria
|
if (is_array($xml['queue'])) {
|
311 |
42b0c921
|
Phil Davis
|
foreach ($xml['queue'] as $q) {
|
312 |
21b94a54
|
Michele Di Maria
|
$child = statsQueues($q);
|
313 |
|
|
$current->pps += $child->pps;
|
314 |
|
|
$current->bandwidth += $child->bandwidth;
|
315 |
|
|
$current->borrows += $child->borrows;
|
316 |
|
|
$current->suspends += $child->suspends;
|
317 |
|
|
$current->drops += $child->drops;
|
318 |
|
|
}
|
319 |
|
|
}
|
320 |
a3eab908
|
Michele Di Maria
|
unset($child);
|
321 |
21b94a54
|
Michele Di Maria
|
$statistics[] = $current;
|
322 |
|
|
return $current;
|
323 |
|
|
}
|
324 |
b06abfe3
|
Michele Di Maria
|
function format_bits($bits) {
|
325 |
|
|
if ($bits >= 1000000000) {
|
326 |
|
|
return sprintf("%.2f Gbps", $bits/1000000000);
|
327 |
|
|
} else if ($bits >= 1000000) {
|
328 |
|
|
return sprintf("%.2f Mbps", $bits/1000000);
|
329 |
|
|
} else if ($bits >= 1000) {
|
330 |
31e41cf4
|
Michele Di Maria
|
return sprintf("%.2f Kbps", $bits/1000);
|
331 |
b06abfe3
|
Michele Di Maria
|
} else {
|
332 |
31e41cf4
|
Michele Di Maria
|
return sprintf("%d bps", $bits);
|
333 |
b06abfe3
|
Michele Di Maria
|
}
|
334 |
|
|
}
|
335 |
39881492
|
Stephen Beaver
|
?>
|