blob: 3fd01a61109fadf2b65476562d83ce010cb55266 (
plain)
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
|
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*
*
*
*
*
*/
require_once('guiconfig.inc');
require_once('interfaces.inc');
require_once('pfsense-utils.inc');
require_once('util.inc');
$listedIPs = "";
//get interface IP and break up into an array
$interface = $_GET['if'];
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
$intip = find_interface_ip($real_interface);
$intip = explode (".", $intip);
//use class A subnet to make sure we capture all traffic on specified interface
$intsubnet = $intip[0] . ".0.0.0/8";
exec("rate -i {$real_interface} -nlq 1 -A -c {$intsubnet}", $listedIPs);
unset($bandwidthinfo);
unset($receivebytesarray);
unset($transmitbytesarray);
$someinfo = false;
for ($x=2; $x<12; $x++){
$bandwidthinfo = $listedIPs[$x];
// echo $bandwidthinfo;
$emptyinfocounter = 1;
if ($bandwidthinfo != "") {
$splitinfo = explode ("|",$bandwidthinfo);
$receivebytesarray = explode(" ",$splitinfo[0]);
//print IP of host;
echo $receivebytesarray[0] . ";";
//skip empty array elements until first element found with data
while ($receivebytesarray[$emptyinfocounter] == "")
{
$emptyinfocounter++;
}
//print received bytes for host
echo $receivebytesarray[$emptyinfocounter] . ";";
$transmitbytesarray = explode(" ",$splitinfo[1]);
$emptyinfocounter = 1;
//skip empty array elements until first element found with data
while ($transmitbytesarray[$emptyinfocounter] == "")
{
$emptyinfocounter++;
}
//print transmitted bytes for host
echo $transmitbytesarray[$emptyinfocounter] . "|";
//mark that we collected information
$someinfo = true;
}
}
//no bandwidth usage found
if ($someinfo == false)
echo "no info";
?>
|