--
-- (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")
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 url = ntop.getHttpPrefix() .. "/lua/system_stats.lua?ifid=" .. getInterfaceId(ifname)
local info = ntop.getInfo()
system_schemas = system_scripts.getAdditionalTimeseries("system")
print [[
]]
-- #######################################################
if(page == "overview") then
local storage_utils = require("storage_utils")
print("
\n")
local system_rowspan = 1
local system_host_stats = ntop.systemHostStat()
if system_host_stats["cpu_load_percentage"] ~= nil then system_rowspan = system_rowspan + 1 end
if system_host_stats["mem_total"] ~= nil then system_rowspan = system_rowspan + 1 end
if(info["pro.systemid"] and (info["pro.systemid"] ~= "")) then
print("
"..i18n("about.system").."
\n")
end
if system_host_stats["cpu_load_percentage"] ~= nil then
print("
"..i18n("about.cpu_load").."
...
\n")
end
if system_host_stats["mem_total"] ~= nil then
print("
"..i18n("about.ram_memory").."
\n")
end
print("
"..info["product"].."
")
if(info.pid ~= nil) then
print("
PID (Process ID)
"..info.pid.."
\n")
end
if system_host_stats["mem_ntopng_resident"] ~= nil then
print("
"..i18n("about.ram_memory").."
\n")
end
if not ntop.isWindows() then
local storage_info = storage_utils.storageInfo()
local storage_items = {}
local classes = { "primary", "info", "warning", "success", "default" }
local colors = { "blue", "salmon", "seagreen", "cyan", "green", "magenta", "orange", "red", "violet" }
-- interfaces
local col = 1
local num_items = 0
for if_id, if_info in pairs(storage_info.interfaces) do
local item = {
title = getInterfaceName(if_id),
value = if_info.total,
link = ntop.getHttpPrefix() .. "/lua/if_stats.lua?ifid=" .. if_id
}
if num_items < #classes then
item.class = classes[num_items+1]
else
item.style = "background-image: linear-gradient(to bottom, "..colors[col].." 0%, dark"..colors[col].." 100%)"
col = col + 1
if col > #colors then col = 1 end
end
table.insert(storage_items, item)
num_items = num_items + 1
end
-- system
local item = {
title = i18n("system"),
value = storage_info.other,
link = ""
}
item.style = "background-image: linear-gradient(to bottom, grey 0%, darkgrey 100%)"
table.insert(storage_items, item)
print("
\n")
if storage_info.pcap_volume_dev ~= nil then
storage_items = {}
-- interfaces
col = 1
num_items = 0
for if_id, if_info in pairs(storage_info.interfaces) do
local item = {
title = getInterfaceName(if_id),
value = if_info.pcap,
link = ntop.getHttpPrefix() .. "/lua/if_stats.lua?ifid=" .. if_id
}
if num_items < #classes then
item.class = classes[num_items+1]
else
item.style = "background-image: linear-gradient(to bottom, "..colors[col].." 0%, dark"..colors[col].." 100%)"
col = col + 1
if col > #colors then col = 1 end
end
table.insert(storage_items, item)
num_items = num_items + 1
end
-- system
local item = {
title = i18n("system"),
value = storage_info.pcap_other,
link = ""
}
item.style = "background-image: linear-gradient(to bottom, grey 0%, darkgrey 100%)"
table.insert(storage_items, item)
print("