--
-- (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 ts_utils = require("ts_utils")
local script_manager = require("script_manager")
local graph_utils = require("graph_utils")
local influxdb_export_api = require "influxdb_export_api"
sendHTTPContentTypeHeader('text/html')
local charts_available = script_manager.systemTimeseriesEnabled()
local page = _GET["page"] or "overview"
local url = script_manager.getMonitorUrl("influxdb_monitor.lua") .. "?ifid=" .. interface.getId()
page_utils.set_active_menu_entry(page_utils.menu_entries.influxdb_status)
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
page_utils.print_navbar("InfluxDB", url,
{
{
active = page == "overview" or not page,
page_name = "overview",
label = "",
},
{
hidden = not charts_available,
active = page == "historical",
page_name = "historical",
label = "",
},
}
)
-- #######################################################
if(page == "overview") then
local fa_external = ""
local tags = {ifid=getSystemInterfaceId()}
print("
\n")
print("".. i18n("system_stats.health") .." "..i18n("system_stats.short_desc_influxdb_health").." | | Loading... |
\n")
print("".. i18n("traffic_recording.storage_utilization") .." "..i18n("system_stats.short_desc_influxdb_storage_utilization").." | ")
print("")
print(ternary(charts_available, "", ""))
print(" | Loading... |
\n")
print("".. i18n("about.ram_memory") .." "..i18n("system_stats.short_desc_influxdb_ram_memory").." | ")
print("")
print(ternary(charts_available, "", ""))
print(" | Loading... |
\n")
if(influxdb_export_api.isInfluxdbChecksEnabled() == true) then
local stats = influxdb_export_api.getExportStats()
print("".. i18n("system_stats.exports") .." "..i18n("system_stats.short_desc_influxdb_exports").." | ")
print("")
print(ternary(charts_available, "", ""))
print(" | ".. formatValue(stats.exports) .." |
\n")
print("".. i18n("system_stats.exported_points") .." "..i18n("system_stats.short_desc_influxdb_exported_points").." | ")
print("")
print(ternary(charts_available, "", ""))
print(" | ".. formatValue(stats.points_exported) .." |
\n")
end
print("".. i18n("system_stats.series_cardinality") .." "..i18n("system_stats.short_desc_influxdb_cardinality").." | | Loading... |
\n")
print[[
]]
print("
\n")
print(""..i18n("notes").."")
print("")
print("- "..i18n("system_stats.influxdb_note_docs", {url = "https://www.ntop.org/guides/ntopng/basic_concepts/timeseries.html#influxdb-driver"}).."
")
print("
")
elseif(page == "historical" and charts_available) then
local schema = _GET["ts_schema"] or "influxdb:storage_size"
local selected_epoch = _GET["epoch"] or ""
local tags = {ifid = getSystemInterfaceId()}
url = url.."&page=historical"
graph_utils.drawGraphs(getSystemInterfaceId(), schema, tags, _GET["zoom"], url, selected_epoch, {
timeseries = {
{schema="influxdb:storage_size", label=i18n("traffic_recording.storage_utilization")},
{schema="influxdb:memory_size", label=i18n("about.ram_memory")},
{schema="influxdb:write_successes", label=i18n("system_stats.write_througput")},
{schema="influxdb:exports", label=i18n("system_stats.exports_label"),
value_formatter = {"NtopUtils.export_rate", "NtopUtils.exports_format"},
metrics_labels = {i18n("system_stats.exports_label")}},
{schema="influxdb:exported_points", label=i18n("system_stats.exported_points")},
{schema="influxdb:dropped_points", label=i18n("system_stats.dropped_points")},
{schema="custom:infludb_exported_vs_dropped_points", label=i18n("system_stats.exported_vs_dropped_points"),
custom_schema = {
bases = {"influxdb:exported_points", "influxdb:dropped_points"},
types = {"area", "line"}, axis = {1,2},
},
metrics_labels = {i18n("system_stats.exported_points"), i18n("system_stats.dropped_points")},
},
{schema="influxdb:rtt", label=i18n("graphs.num_ms_rtt")},
}})
end
-- #######################################################
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")