1 |
aa280d10
|
Bill Marquette
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
aa280d10
|
Bill Marquette
|
/*
|
5 |
|
|
status_queues.php
|
6 |
8dc950ac
|
Scott Ullrich
|
Part of the pfSense project
|
7 |
aa280d10
|
Bill Marquette
|
Copyright (C) 2004, 2005 Scott Ullrich
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
require("guiconfig.inc");
|
33 |
|
|
|
34 |
c5d63426
|
Bill Marquette
|
if($_GET['reset'] <> "") {
|
35 |
f8c2f4f5
|
Scott Ullrich
|
mwexec("killall -9 pfctl pfctl");
|
36 |
|
|
Header("Location: status_queues.php");
|
37 |
c5d63426
|
Bill Marquette
|
exit;
|
38 |
|
|
}
|
39 |
|
|
|
40 |
aa280d10
|
Bill Marquette
|
if (!is_array($config['shaper']['queue'])) {
|
41 |
|
|
$config['shaper']['queue'] = array();
|
42 |
|
|
}
|
43 |
|
|
|
44 |
4fc85b5d
|
Scott Ullrich
|
$a_queues = array();
|
45 |
|
|
|
46 |
|
|
$pfctl_vsq = `/sbin/pfctl -vsq`;
|
47 |
|
|
$pfctl_vsq_array = split("\n", $pfctl_vsq);
|
48 |
|
|
foreach($pfctl_vsq_array as $pfctl) {
|
49 |
|
|
if (preg_match_all("/queue\s+(\w+)\s+/",$pfctl,$match_array))
|
50 |
|
|
if(stristr($match_array[1][0],"root_")==false)
|
51 |
|
|
$a_queues[] = $match_array[1][0];
|
52 |
|
|
}
|
53 |
ad8d82ad
|
Scott Ullrich
|
|
54 |
4df96eff
|
Scott Ullrich
|
$pgtitle = "Status: Traffic shaper: Queues";
|
55 |
|
|
include("head.inc");
|
56 |
|
|
|
57 |
aa280d10
|
Bill Marquette
|
?>
|
58 |
|
|
|
59 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
60 |
|
|
<?php include("fbegin.inc"); ?>
|
61 |
74f446e8
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
62 |
d1dd0241
|
Scott Ullrich
|
<?php
|
63 |
acb63435
|
Scott Ullrich
|
if(!isset($config['shaper']['enable'])) {
|
64 |
d1dd0241
|
Scott Ullrich
|
echo "Traffic shaping is currently disabled.";
|
65 |
|
|
include("fend.inc");
|
66 |
|
|
exit;
|
67 |
|
|
}
|
68 |
|
|
?>
|
69 |
|
|
|
70 |
aa280d10
|
Bill Marquette
|
<form action="status_queues.php" method="post">
|
71 |
8dc950ac
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
72 |
aa280d10
|
Bill Marquette
|
<tr>
|
73 |
8dc950ac
|
Scott Ullrich
|
<td class="listhdr" colspan="1">Queue</td>
|
74 |
|
|
<td class="listhdr" colspan="6">Statistics</td>
|
75 |
aa280d10
|
Bill Marquette
|
</tr>
|
76 |
|
|
<?php $i = 0; foreach ($a_queues as $queue): ?>
|
77 |
8dc950ac
|
Scott Ullrich
|
<tr><td bgcolor="#DDDDDD" colspan="7"> </td></tr>
|
78 |
aa280d10
|
Bill Marquette
|
<tr valign="top">
|
79 |
8dc950ac
|
Scott Ullrich
|
<td bgcolor="#DDDDDD">
|
80 |
69c4bf80
|
Bill Marquette
|
<font color="#000000"> <?echo "<a href=\"firewall_shaper_queues_edit.php?id={$queue}\">" . htmlspecialchars($queue) . "</a>";?> </td>
|
81 |
8dc950ac
|
Scott Ullrich
|
<td bgcolor="#DDDDDD">
|
82 |
|
|
<nobr>
|
83 |
aa280d10
|
Bill Marquette
|
<?php
|
84 |
|
|
$cpuUsage = 0;
|
85 |
677c0869
|
Erik Kristensen
|
echo "<img src='./themes/".$g['theme']."/images/misc/bar_left.gif' height='15' width='4' border='0' align='absmiddle'>";
|
86 |
|
|
echo "<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='15' name='queue{$i}widtha' id='queue{$i}widtha' width='" . $cpuUsage . "' border='0' align='absmiddle'>";
|
87 |
|
|
echo "<img src='./themes/".$g['theme']."/images/misc/bar_gray.gif' height='15' name='queue{$i}widthb' id='queue{$i}widthb' width='" . (400 - $cpuUsage) . "' border='0' align='absmiddle'>";
|
88 |
|
|
echo "<nobr><img src='./themes/".$g['theme']."/images/misc/bar_right.gif' height='15' width='5' border='0' align='absmiddle'> ";
|
89 |
8dc950ac
|
Scott Ullrich
|
echo "</nobr></td></tr>";
|
90 |
|
|
echo "<tr><td bgcolor=\"#DDDDDD\" colspan=\"7\">";
|
91 |
5f046df6
|
Scott Ullrich
|
echo " ";
|
92 |
8dc950ac
|
Scott Ullrich
|
echo "<nobr>";
|
93 |
5f046df6
|
Scott Ullrich
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='15' name='queue{$i}pps' id='queue{$i}pps' value=' (Loading)' align='right'>";
|
94 |
8dc950ac
|
Scott Ullrich
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='15' name='queue{$i}bps' id='queue{$i}bps' value='' align='right'>";
|
95 |
|
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='15' name='queue{$i}borrows' id='queue{$i}borrows' value='' align='right'>";
|
96 |
|
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='15' name='queue{$i}suspends' id='queue{$i}suspends' value='' align='right'>";
|
97 |
|
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='15' name='queue{$i}drops' id='queue{$i}drops' value='' align='right'>";
|
98 |
|
|
echo "</nobr>";
|
99 |
aa280d10
|
Bill Marquette
|
?>
|
100 |
|
|
|
101 |
|
|
</td>
|
102 |
|
|
</tr>
|
103 |
8dc950ac
|
Scott Ullrich
|
<tr><td class="vncell" bgcolor="#DDDDDD" colspan="7"> </td></tr>
|
104 |
aa280d10
|
Bill Marquette
|
<?php $i++; endforeach; $total_queues = $i; ?>
|
105 |
|
|
</table>
|
106 |
|
|
<p>
|
107 |
|
|
<strong><span class="red">Note:</span></strong><strong><br></strong>
|
108 |
c55a8ab9
|
Holger Bauer
|
Queue graphs take 5 seconds to sample data.<br>
|
109 |
|
|
You can configure the TrafficShaper <a href="firewall_shaper.php?reset=true">here</a>.
|
110 |
aa280d10
|
Bill Marquette
|
</p>
|
111 |
|
|
</form>
|
112 |
c5d63426
|
Bill Marquette
|
<br><a href="status_queues.php?reset=true">Reset</a> queues if they do not load.
|
113 |
fda1fdae
|
Scott Ullrich
|
|
114 |
|
|
<meta http-equiv="refresh" content="60;url=<?php print $_SERVER['PHP_SELF']; ?>">
|
115 |
|
|
|
116 |
aa280d10
|
Bill Marquette
|
<?php include("fend.inc"); ?>
|
117 |
|
|
</body>
|
118 |
|
|
</html>
|
119 |
|
|
|
120 |
|
|
<?php
|
121 |
|
|
|
122 |
|
|
sleep(3);
|
123 |
|
|
|
124 |
|
|
$counter = 0;
|
125 |
|
|
While(!Connection_Aborted()) {
|
126 |
|
|
|
127 |
|
|
$stats_array = gather_altq_queue_stats(true);
|
128 |
|
|
|
129 |
|
|
/* calculate total packets being moved through all queues. */
|
130 |
|
|
$total_packets_s = 0;
|
131 |
|
|
foreach($stats_array as $stats_line) {
|
132 |
|
|
$stat_line_split = split("\|", $stats_line);
|
133 |
|
|
$total_packets_s = $total_packets_s + intval($stat_line_split[2]);
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
$i = 0;
|
137 |
|
|
foreach($stats_array as $stats_line) {
|
138 |
|
|
if($stat_line_split[2] == "" and $counter > 1) {
|
139 |
|
|
mwexec("/usr/bin/killall -9 pfctl php");
|
140 |
|
|
exit;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
$stat_line_split = split("\|", $stats_line);
|
144 |
|
|
$packet_sampled = intval($stat_line_split[2]);
|
145 |
|
|
$speed = $stat_line_split[1];
|
146 |
|
|
$borrows = intval($stat_line_split[3]);
|
147 |
4bed294c
|
Bill Marquette
|
$suspends = intval($stat_line_split[4]);
|
148 |
04e6e7b7
|
Bill Marquette
|
$drops = intval($stat_line_split[5]);
|
149 |
aa280d10
|
Bill Marquette
|
|
150 |
|
|
echo "<script language='javascript'>\n";
|
151 |
|
|
|
152 |
|
|
$packet_s = round(400 * (1 - $packet_sampled / $total_packets_s), 0);
|
153 |
|
|
|
154 |
bff31246
|
Erik Kristensen
|
echo "document.queue{$i}widthb.style.width='{$packet_s}px';\n";
|
155 |
|
|
echo "document.queue{$i}widtha.style.width='" . (400 - $packet_s) . "px';\n";
|
156 |
efc68cca
|
Bill Marquette
|
$borrows_txt = "{$borrows} borrows";
|
157 |
|
|
$suspends_txt = "{$suspends} suspends";
|
158 |
|
|
$drops_txt = "${drops} drops";
|
159 |
|
|
echo "document.forms[0].queue{$i}pps.value = '{$packet_sampled}/pps';\n";
|
160 |
|
|
echo "document.forms[0].queue{$i}bps.value = '{$speed}';\n";
|
161 |
|
|
echo "document.forms[0].queue{$i}borrows.value = '{$borrows_txt}';\n";
|
162 |
|
|
echo "document.forms[0].queue{$i}suspends.value = '{$suspends_txt}';\n";
|
163 |
|
|
echo "document.forms[0].queue{$i}drops.value = '{$drops_txt}';\n";
|
164 |
aa280d10
|
Bill Marquette
|
echo "</script>\n";
|
165 |
|
|
$i++;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
/*
|
169 |
|
|
* prevent user from running out of ram.
|
170 |
|
|
* firefox and ie can be a bear on ram usage!
|
171 |
|
|
*/
|
172 |
|
|
$counter++;
|
173 |
a7baf34d
|
Scott Ullrich
|
if($counter > 40) {
|
174 |
aa280d10
|
Bill Marquette
|
echo "Redirecting to <a href=\"status_queues.php\">Queue Status</a>.<p>";
|
175 |
|
|
echo "<meta http-equiv=\"refresh\" content=\"1;url=status_queues.php\">";
|
176 |
|
|
mwexec("/usr/bin/killall -9 pfctl");
|
177 |
8dc950ac
|
Scott Ullrich
|
mwexec("/usr/bin/killall -9 pfctl php");
|
178 |
aa280d10
|
Bill Marquette
|
exit;
|
179 |
|
|
}
|
180 |
|
|
}
|
181 |
|
|
|
182 |
8dc950ac
|
Scott Ullrich
|
mwexec("/usr/bin/killall -9 pfctl pfctl");
|
183 |
aa280d10
|
Bill Marquette
|
mwexec("/usr/bin/killall -9 pfctl php");
|
184 |
|
|
|
185 |
|
|
?>
|