--
-- (C) 2013-24 - 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"
require "ntop_utils"
require "check_redis_prefs"
local page_utils = require("page_utils")
if not isAllowedSystemInterface() then return end
sendHTTPContentTypeHeader('text/html')
page_utils.print_header_and_set_active_menu_entry(
page_utils.menu_entries.redis_status)
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
local page = _GET["page"] or "overview"
local url = ntop.getHttpPrefix() .. "/lua/monitor/redis_monitor.lua?"
local timeseries_available = areSystemTimeseriesEnabled()
page_utils.print_navbar(i18n("system_stats.redis.redis_monitor"), url, {
{
active = page == "overview" or not page,
page_name = "overview",
label = ""
}, {
active = page == "stats",
page_name = "stats",
label = ""
}, {
hidden = not timeseries_available,
active = page == "historical",
page_name = "historical",
label = ""
}
})
-- #######################################################
if (page == "overview") then
local fa_external = ""
local tags = {ifid = getSystemInterfaceId()}
print("
\n")
if not ntop.isWindows() then
-- NOTE: on Windows, some stats are missing from script.getRedisStatus()
print("" .. i18n("system_stats.health") ..
" " ..
i18n("system_stats.redis.short_desc_redis_health") ..
" | | Loading... |
\n")
end
print("" .. i18n("about.ram_memory") ..
" " ..
i18n("system_stats.redis.short_desc_redis_ram_memory") ..
" | ")
print("")
print(ternary(timeseries_available, "",
""))
print(
" | Loading... |
\n")
if not ntop.isWindows() then
print("" ..
i18n("system_stats.redis.redis_keys") .. " " ..
i18n("system_stats.redis.short_desc_redis_keys") ..
" | ")
print("")
print(ternary(timeseries_available, "",
""))
print(
" | Loading... |
\n")
end
print [[
]]
print("
\n")
elseif (page == "stats") then
local json = require "dkjson"
local template_utils = require("template_utils")
local context = {
ifid = interface.getId(),
csrf = ntop.getRandomCSRFValue(),
timeseries_available = timeseries_available
}
template_utils.render("pages/vue_page.template", {
vue_page_name = "PageRedisStats",
page_context = json.encode(context)
})
elseif (page == "historical" and timeseries_available) then
local graph_utils = require("graph_utils")
graph_utils.drawNewGraphs({ifid = -1, command = _GET["redis_command"]})
end
-- #######################################################
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")