mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Added inactive hosts filters and records download (#7580)
This commit is contained in:
parent
9f2abac50d
commit
7924aaf75e
10 changed files with 657 additions and 124 deletions
43
scripts/lua/rest/v2/delete/host/inactive_host.lua
Normal file
43
scripts/lua/rest/v2/delete/host/inactive_host.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
--
|
||||
-- (C) 2013-23 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
local rest_utils = require("rest_utils")
|
||||
local inactive_hosts_utils = require("inactive_hosts_utils")
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v2/delete/host/alerts.lua
|
||||
--
|
||||
-- NOTE: in case of invalid login, no error is returned but redirected to login
|
||||
--
|
||||
|
||||
local rc = rest_utils.consts.success.ok
|
||||
local res = {}
|
||||
|
||||
if not isAdministrator() then
|
||||
rest_utils.answer(rest_utils.consts.err.not_granted)
|
||||
return
|
||||
end
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
local serial_key = _GET["serial_key"]
|
||||
|
||||
if isEmptyString(ifid) or isEmptyString(serial_key) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
if tonumber(serial_key) then
|
||||
inactive_hosts_utils.deleteAllEntriesSince(ifid, tonumber(serial_key))
|
||||
elseif (serial_key == "all") then
|
||||
inactive_hosts_utils.deleteAllEntries(ifid)
|
||||
else
|
||||
inactive_hosts_utils.deleteSingleEntry(ifid, serial_key)
|
||||
end
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue