/* Statystyki rchtb ver 0.1 zciech
Umiescic w katalogu www, zmienic nazwe na htb.php
Wymaga Apacza z obsluga php */
$iface_inet = "imq0";
$iface_local = "imq1";
$resolve = "nie";
?>
Statystyki rchtb
Statystyka ruchu HTB
function tcparse ($output, $flow) {
global $transfer;
$classes = explode("\n\n", $output);
foreach ($classes as $class) {
$lines = explode("\n",$class);
$l = 0;
$rate = "";
foreach ($lines as $line) {
if ($l!=0 && preg_match("/rate (.*?) /", $line, $matches)) {
$rate = $matches[1];
}
$l++;
}
if ($rate!="" && preg_match("/class htb 2:(.*?) /", $lines[0], $matches))
{
$classid=$matches[1];
if (preg_match("/(.*?)bit/", $rate, $vrate)) {
$rate = floor(($vrate[1]) / 1024)." Kbit";
}
if ($rate != "0 Kbit") {
$transfer[$classid]["classid"] = $classid;
$transfer[$classid][$flow] = $rate;
}
}
if ($rate!="" && preg_match("/class htb 1:(.*?) /", $lines[0], $matches))
{
$classid=$matches[1];
if (preg_match("/(.*?)bit/", $rate, $vrate)) {
$rate = floor(($vrate[1]) / 1024)." Kbit";
}
if ($rate != "0 Kbit") {
$transfer[$classid]["classid"] = $classid;
$transfer[$classid][$flow] = $rate;
}
}
}
}
$eup = `tc -s -d class show dev $iface_inet`;
tcparse($eup, "ul");
$edw = `tc -s -d class show dev $iface_local`;
tcparse($edw, "dl");
$grupa = 0;
$linia = 0;
$ipki = `sed 's/^[ \t]*//' /etc/rchtb/htb.hosts|grep ^[0123456789G]|awk '{print $1}'`;
$ipeki = explode("\n", $ipki);
$l = 11;
foreach ($ipeki as $ipek) {
if ($ipek == "GRUP") {
$grupa = 1;
$linia = 1;
continue;
}
if ($ipek == "GRUP_END") {
$grupa = 0;
$linia = 0;
continue;
}
if ($grupa == 0 || $linia == 1) {
if ($resolve != "tak"){$transfer[$l]["ipek"] = $ipek;}
else {$transfer[$l]["ipek"] = `resolveip -s $ipek`;}
$l++;
}
if ($grupa == 1 && $linia == 1) { $linia = 0;}
}
ksort($transfer);
?>
| Download | Upload |
$i = 1;
foreach ($transfer as $class) {
switch ($class["classid"]) {
case 1:
$name = $iface_local."/".$iface_inet;
break;
case 2:
$name = "Internet/ACK";
break;
case 3:
$name = "Serwer/Goscie";
break;
case 4:
$name = "ICMP";
break;
case 5:
$name = "p2p";
break;
case 6:
$name = "Gry";
break;
default:
$name = $class["ipek"];
}
if ($class["dl"] != "" || $class["ul"] != "") {
?>"> | | |
$i++;
}
}
?>
/*
Srypt ten jest przerobionym i dostosowanym do rchtb 0.2x by zciech
skryptem staystyk z pakietu obwman
http://okon.one.pl/downloads/files/obwman/obwman.zip
Oryginalna licencja:
-------------------------------------------------------------------------------
Copyright (c) 2004, Michal "ok0n" Kubski
All rights reserved.
This Software may be copied or redistributed as long as it is not sold
for profit, and it cannot be incorporated into any other substantive
product with or without modifications for profit or non-profit. If The
Software is modified, it must include the following notices:
- The Software is not the original (for protection of the original
author's reputations from any problems introduced by others)
- Change history (e.g. date, functionality, etc.)
This copyright notice must be reproduced on each copy made.
Neither the name of the Author nor the name of The Software
may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
-------------------------------------------------------------------------------
*/
?>