1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
#!/usr/local/bin/php
<?php
/* $Id$ */
/*
status_queues.php
Part of the pfSense project
Copyright (C) 2004, 2005 Scott Ullrich
Copyright (C) 2009 Ermal Luçi
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_BUILDER_BINARIES: /sbin/pfctl
pfSense_MODULE: shaper
*/
##|+PRIV
##|*IDENT=page-status-trafficshaper-queues
##|*NAME=Status: Traffic shaper: Queues page
##|*DESCR=Allow access to the 'Status: Traffic shaper: Queues' page.
##|*MATCH=status_queues.php*
##|-PRIV
require("guiconfig.inc");
if ($_REQUEST['getactivity']) {
$stats_array = gather_altq_queue_stats(true);
/* calculate total packets being moved through all queues. */
$total_packets_s = 0;
foreach($stats_array as $stats_line) {
$stat_line_split = split("\|", $stats_line);
$total_packets_s = $total_packets_s + intval($stat_line_split[2]);
}
$i = 0;
$finscript = "";
foreach($stats_array as $stats_line) {
if($stat_line_split[2] == "" and $counter > 1) {
continue;
}
$stat_line_split = split("\|", $stats_line);
$packet_sampled = intval($stat_line_split[2]);
$speed = $stat_line_split[1];
$borrows = intval($stat_line_split[3]);
$suspends = intval($stat_line_split[4]);
$drops = intval($stat_line_split[5]);
$packet_s = round(400 * (1 - $packet_sampled / $total_packets_s), 0);
$finscript .= "$('queue{$i}widthb').width='{$packet_s}';";
$finscript .= "$('queue{$i}widtha').width='" . (400 - $packet_s) . "';";
$borrows_txt = "{$borrows} borrows";
$suspends_txt = "{$suspends} suspends";
$drops_txt = "${drops} drops";
$finscript .= "$('queue{$i}pps').value = '{$packet_sampled}/pps';";
$finscript .= "$('queue{$i}bps').value = '{$speed}';";
$finscript .= "$('queue{$i}borrows').value = '{$borrows_txt}';";
$finscript .= "$('queue{$i}suspends').value = '{$suspends_txt}';";
$finscript .= "$('queue{$i}drops').value = '{$drops_txt}';";
$i++;
}
header("Content-type: text/javascript");
echo $finscript;
exit;
}
$a_queues = array();
exec("/sbin/pfctl -vsq", $pfctl_vsq_array);
foreach($pfctl_vsq_array as $pfctl) {
if (preg_match_all("/queue\s+(\w+)\s+(\w+)\s+(\w+)\s+/",$pfctl,$match_array)) {
if (stristr($match_array[1][0],"root_"))
continue;
$a_queues[] = $match_array[1][0] . " on " .
convert_real_interface_to_friendly_descr($match_array[3][0]);
}
}
$pgtitle = array("Status","Traffic shaper","Queues");
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<?php
if(!is_array($config['shaper']['queue']) && count($config['shaper']['queue']) < 1) {
echo "Traffic shaping is not configured.";
include("fend.inc");
exit;
}
?>
<form action="status_queues.php" method="post">
<script type="text/javascript">
function getqueueactivity() {
var url = "/status_queues.php";
var pars = 'getactivity=yes';
var myAjax = new Ajax.Request(
url,
{
method: 'post',
parameters: pars,
onComplete: activitycallback
});
}
function activitycallback(transport) {
setTimeout('getqueueactivity()', 5100);
}
document.observe('dom:loaded', function(){
setTimeout('getqueueactivity()', 150);
});
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="listhdr" colspan="1">Queue</td>
<td class="listhdr" colspan="6">Statistics</td>
</tr>
<?php $i = 0; foreach ($a_queues as $queue): ?>
<tr><td bgcolor="#DDDDDD" colspan="7"> </td></tr>
<tr valign="top">
<td bgcolor="#DDDDDD">
<font color="#000000"> <?echo "<a href=\"firewall_shaper.php?id={$queue}\">" . htmlspecialchars($queue) . "</a>";?> </td>
<td bgcolor="#DDDDDD">
<nobr>
<?php
$cpuUsage = 0;
echo "<img src='./themes/".$g['theme']."/images/misc/bar_left.gif' height='10' width='4' border='0' align='absmiddle'>";
echo "<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='10' name='queue{$i}widtha' id='queue{$i}widtha' width='" . $cpuUsage . "' border='0' align='absmiddle'>";
echo "<img src='./themes/".$g['theme']."/images/misc/bar_gray.gif' height='10' name='queue{$i}widthb' id='queue{$i}widthb' width='" . (400 - $cpuUsage) . "' border='0' align='absmiddle'>";
echo "<nobr><img src='./themes/".$g['theme']."/images/misc/bar_right.gif' height='10' width='5' border='0' align='absmiddle'> ";
echo "</nobr></td></tr>";
echo "<tr><td bgcolor=\"#DDDDDD\" colspan=\"7\">";
echo " ";
echo "<nobr>";
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}pps' id='queue{$i}pps' value='(Loading)' align='left'>";
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}bps' id='queue{$i}bps' value='' align='right'>";
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}borrows' id='queue{$i}borrows' value='' align='right'>";
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}suspends' id='queue{$i}suspends' value='' align='right'>";
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}drops' id='queue{$i}drops' value='' align='right'>";
echo "</nobr>";
?>
</td>
</tr>
<tr><td class="vncell" bgcolor="#DDDDDD" colspan="7"> </td></tr>
<?php $i++; endforeach; $total_queues = $i; ?>
</table>
<p>
<strong><span class="red">Note:</span></strong><strong><br></strong>
Queue graphs take 5 seconds to sample data.<br>
You can configure the Traffic Shaper <a href="/firewall_shaper_wizards.php">here</a>.
</p>
</form>
<?php include("fend.inc"); ?>
</body>
</html>
|