Project

General

Profile

Download (1.84 KB) Statistics
| Branch: | Tag: | Revision:
1 19ac33af Scott Ullrich
<?php
2
/*
3 0f3f6cc9 Jared Dillard
 * ifstats.php
4 fd9ebcd5 Stephen Beaver
 *
5 0f3f6cc9 Jared Dillard
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
9 0f3f6cc9 Jared Dillard
 * All rights reserved.
10 fd9ebcd5 Stephen Beaver
 *
11 0f3f6cc9 Jared Dillard
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14 fd9ebcd5 Stephen Beaver
 *
15 0f3f6cc9 Jared Dillard
 * http://www.apache.org/licenses/LICENSE-2.0
16 fd9ebcd5 Stephen Beaver
 *
17 0f3f6cc9 Jared Dillard
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22 fd9ebcd5 Stephen Beaver
 */
23 19ac33af Scott Ullrich
24 6b07c15a Matthew Grooms
##|+PRIV
25
##|*IDENT=page-xmlrpcinterfacestats
26 5230f468 jim-p
##|*NAME=XMLRPC Interface Stats
27 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'XMLRPC Interface Stats' page.
28
##|*MATCH=ifstats.php*
29
##|-PRIV
30
31 849d3a37 Jared Dillard
$nocsrf = true;
32
33 c07071cb PiBa-NL
require_once('auth_check.inc');
34 849d3a37 Jared Dillard
35
if($_POST['if']) {
36
	$ifs = $_POST['if'];
37 d3fd2bbe PiBa-NL
	$realifs = $_POST['realif'];
38 849d3a37 Jared Dillard
39
	$ifarray = explode("|", $ifs);
40 d3fd2bbe PiBa-NL
	$realifarray = explode("|", $realifs);
41 849d3a37 Jared Dillard
42
	$temp = gettimeofday();
43
	$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
44
	$obj = [];
45
	$count = 0;
46
47 d3fd2bbe PiBa-NL
	$i = 0;
48
	for ($i = 0; $i < count($ifarray); $i++) {
49
		$if = $ifarray[$i];
50
		$realif = $realifarray[$i];
51 849d3a37 Jared Dillard
		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
66
	header('Content-Type: application/json');
67
	echo json_encode($obj,JSON_PRETTY_PRINT|JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_NUMERIC_CHECK);
68
}