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 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 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 |
|
|
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 |
19ac33af
|
Scott Ullrich
|
|
84 |
|
|
$if = $_GET['if'];
|
85 |
|
|
|
86 |
85a5da13
|
Ermal Luçi
|
$realif = get_real_interface($if);
|
87 |
849d3a37
|
Jared Dillard
|
|
88 |
45b4ffc6
|
Phil Davis
|
if (!$realif) {
|
89 |
3c4fc30b
|
Chris Buechler
|
$realif = $if; // Need for IPsec case interface.
|
90 |
45b4ffc6
|
Phil Davis
|
}
|
91 |
19ac33af
|
Scott Ullrich
|
|
92 |
8e23b225
|
Ermal
|
$ifinfo = pfSense_get_interface_stats($realif);
|
93 |
|
|
|
94 |
19ac33af
|
Scott Ullrich
|
$temp = gettimeofday();
|
95 |
31cb8b31
|
Scott Ullrich
|
$timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
|
96 |
2c5fda82
|
Jose Luis Duran
|
|
97 |
6c07db48
|
Phil Davis
|
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 |
45581172
|
Ermal Luçi
|
header("Pragma: no-cache"); // HTTP/1.0
|
101 |
19ac33af
|
Scott Ullrich
|
|
102 |
deea2272
|
Scott Ullrich
|
echo "$timing|" . $ifinfo['inbytes'] . "|" . $ifinfo['outbytes'] . "\n";
|
103 |
19ac33af
|
Scott Ullrich
|
|
104 |
849d3a37
|
Jared Dillard
|
}
|
105 |
|
|
|
106 |
8e23b225
|
Ermal
|
?>
|