Project

General

Profile

Download (2.68 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * ifstats.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-xmlrpcinterfacestats
24
##|*NAME=XMLRPC Interface Stats
25
##|*DESCR=Allow access to the 'XMLRPC Interface Stats' page.
26
##|*MATCH=ifstats.php*
27
##|-PRIV
28

    
29
$nocsrf = true;
30

    
31
require_once('guiconfig.inc');
32
require_once("interfaces.inc");
33

    
34

    
35
//overload the use of this page until the conversion of both traffic graphs have been completed
36
if($_POST['if']) {
37

    
38
	$ifs = $_POST['if'];
39

    
40
	$ifarray = explode("|", $ifs);
41

    
42
	$temp = gettimeofday();
43
	$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
44
	$obj = [];
45
	$count = 0;
46

    
47
	foreach ($ifarray as $if) {
48

    
49
		$realif = get_real_interface($if);
50

    
51
		if (!$realif) {
52
			$realif = $if; // Need for IPsec case interface.
53
		}
54

    
55
		$ifinfo = pfSense_get_interface_stats($realif);
56

    
57
		$obj[$if] = [];
58

    
59
		$obj[$if][0]['key'] = $if . "in";
60
		$obj[$if][0]['values'] = array($timing, $ifinfo['inbytes']);
61

    
62
		$obj[$if][1]['key'] = $if . "out";
63
		$obj[$if][1]['values'] = array($timing, $ifinfo['outbytes']);
64
/*
65
		$obj[$count]['key'] = $if . "in";
66
		$obj[$count]['name'] = $if . " (in)";
67
		$obj[$count]['values'] = array($timing, $ifinfo['inbytes']);
68

    
69
		$count++;
70

    
71
		$obj[$count]['key'] = $if . "out";
72
		$obj[$count]['name'] = $if . " (out)";
73
		$obj[$count]['values'] = array($timing, $ifinfo['outbytes']);
74

    
75
		$count++;
76
*/
77
	}
78

    
79
	header('Content-Type: application/json');
80
	echo json_encode($obj,JSON_PRETTY_PRINT|JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_NUMERIC_CHECK);
81

    
82
} else {
83

    
84
	$if = $_GET['if'];
85

    
86
	$realif = get_real_interface($if);
87

    
88
	if (!$realif) {
89
		$realif = $if; // Need for IPsec case interface.
90
	}
91

    
92
	$ifinfo = pfSense_get_interface_stats($realif);
93

    
94
	$temp = gettimeofday();
95
	$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
96

    
97
	header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
98
	header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
99
	header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP/1.1
100
	header("Pragma: no-cache"); // HTTP/1.0
101

    
102
	echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
103

    
104
}
105

    
106
?>
(65-65/225)