1 |
aa280d10
|
Bill Marquette
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_queues.php
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
|
|
*
|
9 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10 |
|
|
* you may not use this file except in compliance with the License.
|
11 |
|
|
* You may obtain a copy of the License at
|
12 |
c5d81585
|
Renato Botelho
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
c5d81585
|
Renato Botelho
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
16 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18 |
|
|
* See the License for the specific language governing permissions and
|
19 |
|
|
* limitations under the License.
|
20 |
39881492
|
Stephen Beaver
|
*/
|
21 |
aa280d10
|
Bill Marquette
|
|
22 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-status-trafficshaper-queues
|
24 |
48157a04
|
Phil Davis
|
##|*NAME=Status: Traffic Shaper: Queues
|
25 |
|
|
##|*DESCR=Allow access to the 'Status: Traffic Shaper: Queues' page.
|
26 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=status_queues.php*
|
27 |
|
|
##|-PRIV
|
28 |
39881492
|
Stephen Beaver
|
/*
|
29 |
42b0c921
|
Phil Davis
|
header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
|
30 |
|
|
header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
|
31 |
|
|
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP/1.1
|
32 |
5f471c95
|
Ermal
|
header("Pragma: no-cache"); // HTTP/1.0
|
33 |
39881492
|
Stephen Beaver
|
*/
|
34 |
5f471c95
|
Ermal
|
|
35 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
36 |
21b94a54
|
Michele Di Maria
|
class QueueStats {
|
37 |
|
|
public $queuename;
|
38 |
2c5fda82
|
Jose Luis Duran
|
public $queuelength;
|
39 |
6ba3121b
|
Michele Di Maria
|
public $pps;
|
40 |
|
|
public $bandwidth;
|
41 |
21b94a54
|
Michele Di Maria
|
public $borrows;
|
42 |
|
|
public $suspends;
|
43 |
|
|
public $drops;
|
44 |
|
|
}
|
45 |
0e2bed22
|
PiBa-NL
|
|
46 |
|
|
include_once("shaper.inc");
|
47 |
|
|
|
48 |
|
|
$stats = get_queue_stats();
|
49 |
|
|
|
50 |
f4741421
|
k-paulius
|
$pgtitle = array(gettext("Status"), gettext("Queues"));
|
51 |
9c1bbdef
|
Stephen Beaver
|
$shortcut_section = "trafficshaper";
|
52 |
|
|
include("head.inc");
|
53 |
625c4a8b
|
Stephen Beaver
|
|
54 |
9c1bbdef
|
Stephen Beaver
|
if (!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) {
|
55 |
|
|
print_info_box(gettext("Traffic shaping is not configured."));
|
56 |
|
|
include("foot.inc");
|
57 |
|
|
exit;
|
58 |
|
|
}
|
59 |
625c4a8b
|
Stephen Beaver
|
|
60 |
|
|
if (!$error): ?>
|
61 |
9c1bbdef
|
Stephen Beaver
|
<form action="status_queues.php" method="post">
|
62 |
|
|
<script type="text/javascript">
|
63 |
|
|
//<![CDATA[
|
64 |
0e2bed22
|
PiBa-NL
|
var refreshrate = 1000;
|
65 |
|
|
var queuestathistorylength = 0;
|
66 |
|
|
var queuestathistory = [];
|
67 |
|
|
var queuestatprevious = [];
|
68 |
|
|
var timestampprevious;
|
69 |
|
|
var graphstatmax = 0;
|
70 |
625c4a8b
|
Stephen Beaver
|
events.push(function() {
|
71 |
0e2bed22
|
PiBa-NL
|
$('#updatespeed').on('change', function() {
|
72 |
|
|
refreshrate = $("#updatespeed").val();
|
73 |
|
|
});
|
74 |
625c4a8b
|
Stephen Beaver
|
|
75 |
9c1bbdef
|
Stephen Beaver
|
function getqueueactivity() {
|
76 |
0e2bed22
|
PiBa-NL
|
var url = "/getqueuestats.php";
|
77 |
|
|
var pars = "format=json";
|
78 |
3f98044a
|
Francisco Cavalcante
|
$.ajax(
|
79 |
9c1bbdef
|
Stephen Beaver
|
url,
|
80 |
|
|
{
|
81 |
|
|
type: 'post',
|
82 |
|
|
data: pars,
|
83 |
|
|
complete: activitycallback
|
84 |
|
|
});
|
85 |
|
|
}
|
86 |
0e2bed22
|
PiBa-NL
|
|
87 |
|
|
function escapeStr(str)
|
88 |
|
|
{
|
89 |
|
|
if (str)
|
90 |
|
|
return str.replace(/([ #;?%&,.+*~\':"!^$[\]()=>|\/@])/g,'\\$1');
|
91 |
|
|
return str;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
9c1bbdef
|
Stephen Beaver
|
function activitycallback(transport) {
|
95 |
0e2bed22
|
PiBa-NL
|
setTimeout(getqueueactivity, refreshrate);
|
96 |
|
|
json = transport.responseJSON;
|
97 |
|
|
if (!json) {
|
98 |
|
|
return;
|
99 |
|
|
}
|
100 |
|
|
timestamp = json.timestamp;
|
101 |
|
|
timestampdiff = timestamp - timestampprevious;
|
102 |
|
|
$stattype = $('#selStatistic').val();
|
103 |
|
|
|
104 |
|
|
interfacename_stats = [];
|
105 |
|
|
for (interfacename in json.interfacestats) {
|
106 |
|
|
var queueparents = [];
|
107 |
|
|
interface = json.interfacestats[interfacename];
|
108 |
|
|
interfacename_stats[interfacename] = [];
|
109 |
|
|
for (queuename in interface) {
|
110 |
|
|
queue = interface[queuename];
|
111 |
|
|
statqname = queue['name'] + queue['interface'];
|
112 |
|
|
|
113 |
|
|
for(childnr in queue['contains']) {
|
114 |
|
|
child = queue['contains'][childnr];
|
115 |
|
|
if (!queueparents[child]) {
|
116 |
|
|
queueparents[child] = [];
|
117 |
|
|
}
|
118 |
|
|
queueparents[child] = queuename;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
if (queuestatprevious[statqname]) {
|
122 |
|
|
interfacename_stats[interfacename][statqname] = [];
|
123 |
|
|
pkts_ps = (queue['pkts'] - queuestatprevious[statqname]['pkts']) / timestampdiff
|
124 |
|
|
bytes_ps = (queue['bytes'] - queuestatprevious[statqname]['bytes']) / timestampdiff
|
125 |
|
|
droppedpkts = parseFloat(queue['droppedpkts']);
|
126 |
|
|
borrows = parseFloat(queue['borrows']);
|
127 |
|
|
suspends = parseFloat(queue['suspends']);
|
128 |
|
|
interfacename_stats[interfacename][statqname]['pkts_ps'] = pkts_ps;
|
129 |
|
|
interfacename_stats[interfacename][statqname]['bytes_ps'] = bytes_ps;
|
130 |
|
|
interfacename_stats[interfacename][statqname]['borrows'] = borrows;
|
131 |
|
|
interfacename_stats[interfacename][statqname]['suspends'] = suspends;
|
132 |
|
|
interfacename_stats[interfacename][statqname]['droppedpkts'] = droppedpkts;
|
133 |
|
|
interfacename_stats[interfacename][statqname]['qlengthitems'] = queue['qlengthitems'];
|
134 |
|
|
interfacename_stats[interfacename][statqname]['qlengthsize'] = queue['qlengthsize'];
|
135 |
|
|
find = queuename;
|
136 |
|
|
while(queueparents[find]) {
|
137 |
|
|
// add diff values also to parent queues
|
138 |
|
|
parentname = queueparents[find];
|
139 |
|
|
parentqueuename = parentname+interfacename;
|
140 |
|
|
interfacename_stats[interfacename][parentqueuename]['pkts_ps'] += pkts_ps;
|
141 |
|
|
interfacename_stats[interfacename][parentqueuename]['bytes_ps'] += bytes_ps;
|
142 |
|
|
interfacename_stats[interfacename][parentqueuename]['borrows'] += borrows;
|
143 |
|
|
interfacename_stats[interfacename][parentqueuename]['suspends'] += suspends;
|
144 |
|
|
interfacename_stats[interfacename][parentqueuename]['droppedpkts'] += droppedpkts;
|
145 |
|
|
find = parentname;
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
queuestatprevious[statqname] = queue;
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
|
|
// Find max pps/bps needed for any scale bar
|
152 |
|
|
statmax = 0;
|
153 |
|
|
for (interfacename in interfacename_stats) {
|
154 |
|
|
interface = interfacename_stats[interfacename];
|
155 |
|
|
for (queuename in interface) {
|
156 |
|
|
queue = interface[queuename];
|
157 |
|
|
if ($stattype == "0") {
|
158 |
|
|
if (statmax < queue['pkts_ps']) {
|
159 |
|
|
statmax = queue['pkts_ps'];
|
160 |
|
|
}
|
161 |
|
|
} else {
|
162 |
|
|
if (statmax < queue['bytes_ps']) {
|
163 |
|
|
statmax = queue['bytes_ps'];
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
}
|
167 |
|
|
}
|
168 |
|
|
// use a slowly sliding max scale value but do make sure its always large enough to accomodate the largest value..
|
169 |
|
|
if (graphstatmax < statmax) {
|
170 |
|
|
// peek value + 10% keeps a little room for it to increase
|
171 |
|
|
graphstatmax = statmax * 1.1;
|
172 |
|
|
} else {
|
173 |
|
|
// in general make largest bar fill +- 2/3 of the scale
|
174 |
|
|
graphstatmax = (graphstatmax * 20 + statmax * 1.5) / 21;
|
175 |
|
|
}
|
176 |
|
|
// set values on the objects
|
177 |
|
|
for (interfacename in interfacename_stats) {
|
178 |
|
|
interface = interfacename_stats[interfacename];
|
179 |
|
|
for (queuename in interface) {
|
180 |
|
|
queue = interface[queuename];
|
181 |
|
|
statqname = escapeStr(queuename);
|
182 |
|
|
if ($stattype == "0") {
|
183 |
|
|
$('#queue'+statqname+'width').css('width', (queue['pkts_ps']*100/graphstatmax).toFixed(0) + '%');
|
184 |
|
|
} else {
|
185 |
|
|
$('#queue'+statqname+'width').css('width', (queue['bytes_ps']*100/graphstatmax).toFixed(0) + '%');
|
186 |
|
|
}
|
187 |
|
|
$('#queue'+statqname+'pps').val(queue['pkts_ps'].toFixed(1));
|
188 |
|
|
$('#queue'+statqname+'bps').val(formatSpeedBits(queue['bytes_ps']));
|
189 |
|
|
$('#queue'+statqname+'borrows').val(queue['borrows']);
|
190 |
|
|
$('#queue'+statqname+'suspends').val(queue['suspends']);
|
191 |
|
|
$('#queue'+statqname+'drops').val(queue['droppedpkts']);
|
192 |
|
|
$('#queue'+statqname+'length').val(queue['qlengthitems']+'/'+queue['qlengthsize']);
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
timestampprevious = timestamp;
|
196 |
9c1bbdef
|
Stephen Beaver
|
}
|
197 |
625c4a8b
|
Stephen Beaver
|
|
198 |
3f98044a
|
Francisco Cavalcante
|
$(document).ready(function() {
|
199 |
625c4a8b
|
Stephen Beaver
|
setTimeout(getqueueactivity, 150);
|
200 |
9c1bbdef
|
Stephen Beaver
|
});
|
201 |
625c4a8b
|
Stephen Beaver
|
});
|
202 |
0e2bed22
|
PiBa-NL
|
|
203 |
|
|
function formatSpeedBits(speed) {
|
204 |
|
|
// format speed in bits/sec, input: bytes/sec
|
205 |
|
|
if (speed < 125000) {
|
206 |
|
|
return Math.round(speed / 125) + " <?=gettext("Kbps"); ?>";
|
207 |
|
|
}
|
208 |
|
|
if (speed < 125000000) {
|
209 |
|
|
return Math.round(speed / 1250)/100 + " <?=gettext("Mbps"); ?>";
|
210 |
|
|
}
|
211 |
|
|
// else
|
212 |
|
|
return Math.round(speed / 1250000)/100 + " <?=gettext("Gbps"); ?>"; /* wow! */
|
213 |
|
|
}
|
214 |
9c1bbdef
|
Stephen Beaver
|
//]]>
|
215 |
|
|
</script>
|
216 |
|
|
<?php endif;
|
217 |
|
|
|
218 |
|
|
if ($error):
|
219 |
|
|
print_info_box($error);
|
220 |
|
|
else: ?>
|
221 |
|
|
<div class="panel panel-default">
|
222 |
0e2bed22
|
PiBa-NL
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Settings"); ?></h2></div>
|
223 |
|
|
<div class="panel-body table-responsive">
|
224 |
|
|
<label class="col-sm-2 control-label">
|
225 |
|
|
<span>Refresh rate</span>
|
226 |
|
|
</label>
|
227 |
|
|
<div class="col-sm-10">
|
228 |
|
|
<select id="updatespeed" class="form-control">
|
229 |
|
|
<option value="500">0.5 <?=gettext("seconds");?></option>
|
230 |
|
|
<option value="1000" selected>1 <?=gettext("seconds");?></option>
|
231 |
|
|
<option value="2000">2 <?=gettext("seconds");?></option>
|
232 |
|
|
<option value="5000">5 <?=gettext("seconds");?></option>
|
233 |
|
|
</select>
|
234 |
|
|
</div>
|
235 |
|
|
</div>
|
236 |
9c1bbdef
|
Stephen Beaver
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Status Queues"); ?></h2></div>
|
237 |
|
|
<div class="panel-body table-responsive">
|
238 |
|
|
<table class="table table-striped table-hover">
|
239 |
|
|
<thead>
|
240 |
|
|
<tr>
|
241 |
|
|
<th><?=gettext("Queue"); ?></th>
|
242 |
|
|
<th><?=gettext("Statistics"); ?>
|
243 |
e9feb2d4
|
Stephen Beaver
|
<select id="selStatistic" class="form-control">
|
244 |
3bd74348
|
bruno
|
<option value="0"><?=gettext("PPS");?></option>
|
245 |
|
|
<option value="1"><?=gettext("Bandwidth");?></option>
|
246 |
9c1bbdef
|
Stephen Beaver
|
</select>
|
247 |
|
|
</th>
|
248 |
|
|
<th><?=gettext("PPS"); ?></th>
|
249 |
|
|
<th><?=gettext("Bandwidth"); ?></th>
|
250 |
|
|
<th><?=gettext("Borrows"); ?></th>
|
251 |
|
|
<th><?=gettext("Suspends"); ?></th>
|
252 |
|
|
<th><?=gettext("Drops"); ?></th>
|
253 |
|
|
<th><?=gettext("Length"); ?></th>
|
254 |
|
|
</tr>
|
255 |
|
|
</thead>
|
256 |
|
|
<tbody>
|
257 |
|
|
<?php
|
258 |
f625f76c
|
Phil Davis
|
$if_queue_list = get_configured_interface_list_by_realif(true);
|
259 |
0e2bed22
|
PiBa-NL
|
processInterfaceQueues($stats, 0, "");
|
260 |
9c1bbdef
|
Stephen Beaver
|
?>
|
261 |
|
|
<?php endif; ?>
|
262 |
|
|
</tbody>
|
263 |
|
|
</table>
|
264 |
f78bbe16
|
Phil Davis
|
<br />
|
265 |
c95dabdd
|
Stephen Beaver
|
<div class="infoblock blockopen">
|
266 |
9c1bbdef
|
Stephen Beaver
|
<?php
|
267 |
0e2bed22
|
PiBa-NL
|
print_info_box(gettext("Queue graphs sample data on a regular interval."), 'info', false);
|
268 |
9c1bbdef
|
Stephen Beaver
|
?>
|
269 |
f78bbe16
|
Phil Davis
|
</div>
|
270 |
9c1bbdef
|
Stephen Beaver
|
</div>
|
271 |
|
|
</div>
|
272 |
9cad1b8e
|
Colin Fleming
|
<br/>
|
273 |
9c1bbdef
|
Stephen Beaver
|
|
274 |
|
|
<script type="text/javascript">
|
275 |
|
|
//<![CDATA[
|
276 |
|
|
function StatsShowHide(classname) {
|
277 |
3f98044a
|
Francisco Cavalcante
|
var firstrow = $("." + classname).first();
|
278 |
9c1bbdef
|
Stephen Beaver
|
if (firstrow.is(':visible')) {
|
279 |
3f98044a
|
Francisco Cavalcante
|
$("." + classname).hide();
|
280 |
9c1bbdef
|
Stephen Beaver
|
} else {
|
281 |
3f98044a
|
Francisco Cavalcante
|
$("." + classname).show();
|
282 |
9c1bbdef
|
Stephen Beaver
|
}
|
283 |
|
|
}
|
284 |
|
|
//]]>
|
285 |
|
|
</script>
|
286 |
|
|
</form>
|
287 |
|
|
<?php
|
288 |
|
|
|
289 |
|
|
include("foot.inc");
|
290 |
9f605c1c
|
Hari
|
|
291 |
0e2bed22
|
PiBa-NL
|
function processInterfaceQueues($altqstats, $parent_name) {
|
292 |
21b94a54
|
Michele Di Maria
|
global $g;
|
293 |
6ba3121b
|
Michele Di Maria
|
global $if_queue_list;
|
294 |
0e2bed22
|
PiBa-NL
|
|
295 |
63a480cb
|
jim-p
|
$parent_name = $parent_name . " queuerow" . $altqstats['name'] . convert_real_interface_to_friendly_interface_name($altqstats['interface']);
|
296 |
1679b68c
|
Michele Di Maria
|
$prev_if = $altqstats['interface'];
|
297 |
0e2bed22
|
PiBa-NL
|
if (!is_array($altqstats['interfacestats'])) {
|
298 |
|
|
print("<tr><td>");
|
299 |
|
|
print("No Queue data available");
|
300 |
|
|
print("</td></tr>");
|
301 |
|
|
return;
|
302 |
|
|
}
|
303 |
|
|
foreach ($altqstats['interfacestats'] as $if => $ifq) {
|
304 |
|
|
$parents = array();
|
305 |
|
|
echo "<tr><td colspan=\"8\"><b>Interface " . htmlspecialchars(convert_real_interface_to_friendly_descr($if)) . "</b></td></tr>\n";
|
306 |
6ba3121b
|
Michele Di Maria
|
$if_name = "";
|
307 |
1679b68c
|
Michele Di Maria
|
foreach ($if_queue_list as $oif => $real_name) {
|
308 |
0e2bed22
|
PiBa-NL
|
if ($oif == $if) {
|
309 |
6ba3121b
|
Michele Di Maria
|
$if_name = $real_name;
|
310 |
|
|
break;
|
311 |
|
|
}
|
312 |
|
|
}
|
313 |
1679b68c
|
Michele Di Maria
|
if ($prev_if != $q['interface']) {
|
314 |
|
|
$prev_if = $q['interface'];
|
315 |
|
|
}
|
316 |
0e2bed22
|
PiBa-NL
|
foreach($ifq as $qkey => $q) {
|
317 |
|
|
$parent_name = $if . " queuerow" . $altqstats['name'] . convert_real_interface_to_friendly_interface_name($altqstats['interface']);
|
318 |
|
|
if (isset($q['contains'])) {
|
319 |
|
|
foreach($q['contains'] as $child) {
|
320 |
|
|
$parents[$child] = $qkey;
|
321 |
9cad1b8e
|
Colin Fleming
|
}
|
322 |
0e2bed22
|
PiBa-NL
|
}
|
323 |
|
|
$find = $qkey;
|
324 |
|
|
$level = 0;
|
325 |
|
|
while(isset($parents[$find])) {
|
326 |
|
|
$find = $parents[$find];
|
327 |
|
|
$level++;
|
328 |
|
|
$parent_name = $parent_name . " queuerow" . $find . $q['interface'];
|
329 |
|
|
}
|
330 |
|
|
$qfinterface = convert_real_interface_to_friendly_interface_name($q['interface']);
|
331 |
|
|
$qname = str_replace($q['interface'], $qfinterface, $q['name']);
|
332 |
|
|
?>
|
333 |
|
|
<tr class="<?=$parent_name;?>">
|
334 |
|
|
<td class="<?=$row_class?>" style="padding-left:<?=$level * 20?>px;">
|
335 |
|
|
<?php
|
336 |
|
|
if (is_array($q['contains'])) {
|
337 |
|
|
echo "<a href=\"#\" onclick=\"StatsShowHide('queuerow{$qname}{$qfinterface}');return false\">+/-</a>";
|
338 |
|
|
}
|
339 |
|
|
if (strstr($qname, "root_")) {
|
340 |
|
|
echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$if_name}&action=show\">Root queue</a>";
|
341 |
|
|
} else {
|
342 |
|
|
echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$qname}&action=show\">" . htmlspecialchars($qname) . "</a>";
|
343 |
|
|
}
|
344 |
|
|
?>
|
345 |
|
|
</td>
|
346 |
42b0c921
|
Phil Davis
|
<?php
|
347 |
0e2bed22
|
PiBa-NL
|
$cpuUsage = 0;
|
348 |
|
|
$stat_prefix = "queue" . $q['name'] . $q['interface'];
|
349 |
|
|
print('<td>');
|
350 |
|
|
print('<div class="progress" style="height: 7px;width: 170px;">');
|
351 |
|
|
print(' <div class="progress-bar" role="progressbar" id="' . $stat_prefix . 'width" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: ' . $cpuUsage*100 . '%;"></div>');
|
352 |
|
|
print(' </div>');
|
353 |
|
|
print('</td>');
|
354 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="' . $stat_prefix . 'pps" id="' . $stat_prefix . 'pps" value="(' . gettext("Loading") . ')" /></td>');
|
355 |
|
|
print('<td><input readonly style="border:0;width:80px;text-align:right;" name="' . $stat_prefix . 'bps" id="' . $stat_prefix . 'bps" value="" /></td>');
|
356 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="' . $stat_prefix . 'borrows" id="' . $stat_prefix . 'borrows" value="" /></td>');
|
357 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="' . $stat_prefix . 'suspends" id="' . $stat_prefix . 'suspends" value="" /></td>');
|
358 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="' . $stat_prefix . 'drops" id="' . $stat_prefix . 'drops" value="" /></td>');
|
359 |
|
|
print('<td><input readonly style="border:0;width:70px;text-align:right;" name="' . $stat_prefix . 'length" id="' . $stat_prefix . 'length" value="" /></td>');
|
360 |
42b0c921
|
Phil Davis
|
?>
|
361 |
0e2bed22
|
PiBa-NL
|
</tr>
|
362 |
42b0c921
|
Phil Davis
|
<?php
|
363 |
0e2bed22
|
PiBa-NL
|
if (is_array($q['queue'])) {
|
364 |
|
|
processInterfaceQueues($q, $level + 1, $parent_name);
|
365 |
|
|
}
|
366 |
42b0c921
|
Phil Davis
|
}
|
367 |
9c1bbdef
|
Stephen Beaver
|
};
|
368 |
21b94a54
|
Michele Di Maria
|
}
|
369 |
39881492
|
Stephen Beaver
|
|
370 |
42b0c921
|
Phil Davis
|
function statsQueues($xml) {
|
371 |
21b94a54
|
Michele Di Maria
|
global $statistics;
|
372 |
b06abfe3
|
Michele Di Maria
|
|
373 |
2d07b58d
|
jim-p
|
$fname = convert_real_interface_to_friendly_interface_name($xml['interface']);
|
374 |
|
|
$qname = str_replace($xml['interface'], $fname, $xml['name']);
|
375 |
|
|
|
376 |
21b94a54
|
Michele Di Maria
|
$current = new QueueStats();
|
377 |
|
|
$child = new QueueStats();
|
378 |
2d07b58d
|
jim-p
|
$current->queuename = $qname . $fname;
|
379 |
2c5fda82
|
Jose Luis Duran
|
$current->queuelength = $xml['qlength'];
|
380 |
ff3003df
|
Michele Di Maria
|
$current->pps = $xml['measured'];
|
381 |
|
|
$current->bandwidth = $xml['measuredspeedint'];
|
382 |
21b94a54
|
Michele Di Maria
|
$current->borrows = intval($xml['borrows']);
|
383 |
|
|
$current->suspends = intval($xml['suspends']);
|
384 |
8e006931
|
Michele Di Maria
|
$current->drops = intval($xml['droppedpkts']);
|
385 |
1679b68c
|
Michele Di Maria
|
if (is_array($xml['queue'])) {
|
386 |
42b0c921
|
Phil Davis
|
foreach ($xml['queue'] as $q) {
|
387 |
21b94a54
|
Michele Di Maria
|
$child = statsQueues($q);
|
388 |
|
|
$current->pps += $child->pps;
|
389 |
|
|
$current->bandwidth += $child->bandwidth;
|
390 |
|
|
$current->borrows += $child->borrows;
|
391 |
|
|
$current->suspends += $child->suspends;
|
392 |
|
|
$current->drops += $child->drops;
|
393 |
|
|
}
|
394 |
|
|
}
|
395 |
a3eab908
|
Michele Di Maria
|
unset($child);
|
396 |
21b94a54
|
Michele Di Maria
|
$statistics[] = $current;
|
397 |
|
|
return $current;
|
398 |
|
|
}
|
399 |
b06abfe3
|
Michele Di Maria
|
function format_bits($bits) {
|
400 |
|
|
if ($bits >= 1000000000) {
|
401 |
|
|
return sprintf("%.2f Gbps", $bits/1000000000);
|
402 |
|
|
} else if ($bits >= 1000000) {
|
403 |
|
|
return sprintf("%.2f Mbps", $bits/1000000);
|
404 |
|
|
} else if ($bits >= 1000) {
|
405 |
31e41cf4
|
Michele Di Maria
|
return sprintf("%.2f Kbps", $bits/1000);
|
406 |
b06abfe3
|
Michele Di Maria
|
} else {
|
407 |
31e41cf4
|
Michele Di Maria
|
return sprintf("%d bps", $bits);
|
408 |
b06abfe3
|
Michele Di Maria
|
}
|
409 |
|
|
}
|
410 |
39881492
|
Stephen Beaver
|
?>
|