-- -- (C) 2013-18 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path if((dirs.scriptdir ~= nil) and (dirs.scriptdir ~= "")) then package.path = dirs.scriptdir .. "/lua/modules/?.lua;" .. package.path end active_page = "system_stats" require "lua_utils" local page_utils = require("page_utils") local ts_utils = require("ts_utils") local system_scripts = require("system_scripts_utils") local rtt_utils = require("rtt_utils") local template = require("template_utils") require("graph_utils") require("alert_utils") if not isAllowedSystemInterface() then return end sendHTTPContentTypeHeader('text/html') page_utils.print_header() dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") local page = _GET["page"] or "overview" local host = _GET["rtt_host"] local probe = system_scripts.getSystemProbe("rtt") local url = system_scripts.getPageScriptPath(probe) .. "?ifid=" .. getInterfaceId(ifname) if not isEmptyString(host) then url = url .. "&rtt_host=" .. host end system_schemas = system_scripts.getAdditionalTimeseries("rtt") print [[ ]] -- ####################################################### if(page == "overview") then if isAdministrator() then if(_POST["rtt_hosts"] ~= nil) then local rtt_hosts_args = string.split(_POST["rtt_hosts"], ",") or {_POST["rtt_hosts"]} local rtt_hosts = {} -- process arguments for _, host_line in pairs(rtt_hosts_args) do local parts = string.split(host_line, "|") local key = table.remove(parts, 1) local old_host = table.remove(parts, 1) local value = table.concat(parts, "|") rtt_hosts[key] = {old_host, value} end -- Delete changed for host, value in pairs(rtt_hosts) do local old_host = value[1] if((not isEmptyString(old_host)) and (host ~= old_host)) then rtt_utils.removeHost(old_host) end end -- Add new for host, value in pairs(rtt_hosts) do local conf = value[2] rtt_utils.addHost(host, conf) end elseif((_POST["action"] == "delete") and (_POST["rtt_host"] ~= nil)) then rtt_utils.removeHost(_POST["rtt_host"]) end end print( template.gen("modal_confirm_dialog.html", { dialog={ id = "delete_host_dialog", action = "deleteRttHost()", title = i18n("system_stats.delete_rtt_host"), message = i18n("system_stats.delete_rtt_confirm", {host=""}), confirm = i18n("delete"), } }) ) print[[


]] elseif((page == "historical") and (host ~= nil)) then local schema = _GET["ts_schema"] or "monitored_host:rtt" local selected_epoch = _GET["epoch"] or "" local tags = {ifid=getSystemInterfaceId(), host=host} url = url.."&page=historical&rtt_host=" .. host drawGraphs(getSystemInterfaceId(), schema, tags, _GET["zoom"], url, selected_epoch, { timeseries = system_schemas, }) elseif((page == "alerts") and isAdministrator()) then local old_ifname = ifname local influxdb = ts_utils.getQueryDriver() interface.select(getSystemInterfaceId()) _GET["ifid"] = getSystemInterfaceId() _GET["entity"] = alertEntity("pinged_host") _GET["entity_val"] = _GET["rtt_host"] drawAlerts() interface.select(old_ifname) end -- ####################################################### dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")