mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 02:16:39 +00:00
Refactors user_scripts into checks (lua)
This commit is contained in:
parent
3c3aa5a25f
commit
76fd315d1b
222 changed files with 980 additions and 981 deletions
|
|
@ -1,85 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-21 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
if(ntop.isPro()) then
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
||||
end
|
||||
|
||||
require "lua_utils"
|
||||
local graph_utils = require "graph_utils"
|
||||
local page_utils = require("page_utils")
|
||||
local os_utils = require "os_utils"
|
||||
local ts_utils = require "ts_utils"
|
||||
|
||||
local user_script = _GET["user_script"]
|
||||
local subdir = _GET["subdir"]
|
||||
|
||||
local ifstats = interface.getStats()
|
||||
local ifId = ifstats.id
|
||||
local schema_prefix = ternary(subdir == "flow", "flow_user_script", "elem_user_script")
|
||||
sendHTTPContentTypeHeader('text/html')
|
||||
|
||||
|
||||
page_utils.set_active_menu_entry(page_utils.menu_entries.scripts_config)
|
||||
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
|
||||
|
||||
if((user_script == nil) or (subdir == nil)) then
|
||||
print("<div class=\"alert alert alert-danger\"><i class='fas fa-exclamation-triangle fa-lg fa-ntopng-warning'></i> user_script/subdir parameter is missing (internal error ?)</div>")
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
return
|
||||
end
|
||||
|
||||
if(not ts_utils.exists(schema_prefix .. ":duration", {ifid = ifId, user_script = user_script, subdir = subdir})) then
|
||||
print("<div class=\"alert alert alert-danger\"><i class='fas fa-exclamation-triangle fa-lg fa-ntopng-warning'></i> No available stats for user script "..user_script.."</div>")
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
return
|
||||
end
|
||||
|
||||
local nav_url = ntop.getHttpPrefix().."/lua/user_script_details.lua?ifid="..interface.getId()
|
||||
local title = "User Script: "..user_script
|
||||
|
||||
page_utils.print_navbar(title, nav_url,
|
||||
{
|
||||
{
|
||||
active = page == "overview" or not page,
|
||||
page_name = "overview",
|
||||
label = "<i class=\"fas fa-home fa-lg\"></i>",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
local schema = _GET["ts_schema"] or "custom:".. schema_prefix ..":vs_total"
|
||||
local selected_epoch = _GET["epoch"] or ""
|
||||
local url = ntop.getHttpPrefix()..'/lua/user_script_details.lua?ifid='..ifId..'&user_script='..user_script..'&page=historical&subdir='..subdir
|
||||
|
||||
local tags = {
|
||||
ifid = ifId,
|
||||
user_script = user_script,
|
||||
subdir = subdir,
|
||||
}
|
||||
|
||||
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, {
|
||||
top_user_script = "top:".. schema_prefix ..":duration",
|
||||
|
||||
timeseries = {
|
||||
{schema = "custom:" .. schema_prefix .. ":total_stats", label = i18n("internals.total_stats", {subdir = firstToUpper(subdir)}), metrics_labels = {i18n("duration")}},
|
||||
{
|
||||
schema = "custom:".. schema_prefix ..":vs_total",
|
||||
label = i18n("internals.script_stats", {script = user_script}),
|
||||
value_formatter = {"NtopUtils.fmillis"},
|
||||
value_formatter2 = {"NtopUtils.fint"},
|
||||
metrics_labels = {
|
||||
i18n("internals.script_duration", {script = user_script}),
|
||||
i18n("internals.total_duration", {subdir = firstToUpper(subdir)}),
|
||||
i18n("internals.script_num_calls", {script = user_script}),
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
Loading…
Add table
Add a link
Reference in a new issue