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
72c3c8c4
Commit
72c3c8c4
authored
Mar 25, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(netflow) add some configd/api commands
parent
42dc887c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
NetflowController.php
...ontrollers/OPNsense/Diagnostics/Api/NetflowController.php
+42
-0
actions_netflow.conf
src/opnsense/service/conf/actions.d/actions_netflow.conf
+24
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php
View file @
72c3c8c4
...
@@ -33,6 +33,7 @@ namespace OPNsense\Diagnostics\Api;
...
@@ -33,6 +33,7 @@ namespace OPNsense\Diagnostics\Api;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Diagnostics\Netflow
;
use
\OPNsense\Diagnostics\Netflow
;
use
\OPNsense\Core\Config
;
use
\OPNsense\Core\Config
;
use
\OPNsense\Core\Backend
;
/**
/**
* Class NetflowController
* Class NetflowController
...
@@ -83,4 +84,45 @@ class NetflowController extends ApiControllerBase
...
@@ -83,4 +84,45 @@ class NetflowController extends ApiControllerBase
}
}
return
$result
;
return
$result
;
}
}
/**
* configure start/stop netflow
* @return array
*/
public
function
reconfigureAction
()
{
if
(
$this
->
request
->
isPost
())
{
// close session for long running action
$this
->
sessionClose
();
// reconfigure netflow
$backend
=
new
Backend
();
$backend
->
configdRun
(
"template reload OPNsense.Netflow"
);
// restart netflow, by calling stop (which will always stop the collectors) and start
// (which will only start if there are collectors configured)
$backend
->
configdRun
(
"netflow stop"
);
$backend
->
configdRun
(
"netflow start"
);
return
array
(
"status"
=>
"ok"
);
}
else
{
return
array
(
"status"
=>
"error"
);
}
}
/**
* request netflow status
* @return array
*/
public
function
statusAction
()
{
$backend
=
new
Backend
();
$status
=
trim
(
$backend
->
configdRun
(
"netflow status"
));
if
(
strpos
(
$status
,
"netflow is active"
)
!==
false
)
{
// active, return status active + number of configured collectors
$collectors
=
trim
(
explode
(
')'
,
explode
(
':'
,
$status
)[
1
])[
0
]);
return
array
(
"status"
=>
"active"
,
"collectors"
=>
$collectors
);
}
else
{
// inactive
return
array
(
"status"
=>
"inactive"
);
}
}
}
}
src/opnsense/service/conf/actions.d/actions_netflow.conf
0 → 100644
View file @
72c3c8c4
[
stop
]
command
:/
usr
/
local
/
etc
/
rc
.
d
/
netflow
onestop
parameters
:
type
:
script
message
:
stop
netflow
[
start
]
command
:/
usr
/
local
/
etc
/
rc
.
d
/
netflow
start
parameters
:
type
:
script
message
:
start
netflow
[
restart
]
command
:/
usr
/
local
/
etc
/
rc
.
d
/
netflow
restart
parameters
:
type
:
script
message
:
restart
netflow
[
status
]
command
:/
usr
/
local
/
etc
/
rc
.
d
/
netflow
status
||
exit
0
parameters
:
type
:
script_output
message
:
get
netflow
status
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