Project

General

Profile

Download (1.97 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
/*
13
	pfSense_BUILDER_BINARIES:	/usr/local/bin/rate
14
	pfSense_MODULE:	trafficgraph
15
*/
16

    
17
require_once('guiconfig.inc');
18
require_once('interfaces.inc');
19
require_once('pfsense-utils.inc');
20
require_once('util.inc');
21

    
22
$listedIPs = "";
23

    
24
//get interface IP and break up into an array
25
$interface = $_GET['if'];
26
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
27
$intip = find_interface_ip($real_interface);
28
$intip = explode (".", $intip);
29

    
30
//use class A subnet to make sure we capture all traffic on specified interface
31
$intsubnet = $intip[0] . ".0.0.0/8";
32

    
33
exec("rate -i {$real_interface} -nlq 1 -A -c {$intsubnet}", $listedIPs);
34

    
35
unset($bandwidthinfo);
36
unset($receivebytesarray);
37
unset($transmitbytesarray);
38

    
39
$someinfo = false;
40
for ($x=2; $x<12; $x++){
41

    
42
    $bandwidthinfo = $listedIPs[$x];
43

    
44
   // echo $bandwidthinfo;
45
    $emptyinfocounter = 1;
46
    if ($bandwidthinfo != "") {
47
        $splitinfo = explode ("|",$bandwidthinfo);
48
        $receivebytesarray = explode(" ",$splitinfo[0]);
49
        //print IP of host;
50
        echo $receivebytesarray[0] . ";";
51

    
52
        //skip empty array elements until first element found with data
53
        while ($receivebytesarray[$emptyinfocounter] == "")
54
        {
55
            $emptyinfocounter++;
56
        }
57
        //print received bytes for host
58
        echo $receivebytesarray[$emptyinfocounter] . ";";
59

    
60
        $transmitbytesarray = explode(" ",$splitinfo[1]);
61

    
62
        $emptyinfocounter = 1;
63

    
64
        //skip empty array elements until first element found with data
65
        while ($transmitbytesarray[$emptyinfocounter] == "")
66
        {
67
            $emptyinfocounter++;
68
        }
69
        //print transmitted bytes for host
70
        echo $transmitbytesarray[$emptyinfocounter] . "|";
71

    
72
        //mark that we collected information
73
        $someinfo = true;
74
    }
75
}
76

    
77

    
78
//no bandwidth usage found
79
if ($someinfo == false)
80
    echo "no info";
81

    
82
?>
(1-1/217)