diff --git a/scripts/callbacks/interface/flow.lua b/scripts/callbacks/interface/flow.lua index c2956f7628..615ce7723f 100644 --- a/scripts/callbacks/interface/flow.lua +++ b/scripts/callbacks/interface/flow.lua @@ -208,7 +208,7 @@ local function triggerFlowAlert(now, l4_proto) if do_trace then trace_f(string.format("flow.triggerAlert(type=%s, severity=%s)", - alert_consts.alertTypeRaw(alerted_status.alert_type.alert_id), + alert_consts.alertTypeRaw(alerted_status.alert_type.alert_key), alert_consts.alertSeverityRaw(alerted_status.alert_severity.severity_id))) end @@ -225,7 +225,7 @@ local function triggerFlowAlert(now, l4_proto) end local triggered = flow.triggerAlert(status_id, - alerted_status.alert_type.alert_id, + alerted_status.alert_type.alert_key, alerted_custom_severity or alerted_status.alert_severity.severity_id, now, alerted_status_msg) diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index e4499e085d..7f41bcb3b0 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -2902,7 +2902,7 @@ local lang = { }, ["plugins_overview"] = { ["action_view"] = "Open the user script source in the code editor", - ["alert_id"] = "Alert ID", + ["alert_key"] = "Alert ID", ["alert_key"] = "Alert Key", ["availability"] = "Availability", ["edition_only"] = "%{edition} Only", diff --git a/scripts/locales/it.lua b/scripts/locales/it.lua index b45dbd861f..3826125de9 100644 --- a/scripts/locales/it.lua +++ b/scripts/locales/it.lua @@ -2640,7 +2640,7 @@ local lang = { }, ["plugins_overview"] = { ["action_view"] = "Apri il codice dello user script nell'editor di codice", - ["alert_id"] = "ID dell'Allarme", + ["alert_key"] = "ID dell'Allarme", ["alert_key"] = "Chiave dell'Allarme", ["availability"] = "Disponibilità", ["edition_only"] = "Solo %{edition}", diff --git a/scripts/locales/jp.lua b/scripts/locales/jp.lua index 434c544e99..935abdc530 100644 --- a/scripts/locales/jp.lua +++ b/scripts/locales/jp.lua @@ -2866,7 +2866,7 @@ local lang = { }, ["plugins_overview"] = { ["action_view"] = "コードエディタでユーザースクリプトソースを開く", - ["alert_id"] = "アラートID", + ["alert_key"] = "アラートID", ["alert_key"] = "アラートキー", ["availability"] = "対応ライセンス", ["edition_only"] = "%{edition} のみ", diff --git a/scripts/lua/defs_overview.lua b/scripts/lua/defs_overview.lua index 841d7a6936..0bb29dd516 100644 --- a/scripts/lua/defs_overview.lua +++ b/scripts/lua/defs_overview.lua @@ -28,15 +28,15 @@ print [[
-]] +]] local id_start = 0 local id_end = 63 -for alert_id=id_start,id_end do - local alert_key = alert_consts.getAlertType(alert_id) or "-" +for alert_key=id_start,id_end do + local alert_key = alert_consts.getAlertType(alert_key) or "-" - print[[]] + print[[]] print[[]] end diff --git a/scripts/lua/get_disabled_alerts.lua b/scripts/lua/get_disabled_alerts.lua index 33a0d05ce3..aabadd82ac 100644 --- a/scripts/lua/get_disabled_alerts.lua +++ b/scripts/lua/get_disabled_alerts.lua @@ -79,7 +79,7 @@ for entity_key, disabled_entities in pairsByKeys(entitites) do for entity_value, disabled_alerts in pairsByKeys(disabled_entities) do for _, alert in pairs(alert_consts.alert_types) do - if((alert.alert_id > 0) and ntop.bitmapIsSet(disabled_alerts, alert.alert_id)) then + if((alert.alert_key > 0) and ntop.bitmapIsSet(disabled_alerts, alert.alert_key)) then totalRows = totalRows + 1 local idx = totalRows @@ -91,7 +91,7 @@ for entity_key, disabled_entities in pairsByKeys(entitites) do } if sortColumn == "column_type" then - sort_to_key[idx] = alert.alert_id + sort_to_key[idx] = alert.alert_key else -- default sort_to_key[idx] = data[idx].entity_formatted end @@ -115,10 +115,10 @@ for key in pairsByValues(sort_to_key, sOrder) do res[#res + 1] = { column_entity_formatted = firstToUpper(alert_consts.formatAlertEntity(ifid, alert_consts.alertEntityRaw(item.entity_id), item.entity_value)), - column_type = alert_consts.alertTypeLabel(item.alert.alert_id), + column_type = alert_consts.alertTypeLabel(item.alert.alert_key), column_entity_id = item.entity_id, column_entity_val = item.entity_value, - column_type_id = item.alert.alert_id, + column_type_id = item.alert.alert_key, } end diff --git a/scripts/lua/modules/alert_consts.lua b/scripts/lua/modules/alert_consts.lua index f222155d98..029d2406b8 100644 --- a/scripts/lua/modules/alert_consts.lua +++ b/scripts/lua/modules/alert_consts.lua @@ -242,7 +242,7 @@ function alert_consts.loadDefinition(def_script, mod_fname, script_path) return(false) end - def_script.alert_id = def_id + def_script.alert_key = def_id alert_consts.alert_types[mod_fname] = def_script alerts_by_id[def_id] = mod_fname @@ -253,10 +253,10 @@ end -- ############################################## function alert_consts.alertTypeLabel(v, nohtml) - local alert_id = alert_consts.alertTypeRaw(v) + local alert_key = alert_consts.alertTypeRaw(v) - if(alert_id) then - local type_info = alert_consts.alert_types[alert_id] + if(alert_key) then + local type_info = alert_consts.alert_types[alert_key] local title = i18n(type_info.i18n_title) or type_info.i18n_title if(nohtml) then @@ -276,13 +276,13 @@ function alert_consts.alertType(v) tprint(debug.traceback()) end - return(alert_consts.alert_types[v].alert_id) + return(alert_consts.alert_types[v].alert_key) end -- ############################################## -function alert_consts.getAlertType(alert_id) - return(alerts_by_id[tonumber(alert_id)]) +function alert_consts.getAlertType(alert_key) + return(alerts_by_id[tonumber(alert_key)]) end -- ############################################## @@ -421,7 +421,7 @@ function alert_consts.alertTypeRaw(type_id) type_id = tonumber(type_id) for key, type_info in pairs(alert_consts.alert_types) do - if(type_info.alert_id == type_id) then + if(type_info.alert_key == type_id) then return(key) end end diff --git a/scripts/lua/modules/alert_utils.lua b/scripts/lua/modules/alert_utils.lua index 1c86cb02fd..9755dd8fc5 100644 --- a/scripts/lua/modules/alert_utils.lua +++ b/scripts/lua/modules/alert_utils.lua @@ -43,10 +43,10 @@ end -- ############################################## local function alertTypeDescription(v) - local alert_id = alert_consts.alertTypeRaw(v) + local alert_key = alert_consts.alertTypeRaw(v) - if(alert_id) then - return(alert_consts.alert_types[alert_id].i18n_description) + if(alert_key) then + return(alert_consts.alert_types[alert_key].i18n_description) end end @@ -1164,9 +1164,9 @@ function getCurrentStatus() { return val; } -function deleteAlertById(alert_id) { +function deleteAlertById(alert_key) { var params = {}; - params.id_to_delete = alert_id; + params.id_to_delete = alert_key; params.status = getCurrentStatus(); params.csrf = "]] print(ntop.getRandomCSRFValue()) print[["; @@ -1462,7 +1462,7 @@ function toggleAlert(disable) { datatableForEachRow("#]] print(t["div-id"]) print[[", function(row_id) { var alert_key = $("td:nth(8)", this).html().split("|"); - var alert_id = alert_key[0]; + var alert_key = alert_key[0]; var data = table_data[row_id]; var explorer_url = data["column_explorer"]; @@ -1482,7 +1482,7 @@ function toggleAlert(disable) { datatableAddActionButtonCallback.bind(this)(10, "alert_to_release = "+ row_id +"; $('#release_single_alert').modal('show');", "]] print(i18n("show_alerts.release_alert_action")) print[["); if(]] print(ternary(t["status"] ~= "engaged", "true", "false")) print[[) { - datatableAddDeleteButtonCallback.bind(this)(10, "delete_alert_id ='" + alert_id + "'; $('#delete_alert_dialog').modal('show');", "]] print(i18n('delete')) print[["); + datatableAddDeleteButtonCallback.bind(this)(10, "delete_alert_id ='" + alert_key + "'; $('#delete_alert_dialog').modal('show');", "]] print(i18n('delete')) print[["); } $("form", this).submit(function() { diff --git a/scripts/lua/modules/alerts_api.lua b/scripts/lua/modules/alerts_api.lua index 22e0580dd7..bdd5b18558 100644 --- a/scripts/lua/modules/alerts_api.lua +++ b/scripts/lua/modules/alerts_api.lua @@ -48,7 +48,7 @@ local function get_alert_triggered_key(type_info) tprint(debug.traceback()) end - return(string.format("%d@%s", type_info.alert_type.alert_id, type_info.alert_subtype or "")) + return(string.format("%d@%s", type_info.alert_type.alert_key, type_info.alert_subtype or "")) end -- ############################################## @@ -139,7 +139,7 @@ function alerts_api.store(entity_info, type_info, when) return(false) end - if alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_id) then + if alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_key) then return(false) end @@ -150,7 +150,7 @@ function alerts_api.store(entity_info, type_info, when) local alert_to_store = { ifid = ifid, action = "store", - alert_type = type_info.alert_type.alert_id, + alert_type = type_info.alert_type.alert_key, alert_subtype = subtype, alert_granularity = granularity_sec, alert_entity = entity_info.alert_entity.entity_id, @@ -163,7 +163,7 @@ function alerts_api.store(entity_info, type_info, when) if(entity_info.alert_entity.entity_id == alert_consts.alertEntity("host")) then -- NOTE: for engaged alerts this operation is performed during trigger in C - interface.incTotalHostAlerts(entity_info.alert_entity_val, type_info.alert_type.alert_id) + interface.incTotalHostAlerts(entity_info.alert_entity_val, type_info.alert_type.alert_key) end local alert_json = json.encode(alert_to_store) @@ -229,7 +229,7 @@ end --! @note false is also returned if an existing alert is found and refreshed function alerts_api.trigger(entity_info, type_info, when, cur_alerts) local ifid = interface.getId() - local is_disabled = alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_id) + local is_disabled = alerts_api.isEntityAlertDisabled(ifid, entity_info.alert_entity.entity_id, entity_info.alert_entity_val, type_info.alert_type.alert_key) -- Check if the alerts has been disabled and, in case return, before checking already_triggered, -- so that the alert will be automatically released during the next check. @@ -252,7 +252,7 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts) local subtype = type_info.alert_subtype or "" if(cur_alerts and already_triggered(cur_alerts, type_info.alert_severity.severity_id, - type_info.alert_type.alert_id, granularity_sec, subtype) == true) then + type_info.alert_type.alert_key, granularity_sec, subtype) == true) then return(true) end @@ -267,7 +267,7 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts) local params = { alert_key_name, granularity_id, - type_info.alert_severity.severity_id, type_info.alert_type.alert_id, + type_info.alert_severity.severity_id, type_info.alert_type.alert_key, subtype, alert_json, } @@ -318,7 +318,7 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts) local subtype = type_info.alert_subtype or "" if(cur_alerts and (not already_triggered(cur_alerts, type_info.alert_severity.severity_id, - type_info.alert_type.alert_id, granularity_sec, subtype))) then + type_info.alert_type.alert_key, granularity_sec, subtype))) then return(true) end @@ -333,7 +333,7 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts) end if(type_info.alert_severity == nil) then - alertErrorTraceback(string.format("Missing alert_severity [type=%s]", type_info.alert_type and type_info.alert_type.alert_id or "")) + alertErrorTraceback(string.format("Missing alert_severity [type=%s]", type_info.alert_type and type_info.alert_type.alert_key or "")) return(false) end @@ -1025,7 +1025,7 @@ end local cache_disabled_by_entity_type = {} -- @brief Check if the alert_type is disabled for the given entity -function alerts_api.isEntityAlertDisabled(ifid, entity_type, entity_val, alert_id) +function alerts_api.isEntityAlertDisabled(ifid, entity_type, entity_val, alert_key) local entities_disabled = cache_disabled_by_entity_type[entity_type] if(entities_disabled == nil) then @@ -1036,7 +1036,7 @@ function alerts_api.isEntityAlertDisabled(ifid, entity_type, entity_val, alert_i local bitmap = entities_disabled[entity_val] - if((bitmap ~= nil) and ntop.bitmapIsSet(bitmap, alert_id)) then + if((bitmap ~= nil) and ntop.bitmapIsSet(bitmap, alert_key)) then return(true) end
]] print(i18n("plugins_overview.alert_id")) print[[]] print(i18n("plugins_overview.alert_key")) print[[
]] print(i18n("plugins_overview.alert_key")) print[[]] print(i18n("plugins_overview.alert_key")) print[[
]] print(string.format("%s", alert_id)) print[[
]] print(string.format("%s", alert_key)) print[[]] print(alert_key) print[[