--
-- (C) 2013-19 - 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 probe = system_scripts.getSystemProbe("redis")
local page = _GET["page"] or "overview"
local url = system_scripts.getPageScriptPath(probe) .. "?ifid=" .. getInterfaceId(ifname)
system_schemas = system_scripts.getAdditionalTimeseries("redis")
print [[
]]
-- #######################################################
if(page == "overview") then
local fa_external = " "
local tags = {ifid=getSystemInterfaceId()}
print("
\n")
print("".. i18n("system_stats.health") .." "..i18n("system_stats.redis.short_desc_redis_health").." \n")
-- No need to determine whether the chart exists for this as memory is always fetched straigth from redis
local storage_chart_available = ts_utils.exists("redis:memory", tags)
print("".. i18n("about.ram_memory") .." "..ternary(storage_chart_available, " ", "")..""..i18n("system_stats.redis.short_desc_redis_ram_memory").." \n")
local keys_chart_available = ts_utils.exists("redis:keys", tags)
print("".. i18n("system_stats.redis.redis_keys") .." "..ternary(keys_chart_available, " ", "")..""..i18n("system_stats.redis.short_desc_redis_keys").." \n")
print[[
]]
print("
\n")
elseif(page == "historical") then
local schema = _GET["ts_schema"] or "redis:memory"
local selected_epoch = _GET["epoch"] or ""
local tags = {ifid = getSystemInterfaceId()}
url = url.."&page=historical"
drawGraphs(getSystemInterfaceId(), schema, tags, _GET["zoom"], url, selected_epoch, {
timeseries = system_schemas,
})
elseif((page == "alerts") and isAdministrator()) then
local old_ifname = ifname
interface.select(getSystemInterfaceId())
_GET["ifid"] = getSystemInterfaceId()
-- _GET["entity"] = alertEntity("redis")
drawAlerts()
interface.select(old_ifname)
end
-- #######################################################
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")