mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
parent
8dd781b855
commit
04db8cc274
24 changed files with 75 additions and 519 deletions
|
|
@ -87,7 +87,6 @@ local endpoint_list = "/lua/rest/v1/get/host/alert/list.lua"
|
|||
local endpoint_ts = "/lua/rest/v1/get/host/alert/ts.lua"
|
||||
local endpoint_delete = "/lua/rest/v1/delete/host/alerts.lua"
|
||||
local endpoint_acknowledge = "/lua/rest/v1/acknowledge/host/alerts.lua"
|
||||
local endpoint_label = "/lua/rest/v1/label/host/alerts.lua"
|
||||
|
||||
-- Preserve page params when switching between tabs
|
||||
local base_params = table.clone(_GET)
|
||||
|
|
@ -115,7 +114,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/host/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/host/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/host/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/host/alerts.lua",
|
||||
url = getPageUrl(base_url, {page = "host"}),
|
||||
hidden = is_system_interface or not require "host_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.host.entity_id)]
|
||||
|
|
@ -128,7 +126,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/interface/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/interface/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/interface/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/interface/alerts.lua",
|
||||
url = getPageUrl(base_url, {page = "interface"}),
|
||||
hidden = not require "interface_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.interface.entity_id)]
|
||||
|
|
@ -141,7 +138,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/network/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/network/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/network/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/network/alerts.lua",
|
||||
url = getPageUrl(base_url, {page = "network"}),
|
||||
hidden = is_system_interface or not require "network_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.network.entity_id)]
|
||||
|
|
@ -154,7 +150,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/pro/rest/v1/get/snmp/device/alert/ts.lua",
|
||||
endpoint_delete = "/lua/pro/rest/v1/delete/snmp/device/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/pro/rest/v1/acknowledge/snmp/device/alerts.lua",
|
||||
endpoint_label = "/lua/pro/rest/v1/label/snmp/device/alerts.lua",
|
||||
url = getPageUrl(base_url_historical_only, {page = "snmp_device"}),
|
||||
hidden = not is_system_interface or not ntop.isPro() or not require "snmp_device_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.snmp_device.entity_id)]
|
||||
|
|
@ -167,7 +162,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/flow/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/flow/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/flow/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/flow/alerts.lua",
|
||||
url = getPageUrl(base_url_historical_only, {page = "flow"}),
|
||||
hidden = is_system_interface or not require "flow_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.flow.entity_id)]
|
||||
|
|
@ -180,7 +174,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/mac/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/mac/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/mac/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/mac/alerts.lua",
|
||||
url = getPageUrl(base_url_historical_only, {page = "mac"}),
|
||||
hidden = is_system_interface or not require "mac_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.mac.entity_id)]
|
||||
|
|
@ -193,7 +186,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/system/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/system/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/system/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/system/alerts.lua",
|
||||
url = getPageUrl(base_url_historical_only, {page = "system"}),
|
||||
hidden = not is_system_interface or not require "system_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.system.entity_id)]
|
||||
|
|
@ -206,7 +198,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/am_host/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/am_host/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/am_host/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/am_host/alerts.lua",
|
||||
url = getPageUrl(base_url, {page = "am_host"}),
|
||||
hidden = not is_system_interface or not require "am_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.am_host.entity_id)]
|
||||
|
|
@ -219,7 +210,6 @@ local pages = {
|
|||
endpoint_ts = "/lua/rest/v1/get/user/alert/ts.lua",
|
||||
endpoint_delete = "/lua/rest/v1/delete/user/alerts.lua",
|
||||
endpoint_acknowledge = "/lua/rest/v1/acknowledge/user/alerts.lua",
|
||||
endpoint_label = "/lua/rest/v1/label/user/alerts.lua",
|
||||
url = getPageUrl(base_url_historical_only, {page = "user"}),
|
||||
hidden = not is_system_interface or not require "user_alert_store".new():has_alerts(),
|
||||
badge_num = num_alerts_engaged_by_entity[tostring(alert_entities.user.entity_id)]
|
||||
|
|
@ -237,7 +227,6 @@ for i = #pages, 1, -1 do
|
|||
endpoint_ts = cur_page.endpoint_ts
|
||||
endpoint_delete = cur_page.endpoint_delete
|
||||
endpoint_acknowledge = cur_page.endpoint_acknowledge
|
||||
endpoint_label = cur_page.endpoint_label
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -283,7 +272,7 @@ local modals = {
|
|||
no_confirm_id = true
|
||||
}
|
||||
}),
|
||||
["acknowledge_alert_dialog"] = template_utils.gen("modal_confirm_dialog_form.template", {
|
||||
["acknowledge_alert_dialog"] = template_utils.gen("pages/modals/alerts/acknowledge_alert.template", {
|
||||
dialog = {
|
||||
id = "acknowledge_alert_dialog",
|
||||
title = i18n("show_alerts.acknowledge_alert"),
|
||||
|
|
@ -294,16 +283,6 @@ local modals = {
|
|||
no_confirm_id = true
|
||||
}
|
||||
}),
|
||||
["label_alert_dialog"] = template_utils.gen("pages/modals/alerts/label_alert.template", {
|
||||
dialog = {
|
||||
id = "label_alert_dialog",
|
||||
title = i18n("show_alerts.label_alert"),
|
||||
message = i18n("show_alerts.confirm_label_alert"),
|
||||
confirm = i18n("label"),
|
||||
confirm_button = "btn-primary",
|
||||
custom_alert_class = "alert alert-warning",
|
||||
}
|
||||
}),
|
||||
["alerts_filter_dialog"] = template_utils.gen("pages/modals/modal_alerts_filter_dialog.html", {
|
||||
dialog = {
|
||||
id = "alerts_filter_dialog",
|
||||
|
|
@ -349,16 +328,6 @@ local modals = {
|
|||
apply = i18n("acknowledge")
|
||||
}
|
||||
}),
|
||||
["label-alerts-modal"] = template_utils.gen("pages/modals/alerts/label_alerts.template",{
|
||||
dialog = {
|
||||
id = "label-alerts-modal",
|
||||
title = i18n("label_alerts"),
|
||||
label = "",
|
||||
message = i18n("show_alerts.confirm_label_alerts"),
|
||||
cancel = i18n("cancel"),
|
||||
apply = i18n("label")
|
||||
}
|
||||
}),
|
||||
["external-link"] = template_utils.gen("pages/modals/alerts/redirect_modal.template", {
|
||||
dialog={
|
||||
id = "external-link",
|
||||
|
|
@ -528,7 +497,6 @@ local context = {
|
|||
endpoint_list = endpoint_list,
|
||||
endpoint_delete = endpoint_delete,
|
||||
endpoint_acknowledge = endpoint_acknowledge,
|
||||
endpoint_label = endpoint_label,
|
||||
datasource = Datasource(endpoint_list, {
|
||||
ifid = ifid,
|
||||
epoch_begin = epoch_begin,
|
||||
|
|
|
|||
|
|
@ -553,24 +553,11 @@ end
|
|||
-- ##############################################
|
||||
|
||||
--@brief Labels alerts according to specified filters
|
||||
function alert_store:label(label)
|
||||
function alert_store:acknowledge(label)
|
||||
local where_clause = self:build_where_clause()
|
||||
|
||||
-- Prepare the final query
|
||||
local q = string.format("UPDATE `%s` SET `user_label` = '%s', `user_label_tstamp` = %u WHERE %s", self._table_name, self:_escape(label), os.time(), where_clause)
|
||||
|
||||
local res = interface.alert_store_query(q)
|
||||
return res and table.len(res) == 0
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--@brief Acknowledges alerts according to specified filters
|
||||
function alert_store:acknowledge()
|
||||
local where_clause = self:build_where_clause()
|
||||
|
||||
-- Prepare the final query
|
||||
local q = string.format("UPDATE `%s` SET alert_status = %u WHERE %s", self._table_name, alert_consts.alert_status.acknowledged.alert_status_id, where_clause)
|
||||
local q = string.format("UPDATE `%s` SET `alert_status` = %u, `user_label` = '%s', `user_label_tstamp` = %u WHERE %s", self._table_name, alert_consts.alert_status.acknowledged.alert_status_id, self:_escape(label), os.time(), where_clause)
|
||||
|
||||
local res = interface.alert_store_query(q)
|
||||
return res and table.len(res) == 0
|
||||
|
|
|
|||
|
|
@ -53,12 +53,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function all_alert_store:label()
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, "Unsupported!")
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--@brief Selects engaged alerts from memory
|
||||
--@return Selected engaged alerts, and the total number of engaged alerts
|
||||
function alert_store:select_engaged(filter)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ local am_alert_store = require "am_alert_store".new()
|
|||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{}' http://localhost:3000/lua/rest/v1/acknowledge/am_host/alerts.lua
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/am_host/alerts.lua
|
||||
--
|
||||
-- NOTE: in case of invalid login, no error is returned but redirected to login
|
||||
--
|
||||
|
|
@ -27,7 +27,7 @@ interface.select(getSystemInterfaceId())
|
|||
-- Add filters
|
||||
am_alert_store:add_request_filters()
|
||||
|
||||
am_alert_store:acknowledge()
|
||||
am_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ interface.select(ifid)
|
|||
-- Add filters
|
||||
flow_alert_store:add_request_filters()
|
||||
|
||||
flow_alert_store:acknowledge()
|
||||
|
||||
flow_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ interface.select(ifid)
|
|||
-- Add filters
|
||||
host_alert_store:add_request_filters()
|
||||
|
||||
host_alert_store:acknowledge()
|
||||
host_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ interface.select(ifid)
|
|||
-- Add filters
|
||||
interface_alert_store:add_request_filters()
|
||||
|
||||
interface_alert_store:acknowledge()
|
||||
interface_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ interface.select(ifid)
|
|||
-- Add filters
|
||||
mac_alert_store:add_request_filters()
|
||||
|
||||
mac_alert_store:acknowledge()
|
||||
mac_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ interface.select(ifid)
|
|||
-- Add filters
|
||||
network_alert_store:add_request_filters()
|
||||
|
||||
network_alert_store:acknowledge()
|
||||
network_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ interface.select(getSystemInterfaceId())
|
|||
-- Add filters
|
||||
system_alert_store:add_request_filters()
|
||||
|
||||
system_alert_store:acknowledge()
|
||||
system_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ interface.select(getSystemInterfaceId())
|
|||
-- Add filters
|
||||
user_alert_store:add_request_filters()
|
||||
|
||||
user_alert_store:acknowledge()
|
||||
user_alert_store:acknowledge(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local flow_alert_store = require "flow_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/label/flow/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
flow_alert_store:add_request_filters()
|
||||
|
||||
tprint(_GET["label"])
|
||||
flow_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local flow_alert_store = require "flow_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/label/flow/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
flow_alert_store:add_request_filters()
|
||||
|
||||
|
||||
flow_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local host_alert_store = require "host_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
host_alert_store:add_request_filters()
|
||||
|
||||
host_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local interface_alert_store = require "interface_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/interface/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
interface_alert_store:add_request_filters()
|
||||
|
||||
interface_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local mac_alert_store = require "mac_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/mac/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
mac_alert_store:add_request_filters()
|
||||
|
||||
mac_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local network_alert_store = require "network_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/network/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 = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
interface.select(ifid)
|
||||
|
||||
-- Add filters
|
||||
network_alert_store:add_request_filters()
|
||||
|
||||
network_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local system_alert_store = require "system_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{}' http://localhost:3000/lua/rest/v1/acknowledge/system/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 = {}
|
||||
|
||||
interface.select(getSystemInterfaceId())
|
||||
|
||||
-- Add filters
|
||||
system_alert_store:add_request_filters()
|
||||
|
||||
system_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/alert_store/?.lua;" .. package.path
|
||||
|
||||
local alert_utils = require "alert_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local alert_entities = require "alert_entities"
|
||||
local rest_utils = require("rest_utils")
|
||||
local user_alert_store = require "user_alert_store".new()
|
||||
|
||||
--
|
||||
-- Read alerts data
|
||||
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"ifid": "1"}' http://localhost:3000/lua/rest/v1/acknowledge/user/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 = {}
|
||||
|
||||
interface.select(getSystemInterfaceId())
|
||||
|
||||
-- Add filters
|
||||
user_alert_store:add_request_filters()
|
||||
|
||||
user_alert_store:label(_GET["label"])
|
||||
|
||||
rest_utils.answer(rc)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue