Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
97b3dc1f
Commit
97b3dc1f
authored
Apr 12, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(network insight) optimize api
parent
aaf2cd1d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
NetworkinsightController.php
...ers/OPNsense/Diagnostics/Api/NetworkinsightController.php
+22
-18
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetworkinsightController.php
View file @
97b3dc1f
...
...
@@ -70,13 +70,6 @@ class NetworkinsightController extends ApiControllerBase
$resolution
=
$filter
->
sanitize
(
$resolution
,
"int"
);
$field
=
$filter
->
sanitize
(
$field
,
"string"
);
// map physical interfaces to description / name
$configObj
=
Config
::
getInstance
()
->
object
();
$allInterfaces
=
array
();
foreach
(
$configObj
->
interfaces
->
children
()
as
$key
=>
$intf
)
{
$allInterfaces
[(
string
)
$intf
->
if
]
=
empty
(
$intf
->
descr
)
?
$key
:
(
string
)
$intf
->
descr
;
}
$result
=
array
();
if
(
$this
->
request
->
isGet
())
{
$backend
=
new
Backend
();
...
...
@@ -88,10 +81,10 @@ class NetworkinsightController extends ApiControllerBase
if
(
$graph_data
!=
null
)
{
ksort
(
$graph_data
);
$timeseries
=
array
();
foreach
(
$graph_data
as
$timeserie
=>
$
interfaces
)
{
foreach
(
$
interfaces
as
$interface
=>
$payload
)
{
if
(
!
isset
(
$timeseries
[
$
interface
]))
{
$timeseries
[
$
interface
]
=
array
();
foreach
(
$graph_data
as
$timeserie
=>
$
timeserie_data
)
{
foreach
(
$
timeserie_data
as
$timeserie_key
=>
$payload
)
{
if
(
!
isset
(
$timeseries
[
$
timeserie_key
]))
{
$timeseries
[
$
timeserie_key
]
=
array
();
}
// measure value
$measure_val
=
0
;
...
...
@@ -105,18 +98,29 @@ class NetworkinsightController extends ApiControllerBase
$measure_val
=
$payload
[
'packets'
]
/
$payload
[
'resolution'
];
}
// add to timeseries
$timeseries
[
$
interface
][]
=
array
((
int
)
$timeserie
*
1000
,
$measure_val
);
$timeseries
[
$
timeserie_key
][]
=
array
((
int
)
$timeserie
*
1000
,
$measure_val
);
}
}
foreach
(
$timeseries
as
$interface
=>
$data
)
{
if
(
isset
(
$allInterfaces
[
$interface
]))
{
$result
[]
=
array
(
"key"
=>
$allInterfaces
[
$interface
],
"values"
=>
$data
);
}
else
{
$result
[]
=
array
(
"key"
=>
$interface
,
"values"
=>
$data
);
}
foreach
(
$timeseries
as
$timeserie_key
=>
$data
)
{
$result
[]
=
array
(
"key"
=>
$timeserie_key
,
"values"
=>
$data
);
}
}
}
return
$result
;
}
/**
* return interface map (device / name)
* @return array interfaces
*/
public
function
getInterfacesAction
()
{
// map physical interfaces to description / name
$configObj
=
Config
::
getInstance
()
->
object
();
$allInterfaces
=
array
();
foreach
(
$configObj
->
interfaces
->
children
()
as
$key
=>
$intf
)
{
$allInterfaces
[(
string
)
$intf
->
if
]
=
empty
(
$intf
->
descr
)
?
$key
:
(
string
)
$intf
->
descr
;
}
return
$allInterfaces
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment