41 |
41 |
##|*MATCH=status_queues.php*
|
42 |
42 |
##|-PRIV
|
43 |
43 |
|
|
44 |
header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
|
|
45 |
header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
|
|
46 |
header("Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
|
|
47 |
header("Cache-Control: post-check=0, pre-check=0", FALSE );
|
|
48 |
header("Pragma: no-cache"); // HTTP/1.0
|
|
49 |
|
44 |
50 |
require("guiconfig.inc");
|
45 |
51 |
|
46 |
|
if ($_REQUEST['getactivity']) {
|
47 |
|
$stats_array = gather_altq_queue_stats(true);
|
|
52 |
if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_path']}/qstats.pid"))
|
|
53 |
mwexec("/usr/local/sbin/qstats -p {$g['varrun_path']}/qstats.pid");
|
|
54 |
|
|
55 |
$fd = @fsockopen("unix://{$g['varrun_path']}/qstats");
|
|
56 |
if (!$fd) {
|
|
57 |
log_error("Something wrong happened during comunication with stat gathering");
|
|
58 |
header("Location: /status_queues.php");
|
|
59 |
exit;
|
|
60 |
}
|
|
61 |
$stats = "";
|
|
62 |
while(!feof($fd))
|
|
63 |
$stats .= fread($fd, 4096);
|
|
64 |
fclose($fd);
|
|
65 |
|
|
66 |
@file_put_contents("{$g['tmp_path']}/qstats", $stats);
|
|
67 |
$altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats"));
|
48 |
68 |
|
|
69 |
if ($_REQUEST['getactivity']) {
|
49 |
70 |
/* calculate total packets being moved through all queues. */
|
50 |
71 |
$total_packets_s = 0;
|
51 |
|
foreach($stats_array as $stats_line) {
|
52 |
|
$stat_line_split = split("\|", $stats_line);
|
53 |
|
$total_packets_s = $total_packets_s + intval($stat_line_split[2]);
|
|
72 |
foreach($altqstats['queue'] as $q) {
|
|
73 |
if (strstr($q['name'], "root_"))
|
|
74 |
continue;
|
|
75 |
$total_packets_s = $total_packets_s + intval($q['pkts']);
|
54 |
76 |
}
|
55 |
77 |
|
56 |
|
$i = 0;
|
57 |
78 |
$finscript = "";
|
58 |
|
foreach($stats_array as $stats_line) {
|
59 |
|
if($stat_line_split[2] == "" and $counter > 1) {
|
60 |
|
continue;
|
61 |
|
}
|
62 |
|
|
63 |
|
$stat_line_split = split("\|", $stats_line);
|
64 |
|
$packet_sampled = intval($stat_line_split[2]);
|
65 |
|
$speed = $stat_line_split[1];
|
66 |
|
$borrows = intval($stat_line_split[3]);
|
67 |
|
$suspends = intval($stat_line_split[4]);
|
68 |
|
$drops = intval($stat_line_split[5]);
|
69 |
|
|
70 |
|
|
71 |
|
$packet_s = round(400 * (1 - $packet_sampled / $total_packets_s), 0);
|
72 |
|
|
73 |
|
$finscript .= "$('queue{$i}widthb').width='{$packet_s}';";
|
74 |
|
$finscript .= "$('queue{$i}widtha').width='" . (400 - $packet_s) . "';";
|
75 |
|
$borrows_txt = "{$borrows} borrows";
|
76 |
|
$suspends_txt = "{$suspends} suspends";
|
77 |
|
$drops_txt = "${drops} drops";
|
78 |
|
$finscript .= "$('queue{$i}pps').value = '{$packet_sampled}/pps';";
|
79 |
|
$finscript .= "$('queue{$i}bps').value = '{$speed}';";
|
80 |
|
$finscript .= "$('queue{$i}borrows').value = '{$borrows_txt}';";
|
81 |
|
$finscript .= "$('queue{$i}suspends').value = '{$suspends_txt}';";
|
82 |
|
$finscript .= "$('queue{$i}drops').value = '{$drops_txt}';";
|
83 |
|
$i++;
|
|
79 |
foreach($altqstats['queue'] as $q) {
|
|
80 |
if (strstr($q['name'], "root_"))
|
|
81 |
continue;
|
|
82 |
|
|
83 |
$packet_s = round(400 * (1 - $q['pkts']/ $total_packets_s), 0);
|
|
84 |
|
|
85 |
$finscript .= "$('queue{$q['name']}{$q['interface']}widthb').width='{$packet_s}';";
|
|
86 |
$finscript .= "$('queue{$q['name']}{$q['interface']}widtha').width='" . (400 - $packet_s) . "';";
|
|
87 |
$finscript .= "$('queue{$q['name']}{$q['interface']}pps').value = '{$q['measured']}/pps';";
|
|
88 |
$finscript .= "$('queue{$q['name']}{$q['interface']}bps').value = '{$q['measuredspeed']}';";
|
|
89 |
$finscript .= "$('queue{$q['name']}{$q['interface']}borrows').value = '{$q['borrows']} borrows';";
|
|
90 |
$finscript .= "$('queue{$q['name']}{$q['interface']}suspends').value = '{$q['suspends']} suspends';";
|
|
91 |
$finscript .= "$('queue{$q['name']}{$q['interface']}drops').value = '{$q['droppedpkts']} drops';";
|
84 |
92 |
}
|
85 |
93 |
header("Content-type: text/javascript");
|
86 |
94 |
echo $finscript;
|
87 |
95 |
exit;
|
88 |
96 |
}
|
89 |
97 |
|
90 |
|
$a_queues = array();
|
91 |
|
|
92 |
|
exec("/sbin/pfctl -vsq", $pfctl_vsq_array);
|
93 |
|
foreach($pfctl_vsq_array as $pfctl) {
|
94 |
|
if (preg_match_all("/queue\s+(\w+)\s+(\w+)\s+(\w+)\s+/",$pfctl,$match_array)) {
|
95 |
|
if (stristr($match_array[1][0],"root_"))
|
96 |
|
continue;
|
97 |
|
$a_queues[] = $match_array[1][0] . " on " .
|
98 |
|
convert_real_interface_to_friendly_descr($match_array[3][0]);
|
99 |
|
}
|
100 |
|
}
|
101 |
|
|
102 |
98 |
$pgtitle = array(gettext("Status"),gettext("Traffic shaper"),gettext("Queues"));
|
103 |
99 |
include("head.inc");
|
104 |
100 |
|
... | ... | |
139 |
135 |
<td class="listhdr" colspan="1"><?=gettext("Queue"); ?></td>
|
140 |
136 |
<td class="listhdr" colspan="6"><?=gettext("Statistics"); ?></td>
|
141 |
137 |
</tr>
|
142 |
|
<?php $i = 0; foreach ($a_queues as $queue): ?>
|
|
138 |
<?php $i = 0; foreach ($altqstats['queue'] as $q):
|
|
139 |
if (strstr($q['name'], "root_"))
|
|
140 |
continue;
|
|
141 |
?>
|
143 |
142 |
<tr><td bgcolor="#DDDDDD" colspan="7"> </td></tr>
|
144 |
143 |
<tr valign="top">
|
145 |
144 |
<td bgcolor="#DDDDDD">
|
146 |
|
<font color="#000000"> <?echo "<a href=\"firewall_shaper.php?id={$queue}\">" . htmlspecialchars($queue) . "</a>";?> </td>
|
|
145 |
<font color="#000000"> <?echo "<a href=\"firewall_shaper.php?id={$q['name']}\">" . htmlspecialchars($q['name'] . " on " . convert_real_interface_to_friendly_descr($q['interface'])) . "</a>";?> </td>
|
147 |
146 |
<td bgcolor="#DDDDDD">
|
148 |
147 |
<nobr>
|
149 |
148 |
<?php
|
150 |
149 |
$cpuUsage = 0;
|
151 |
150 |
echo "<img src='./themes/".$g['theme']."/images/misc/bar_left.gif' height='10' width='4' border='0' align='absmiddle'>";
|
152 |
|
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'>";
|
153 |
|
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'>";
|
|
151 |
echo "<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='10' name='queue{$q['name']}{$q['interface']}widtha' id='queue{$q['name']}{$q['interface']}widtha' width='" . $cpuUsage . "' border='0' align='absmiddle'>";
|
|
152 |
echo "<img src='./themes/".$g['theme']."/images/misc/bar_gray.gif' height='10' name='queue{$q['name']}{$q['interface']}widthb' id='queue{$q['name']}{$q['interface']}widthb' width='" . (400 - $cpuUsage) . "' border='0' align='absmiddle'>";
|
154 |
153 |
echo "<nobr><img src='./themes/".$g['theme']."/images/misc/bar_right.gif' height='10' width='5' border='0' align='absmiddle'> ";
|
155 |
154 |
echo "</nobr></td></tr>";
|
156 |
155 |
echo "<tr><td bgcolor=\"#DDDDDD\" colspan=\"7\">";
|
157 |
156 |
echo " ";
|
158 |
157 |
echo "<nobr>";
|
159 |
|
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$i}pps' id='queue{$i}pps' value='(" . gettext("Loading") . ")' align='left'>";
|
160 |
|
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'>";
|
161 |
|
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'>";
|
162 |
|
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'>";
|
163 |
|
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'>";
|
|
158 |
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$q['name']}{$q['interface']}pps' id='queue{$q['name']}{$q['interface']}pps' value='(" . gettext("Loading") . ")' align='left'>";
|
|
159 |
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$q['name']}{$q['interface']}bps' id='queue{$q['name']}{$q['interface']}bps' value='' align='right'>";
|
|
160 |
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$q['name']}{$q['interface']}borrows' id='queue{$q['name']}{$q['interface']}borrows' value='' align='right'>";
|
|
161 |
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$q['name']}{$q['interface']}suspends' id='queue{$q['name']}{$q['interface']}suspends' value='' align='right'>";
|
|
162 |
echo "<input style='border: 0px solid white; background-color:#DDDDDD; color:#000000;' size='10' name='queue{$q['name']}{$q['interface']}drops' id='queue{$q['name']}{$q['interface']}drops' value='' align='right'>";
|
164 |
163 |
echo "</nobr>";
|
165 |
164 |
?>
|
166 |
165 |
|
... | ... | |
174 |
173 |
<?=gettext("Queue graphs take 5 seconds to sample data"); ?>.<br>
|
175 |
174 |
<?=gettext("You can configure the Traffic Shaper"); ?> <a href="/firewall_shaper_wizards.php"><?=gettext("here"); ?></a>.
|
176 |
175 |
</p>
|
177 |
|
</form>
|
178 |
176 |
<?php include("fend.inc"); ?>
|
179 |
177 |
</body>
|
180 |
178 |
</html>
|
Use the new daemon for status->queues until a proper chart javascript library is availble