Project

General

Profile

Download (1.37 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 -Aa 10 -c {$intsubnet} | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1,  $2,  $5,  $8,  $11 }'", $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
        $infoarray = explode (":",$bandwidthinfo);
48
        //print IP of host;
49
        echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
50

    
51
        //mark that we collected information
52
        $someinfo = true;
53
    }
54
}
55

    
56

    
57
//no bandwidth usage found
58
if ($someinfo == false)
59
    echo "no info";
60

    
61
?>
(2-2/218)