1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
ifstats.php
|
5
|
part of pfSense (https://www.pfsense.org)
|
6
|
|
7
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
8
|
Copyright (C) 2005-2006 Scott Ullrich (sullrich@gmail.com)
|
9
|
All rights reserved.
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, are permitted provided that the following conditions are met:
|
13
|
|
14
|
1. Redistributions of source code must retain the above copyright notice,
|
15
|
this list of conditions and the following disclaimer.
|
16
|
|
17
|
2. Redistributions in binary form must reproduce the above copyright
|
18
|
notice, this list of conditions and the following disclaimer in the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
/*
|
33
|
pfSense_BUILDER_BINARIES: /usr/bin/netstat
|
34
|
pfSense_MODULE: interfaces
|
35
|
*/
|
36
|
|
37
|
##|+PRIV
|
38
|
##|*IDENT=page-xmlrpcinterfacestats
|
39
|
##|*NAME=XMLRPC Interface Stats page
|
40
|
##|*DESCR=Allow access to the 'XMLRPC Interface Stats' page.
|
41
|
##|*MATCH=ifstats.php*
|
42
|
##|-PRIV
|
43
|
|
44
|
require_once('guiconfig.inc');
|
45
|
require_once("interfaces.inc");
|
46
|
|
47
|
$if = $_GET['if'];
|
48
|
|
49
|
$realif = get_real_interface($if);
|
50
|
if(!$realif)
|
51
|
$realif = $if; // Need for IPsec case interface.
|
52
|
|
53
|
$ifinfo = pfSense_get_interface_stats($realif);
|
54
|
|
55
|
$temp = gettimeofday();
|
56
|
$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
|
57
|
|
58
|
header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
|
59
|
header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
|
60
|
header("Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
|
61
|
header("Cache-Control: post-check=0, pre-check=0", FALSE );
|
62
|
header("Pragma: no-cache"); // HTTP/1.0
|
63
|
|
64
|
echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
|
65
|
|
66
|
?>
|