Project

General

Profile

« Previous | Next » 

Revision 8e23b225

Added by Ermal LUÇI almost 15 years ago

Ticket #682. Use pfSense modules function to collect interface stats.

View differences:

usr/local/www/ifstats.php
43 43
	require_once('guiconfig.inc');
44 44
	require_once("interfaces.inc");
45 45

  
46
	$ifinfo = array();
47

  
48 46
	$if = $_GET['if'];
49 47

  
50 48
	$realif = get_real_interface($if);
51 49
	if(!$realif)
52 50
		$realif = $if; // Need for IPSec case interface.
53 51

  
54
	/* run netstat to determine link info */
55
	$linkinfo = "";
56
	unset($linkinfo);
57
	exec("/usr/bin/netstat -I {$realif} -nWb -f link", $linkinfo);
58
	$linkinfo = preg_split("/\s+/", $linkinfo[1]);
59
	if (preg_match("/^enc|^tun|^pppoe|^pptp/i", $realif)) {
60
		$ifinfo['inpkts'] = $linkinfo[3];
61
		$ifinfo['inbytes'] = $linkinfo[6];
62
		$ifinfo['outpkts'] = $linkinfo[7];
63
		$ifinfo['outbytes'] = $linkinfo[9];
64
	} else {
65
		$ifinfo['inpkts'] = $linkinfo[4];
66
		$ifinfo['inbytes'] = $linkinfo[7];
67
		$ifinfo['outpkts'] = $linkinfo[8];
68
		$ifinfo['outbytes'] = $linkinfo[10];
69
	}
52
	$ifinfo = pfSense_get_interface_stats($realif);
53

  
70 54
	$temp = gettimeofday();
71 55
	$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
72 56
	
......
78 62

  
79 63
	echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
80 64

  
81
?>
65
?>

Also available in: Unified diff