-- -- (C) 2013-22 - 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 require "lua_utils" local page_utils = require("page_utils") local script_manager = require("script_manager") local internals_utils = require "internals_utils" local cpu_utils = require("cpu_utils") local ts_utils = require "ts_utils" local graph_utils = require("graph_utils") local ts_creation = script_manager.systemTimeseriesEnabled() if not isAllowedSystemInterface() then return end sendHTTPContentTypeHeader('text/html') page_utils.set_active_menu_entry(page_utils.menu_entries.system_status) dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") local page = _GET["page"] or "overview" local url = ntop.getHttpPrefix() .. "/lua/system_stats.lua?ifid="..interface.getId() local title = i18n("system") local info = ntop.getInfo() page_utils.print_navbar(title, url, { { active = page == "overview" or not page, page_name = "overview", label = "", }, { hidden = not ts_creation, active = page == "historical", page_name = "historical", label = "", }, { active = page == "internals", page_name = "internals", label = "", }, } ) -- ####################################################### if(page == "overview") then local storage_utils = require("storage_utils") print("
") print("\n") local system_rowspan = 1 local ntopng_rowspan = 20 local system_host_stats = cpu_utils.systemHostStats() local has_system = false if system_host_stats["cpu_load"] ~= nil then system_rowspan = system_rowspan + 1; has_system = true end if system_host_stats["mem_total"] ~= nil then system_rowspan = system_rowspan + 1; has_system = true end if system_host_stats["cpu_states"] and system_host_stats["cpu_states"]["iowait"] then system_rowspan = system_rowspan + 1; has_system = true end if has_system then print("\n") end if system_host_stats["cpu_load"] ~= nil then local chart_available = ts_utils.exists("system:cpu_load", {ifid = getSystemInterfaceId()}) print("\n") end if system_host_stats["cpu_states"] and system_host_stats["cpu_states"]["iowait"] then local chart_available = ts_utils.exists("system:cpu_states", {ifid = getSystemInterfaceId()}) local iowait = i18n("about.iowait") .. ": " .. round(formatValue(system_host_stats["cpu_states"]["iowait"]), 2) .. "%" local active = i18n("about.active") .. ": " .. round(formatValue(system_host_stats["cpu_states"]["user"] + system_host_stats["cpu_states"]["system"] + system_host_stats["cpu_states"]["nice"] + system_host_stats["cpu_states"]["irq"] + system_host_stats["cpu_states"]["softirq"] + system_host_stats["cpu_states"]["guest"] + system_host_stats["cpu_states"]["guest_nice"]), 2) .. "%" local idle = i18n("about.idle") .. ": " .. round(formatValue(system_host_stats["cpu_states"]["idle"] + system_host_stats["cpu_states"]["steal"]), 2) .. "%" print("\n") end if system_host_stats["mem_total"] ~= nil then local ram_used = system_host_stats["mem_used"] local ram_used_ratio = i18n("ram_used") .. ": " .. tostring(round((ram_used / system_host_stats["mem_total"]) * 100 * 100) / 100) .. "%"; local ram_available = i18n("ram_available") .. ": " .. bytesToSize((system_host_stats["mem_total"] - ram_used) * 1024) local ram_total = i18n("ram_total") .. ": " .. bytesToSize(system_host_stats["mem_total"] * 1024) print("\n") end print("") if(info.pid ~= nil) then print("\n") end if system_host_stats["mem_ntopng_resident"] ~= nil then local chart_available = ts_utils.exists("process:resident_memory", {ifid = getSystemInterfaceId()}) print("\n") end if areAlertsEnabled() then local chart_available = ts_utils.exists("process:num_alerts", {ifid = getSystemInterfaceId()}) print("\n") end print("") print("") if not info.oem then print("\n") end print("
"..i18n("about.system").."
"..i18n("about.cpu_load").." "..ternary(chart_available, "", "").."" .. round(system_host_stats["cpu_load"], 2) .. "
"..i18n("about.cpu_states").." "..ternary(chart_available, "", "").."" .. iowait .. " / " .. active .. " / " .. idle .. "
"..i18n("about.ram_memory").."" .. ram_used_ratio .. " / " .. ram_available .. " / " .. ram_total .. "
"..info["product"].."
PID (Process ID)"..info.pid.."
"..i18n("about.ram_memory").." "..ternary(chart_available, "", "").."" .. i18n("ram_used") .. ": " .. bytesToSize(system_host_stats["mem_ntopng_resident"] * 1024) .. "
"..i18n("details.alerts").." "..ternary(chart_available, "", "")..""..i18n("about.alert_queries")..": " .. round(system_host_stats["alerts_queries"]) .. " / "..i18n("about.alerts_stored")..": " .. round(system_host_stats["written_alerts"]) .. " / "..i18n("about.alerts_dropped")..": " .. round(system_host_stats["dropped_alerts"]) .. "
"..i18n("traffic_recording.storage_utilization").."") print("
") print("
"..i18n("traffic_recording.storage_utilization_pcap").."") print("
") print("
"..i18n("about.last_log").."
\n") for i=0,32 do msg = ntop.listIndexCache("ntopng.trace", i) if(msg ~= nil) then local text = noHtml(msg) -- encapsule the ERROR or WARNING string in a badge -- so the log are more visible if text:find("ERROR") then text = text:gsub("(ERROR)(:)", "%1") elseif text:find("WARNING") then text = text:gsub("(WARNING)(:)", "%1") end print(text) print("
") end end print("
") print("
") print [[ ]] elseif(page == "historical" and ts_creation) then local sys_stats = ntop.systemHostStat() local selected_epoch = _GET["epoch"] or "" local tags = {ifid = getSystemInterfaceId()} local skip_cpu_load = (sys_stats.cpu_load == nil) local schema = _GET["ts_schema"] or ternary(skip_cpu_load, "process:num_alerts", "system:cpu_load") url = url.."&page=historical" graph_utils.drawGraphs(getSystemInterfaceId(), schema, tags, _GET["zoom"], url, selected_epoch, { timeseries = { { schema = "system:cpu_load", label=i18n("about.cpu_load"), metrics_labels = {i18n("about.cpu_load")}, value_formatter = {"NtopUtils.ffloat"}, skip = skip_cpu_load, }, { schema="system:cpu_states", label=i18n("about.cpu_states"), metrics_labels = {i18n("about.iowait"), i18n("about.active"), i18n("about.idle")}, value_formatter = {"NtopUtils.fpercent"} }, { schema="process:resident_memory", label=i18n("graphs.process_memory") }, { schema="process:num_alerts", label=i18n("graphs.process_alerts"), metrics_labels = {i18n("about.alerts_stored"), i18n("about.alert_queries"), i18n("about.alerts_dropped")}, }, { schema="iface:engaged_alerts", label=i18n("show_alerts.engaged_alerts"), metrics_labels = { i18n("show_alerts.engaged_alerts") }, skip=hasAllowedNetworksSet() }, { schema="iface:dropped_alerts", label=i18n("show_alerts.dropped_alerts"), metrics_labels = { i18n("show_alerts.dropped_alerts") }, skip=hasAllowedNetworksSet() }, } }) elseif page == "internals" then internals_utils.printInternals(getSystemInterfaceId(), false --[[ hash tables ]], true --[[ periodic activities ]], true --[[ checks]], true --[[ queues --]]) end -- ####################################################### dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")