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
b154aedb
Commit
b154aedb
authored
Apr 13, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(netflow, flowd aggregation) add top command to api
parent
9d44ed8f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
7 deletions
+52
-7
NetworkinsightController.php
...ers/OPNsense/Diagnostics/Api/NetworkinsightController.php
+52
-7
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetworkinsightController.php
View file @
b154aedb
...
...
@@ -44,12 +44,12 @@ class NetworkinsightController extends ApiControllerBase
{
/**
* request timeserie data to use for reporting
* @param $provider provider class name
* @param $measure measure [octets, packets, octets_ps, packets_ps]
* @param $from_date from timestamp
* @param $to_date to timestamp
* @param $resolution resolution in seconds
* @param $field field name to aggregate
* @param
string
$provider provider class name
* @param
string
$measure measure [octets, packets, octets_ps, packets_ps]
* @param
string
$from_date from timestamp
* @param
string
$to_date to timestamp
* @param
string
$resolution resolution in seconds
* @param
string
$field field name to aggregate
* @return array timeseries
*/
public
function
timeserieAction
(
...
...
@@ -76,7 +76,7 @@ class NetworkinsightController extends ApiControllerBase
// request current data
$response
=
$backend
->
configdRun
(
"netflow aggregate fetch
{
$provider
}
{
$from_date
}
{
$to_date
}
{
$resolution
}
{
$field
}
"
);
//
// for test, request random data
//$response = $backend->configdRun("netflow aggregate fetch {$provider} {$from_date} {$to_date} {$resolution} {$field} em0,
em1,em2,em3,em4
"); //
//$response = $backend->configdRun("netflow aggregate fetch {$provider} {$from_date} {$to_date} {$resolution} {$field} em0,
in~em0,out~em1,in~em1,out~em2,in~em2,out~em3,in~em3,out
"); //
$graph_data
=
json_decode
(
$response
,
true
);
if
(
$graph_data
!=
null
)
{
ksort
(
$graph_data
);
...
...
@@ -109,6 +109,51 @@ class NetworkinsightController extends ApiControllerBase
return
$result
;
}
/**
* request top usage data (for reporting), values can optionally be filtered using filter_field and filter_value
* @param string $provider provider class name
* @param string $from_date from timestamp
* @param string $to_date to timestamp
* @param string $field field name(s) to aggregate
* @param string $measure measure [octets, packets]
* @param string $max_hits maximum number of results
* @return array timeseries
*/
public
function
topAction
(
$provider
=
null
,
$from_date
=
null
,
$to_date
=
null
,
$field
=
null
,
$measure
=
null
,
$max_hits
=
null
)
{
// cleanse input
$filter
=
new
Filter
();
$provider
=
$filter
->
sanitize
(
$provider
,
"alphanum"
);
$from_date
=
$filter
->
sanitize
(
$from_date
,
"int"
);
$to_date
=
$filter
->
sanitize
(
$to_date
,
"int"
);
$field
=
$filter
->
sanitize
(
$field
,
"string"
);
$measure
=
$filter
->
sanitize
(
$measure
,
"string"
);
$max_hits
=
$filter
->
sanitize
(
$max_hits
,
"int"
);
$result
=
array
();
if
(
$this
->
request
->
isGet
())
{
if
(
$this
->
request
->
get
(
"filter_field"
)
!=
null
&&
$this
->
request
->
get
(
"filter_value"
)
!=
null
)
{
$data_filter
=
$this
->
request
->
get
(
"filter_field"
)
.
"="
.
$this
->
request
->
get
(
"filter_value"
);
}
else
{
$data_filter
=
""
;
}
$backend
=
new
Backend
();
$configd_cmd
=
"netflow aggregate top
{
$provider
}
{
$from_date
}
{
$to_date
}
{
$field
}
"
;
$configd_cmd
.=
"
{
$measure
}
{
$data_filter
}
{
$max_hits
}
"
;
$response
=
$backend
->
configdRun
(
$configd_cmd
);
//
$graph_data
=
json_decode
(
$response
,
true
);
if
(
$graph_data
!=
null
)
{
return
$graph_data
;
}
}
}
/**
* return interface map (device / name)
* @return array interfaces
...
...
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