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 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
0f3f6cc9
|
Jared Dillard
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
0f3f6cc9
|
Jared Dillard
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
0f3f6cc9
|
Jared Dillard
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
0f3f6cc9
|
Jared Dillard
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
21 |
19ac33af
|
Scott Ullrich
|
|
22 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-xmlrpcinterfacestats
|
24 |
5230f468
|
jim-p
|
##|*NAME=XMLRPC Interface Stats
|
25 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'XMLRPC Interface Stats' page.
|
26 |
|
|
##|*MATCH=ifstats.php*
|
27 |
|
|
##|-PRIV
|
28 |
|
|
|
29 |
849d3a37
|
Jared Dillard
|
$nocsrf = true;
|
30 |
|
|
|
31 |
c07071cb
|
PiBa-NL
|
require_once('auth_check.inc');
|
32 |
849d3a37
|
Jared Dillard
|
|
33 |
|
|
if($_POST['if']) {
|
34 |
|
|
$ifs = $_POST['if'];
|
35 |
d3fd2bbe
|
PiBa-NL
|
$realifs = $_POST['realif'];
|
36 |
849d3a37
|
Jared Dillard
|
|
37 |
|
|
$ifarray = explode("|", $ifs);
|
38 |
d3fd2bbe
|
PiBa-NL
|
$realifarray = explode("|", $realifs);
|
39 |
849d3a37
|
Jared Dillard
|
|
40 |
|
|
$temp = gettimeofday();
|
41 |
|
|
$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
|
42 |
|
|
$obj = [];
|
43 |
|
|
$count = 0;
|
44 |
|
|
|
45 |
d3fd2bbe
|
PiBa-NL
|
$i = 0;
|
46 |
|
|
for ($i = 0; $i < count($ifarray); $i++) {
|
47 |
|
|
$if = $ifarray[$i];
|
48 |
|
|
$realif = $realifarray[$i];
|
49 |
849d3a37
|
Jared Dillard
|
if (!$realif) {
|
50 |
|
|
$realif = $if; // Need for IPsec case interface.
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
$ifinfo = pfSense_get_interface_stats($realif);
|
54 |
|
|
|
55 |
|
|
$obj[$if] = [];
|
56 |
|
|
|
57 |
|
|
$obj[$if][0]['key'] = $if . "in";
|
58 |
|
|
$obj[$if][0]['values'] = array($timing, $ifinfo['inbytes']);
|
59 |
|
|
|
60 |
|
|
$obj[$if][1]['key'] = $if . "out";
|
61 |
|
|
$obj[$if][1]['values'] = array($timing, $ifinfo['outbytes']);
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
header('Content-Type: application/json');
|
65 |
|
|
echo json_encode($obj,JSON_PRETTY_PRINT|JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_NUMERIC_CHECK);
|
66 |
|
|
}
|