Project

General

Profile

Download (1.89 KB) Statistics
| Branch: | Tag: | Revision:
1 f0a3b883 Scott Ullrich
<?php
2
/* 
3
 * To change this template, choose Tools | Templates
4
 * and open the template in the editor.
5
 *
6
 *
7
 *
8
 *
9
 *
10
 */
11
12
require_once('guiconfig.inc');
13
require_once('interfaces.inc');
14
require_once('pfsense-utils.inc');
15
require_once('util.inc');
16
17
$listedIPs = "";
18
19
//get interface IP and break up into an array
20
$interface = $_GET['if'];
21
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
22
$intip = find_interface_ip($real_interface);
23
$intip = explode (".", $intip);
24
25
//use class A subnet to make sure we capture all traffic on specified interface
26
$intsubnet = $intip[0] . ".0.0.0/8";
27
28
exec("rate -i {$real_interface} -nlq 1 -A -c {$intsubnet}", $listedIPs);
29
30
unset($bandwidthinfo);
31
unset($receivebytesarray);
32
unset($transmitbytesarray);
33
34
$someinfo = false;
35
for ($x=2; $x<12; $x++){
36
37
    $bandwidthinfo = $listedIPs[$x];
38
39
   // echo $bandwidthinfo;
40
    $emptyinfocounter = 1;
41
    if ($bandwidthinfo != "") {
42
        $splitinfo = explode ("|",$bandwidthinfo);
43
        $receivebytesarray = explode(" ",$splitinfo[0]);
44
        //print IP of host;
45
        echo $receivebytesarray[0] . ";";
46
47
        //skip empty array elements until first element found with data
48
        while ($receivebytesarray[$emptyinfocounter] == "")
49
        {
50
            $emptyinfocounter++;
51
        }
52
        //print received bytes for host
53
        echo $receivebytesarray[$emptyinfocounter] . ";";
54
55
        $transmitbytesarray = explode(" ",$splitinfo[1]);
56
57
        $emptyinfocounter = 1;
58
59
        //skip empty array elements until first element found with data
60
        while ($transmitbytesarray[$emptyinfocounter] == "")
61
        {
62
            $emptyinfocounter++;
63
        }
64
        //print transmitted bytes for host
65
        echo $transmitbytesarray[$emptyinfocounter] . "|";
66
67
        //mark that we collected information
68
        $someinfo = true;
69
    }
70
}
71
72
73
//no bandwidth usage found
74
if ($someinfo == false)
75
    echo "no info";
76
77
?>