function drawAlertSourceSettings(entity_type, alert_source, delete_button_msg, delete_confirm_msg, page_name, page_params, alt_name, show_entity, options) options = options or {} local tab = _GET["tab"] or "min" local ts_utils = require("ts_utils") local ifid = interface.getId() local entity_value = alert_source local subdir = entity_type if interface.isPcapDumpInterface() then if entity_type == "interface" then tab = "flows" else return end else local function printTab(tab, content, sel_tab) if(tab == sel_tab) then print("\t\n") end print('') end -- !isPcapDumpInterface if((tab == "flows") and (entity_type == "interface")) then local flow_callbacks_utils = require "flow_callbacks_utils" flow_callbacks_utils.print_callbacks_config() else local available_modules = user_scripts.load(interface.getId(), user_scripts.script_types.traffic_element, entity_type) local no_modules_available = table.len(available_modules.modules) == 0 if((_POST["to_delete"] ~= nil) and (_POST["SaveAlerts"] == nil)) then if _POST["to_delete"] == "local" then user_scripts.deleteSpecificConfiguration(subdir, available_modules, tab, entity_value) else user_scripts.deleteGlobalConfiguration(subdir, available_modules, tab, options.remote_host) end elseif(not table.empty(_POST)) then user_scripts.handlePOST(subdir, available_modules, tab, entity_value, options.remote_host) end local label if entity_type == "host" then if options.remote_host then label = i18n("remote_hosts") else label = i18n("alerts_thresholds_config.active_local_hosts") end else label = firstToUpper(entity_type) .. "s" end print [[

]] if(tab == "min") then print[[]] end print[[]] print('\n') if no_modules_available then if areAlertsEnabled() then print[[]] else print[[]] end else local benchmarks = user_scripts.getLastBenchmark(ifid, entity_type) for mod_k, user_script in pairsByKeys(available_modules.modules, asc) do local key = user_script.key local gui_conf = user_script.gui local show_input = true if user_script.granularity then -- check if the check is performed and thus has to -- be configured at this granularity show_input = false for _, gran in pairs(user_script.granularity) do if gran == tab then show_input = true break end end end if(user_script.local_only and options.remote_host) then show_input = false end if not gui_conf or not show_input then goto next_module end local url = '' if(user_script.plugin.edition == "community") then local path = string.sub(user_script.source_path, string.len(ntop.getDirs().scriptdir)+1) url = '' end print("\n") ::next_module:: end end print [[
]] print(i18n("alerts_thresholds_config.threshold_type")) print[[]] print(i18n("chart")) print[[]] print(i18n("alerts_thresholds_config.thresholds_single_source", {source=firstToUpper(entity_type),alt_name=ternary(alt_name ~= nil, alt_name, alert_source)})) print[[]] print(i18n("alerts_thresholds_config.common_thresholds_local_sources", {source=label})) print[[]] print(i18n("flow_callbacks.callback_latest_run")) print[[
]] print(i18n("flow_callbacks.no_callbacks_available")) print[[.
]] print(i18n("flow_callbacks.no_callbacks_available_disabled_alerts", {url = ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=alerts"})) print[[.
".. (i18n(gui_conf.i18n_title) or gui_conf.i18n_title) .. " " .. url .."
") print("".. (i18n(gui_conf.i18n_description) or gui_conf.i18n_description) .."\n") if(tab == "min") then print("
") if ts_utils.exists("elem_user_script:duration", {ifid=ifid, user_script=mod_k, subdir=entity_type}) then print('') end end for _, prefix in pairs({"", "global_"}) do if user_script.gui.input_builder then local k = prefix..key local is_global = (prefix == "global_") local conf print("") if is_global then conf = user_scripts.getGlobalConfiguration(user_script, tab, options.remote_host) else conf = user_scripts.getConfiguration(user_script, tab, entity_value, options.remote_host) end if(conf ~= nil) then -- TODO remove after implementing the new gui local value = ternary(user_script.gui.post_handler == user_scripts.checkbox_post_handler, conf.enabled, conf.script_conf) print(user_script.gui.input_builder(user_script.gui or {}, k, value)) end end end print("\n") local script_benchmark = benchmarks[mod_k] if script_benchmark and (script_benchmark[tab] or script_benchmark["all"]) then local hook = ternary(script_benchmark[tab], tab, "all") if script_benchmark[hook]["tot_elapsed"] then if script_benchmark[hook]["tot_num_calls"] > 1 then print(i18n("flow_callbacks.callback_function_duration_fmt_long", {num_calls = format_utils.formatValue(script_benchmark[hook]["tot_num_calls"]), time = format_utils.secondsToTime(script_benchmark[hook]["tot_elapsed"]), speed = format_utils.formatValue(round(script_benchmark[hook]["avg_speed"], 0))})) else print(i18n("flow_callbacks.callback_function_duration_fmt_short", {time = format_utils.secondsToTime(script_benchmark[hook]["tot_elapsed"])})) end end end print("
]] if not no_modules_available then print[[
]] end print("
" .. i18n("alerts_thresholds_config.notes") .. ":
") print[[ ]] end end