mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-06 03:45:26 +00:00
Add support for on/off alert configuration
This commit is contained in:
parent
c1b114e151
commit
3ab6ff7901
3 changed files with 30 additions and 2 deletions
|
|
@ -1077,7 +1077,11 @@ function drawAlertSourceSettings(entity_type, alert_source, delete_button_msg, d
|
|||
-- TODO refactor this into the threshold cross checker
|
||||
for k, check_module in pairs(descr) do
|
||||
value = _POST["value_"..k]
|
||||
operator = _POST["op_"..k]
|
||||
operator = _POST["op_"..k] or ""
|
||||
|
||||
if value == "on" then
|
||||
value = "1"
|
||||
end
|
||||
|
||||
if((value ~= nil) and (operator ~= nil)) then
|
||||
--io.write("\t"..k.."\n")
|
||||
|
|
@ -1229,6 +1233,16 @@ function drawAlertSourceSettings(entity_type, alert_source, delete_button_msg, d
|
|||
if check_module.gui.input_builder then
|
||||
local k = prefix..key
|
||||
local value = vals[k]
|
||||
|
||||
if(check_module.check_function ~= alerts_api.threshold_check_function) then
|
||||
-- Temporary fix to handle non-thresholds
|
||||
k = "value_" .. k
|
||||
|
||||
if(value ~= nil) then
|
||||
value = tonumber(value[2])
|
||||
end
|
||||
end
|
||||
|
||||
print("</td><td>")
|
||||
|
||||
print(check_module.gui.input_builder(check_module.gui or {}, k, value))
|
||||
|
|
|
|||
|
|
@ -960,6 +960,14 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function alerts_api.checkbox_input_builder(gui_conf, input_id, value)
|
||||
return(string.format([[
|
||||
<input type="checkbox" name="%s" %s/>
|
||||
]], input_id, ternary(value, "checked", "")))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function getEntityDisabledAlertsBitmapKey(ifid, entity, entity_val)
|
||||
return string.format("ntopng.prefs.alerts.ifid_%d.disabled_alerts.__%s__%s", ifid, entity, entity_val)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -244,6 +244,12 @@ local function validateOperator(mode)
|
|||
return validateChoice(modes, mode)
|
||||
end
|
||||
|
||||
local function validateAlertValue(value)
|
||||
return validateEmpty(value) or
|
||||
validateNumber(value) or
|
||||
validateOnOff(value)
|
||||
end
|
||||
|
||||
local function validateHttpMode(mode)
|
||||
local modes = {"responses", "queries"}
|
||||
|
||||
|
|
@ -1517,7 +1523,7 @@ local special_parameters = { --[[Suffix validator]] --[[Value Validator]]
|
|||
|
||||
-- ALERTS (see alert_utils.lua)
|
||||
["op_"] = { validateAlertDescriptor, validateOperator }, -- key: an alert descriptor, value: alert operator
|
||||
["value_"] = { validateAlertDescriptor, validateEmptyOr(validateNumber) }, -- key: an alert descriptor, value: alert value
|
||||
["value_"] = { validateAlertDescriptor, validateAlertValue }, -- key: an alert descriptor, value: alert value
|
||||
["slack_ch_"] = { validateNumber, validateSingleWord }, -- slack channel name
|
||||
|
||||
-- Protocol to categories match
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue