Project

General

Profile

Download (1.4 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 13d193c2 Scott Ullrich
/*
9
	pfSense_BUILDER_BINARIES:	/usr/local/bin/rate
10
	pfSense_MODULE:	trafficgraph
11
*/
12
13 f0a3b883 Scott Ullrich
require_once('guiconfig.inc');
14
require_once('interfaces.inc');
15
require_once('pfsense-utils.inc');
16
require_once('util.inc');
17
18
$listedIPs = "";
19
20
//get interface IP and break up into an array
21
$interface = $_GET['if'];
22
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
23
$intip = find_interface_ip($real_interface);
24
$intip = explode (".", $intip);
25
26
//use class A subnet to make sure we capture all traffic on specified interface
27
$intsubnet = $intip[0] . ".0.0.0/8";
28
29 f1aad4d1 Ermal
exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 -c {$intsubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1,  $2,  $4,  $6,  $8 }'", $listedIPs);
30 f0a3b883 Scott Ullrich
31
unset($bandwidthinfo);
32
unset($receivebytesarray);
33
unset($transmitbytesarray);
34
35
$someinfo = false;
36
for ($x=2; $x<12; $x++){
37
38
    $bandwidthinfo = $listedIPs[$x];
39
40
   // echo $bandwidthinfo;
41
    $emptyinfocounter = 1;
42
    if ($bandwidthinfo != "") {
43 6745e860 Ermal Lu?i
        $infoarray = explode (":",$bandwidthinfo);
44 f0a3b883 Scott Ullrich
        //print IP of host;
45 6745e860 Ermal Lu?i
        echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
46 f0a3b883 Scott Ullrich
47
        //mark that we collected information
48
        $someinfo = true;
49
    }
50
}
51
52
//no bandwidth usage found
53
if ($someinfo == false)
54 a1129192 Carlos Eduardo Ramos
    echo gettext("no info");
55 f0a3b883 Scott Ullrich
56
?>