Restyle timeseries: restyle consts.lua; add new network_details page; restyle page-stats props

This commit is contained in:
uccidibuti 2022-11-07 16:23:40 +01:00
parent 1d2bd8de20
commit 9c004f1ab7
11 changed files with 142 additions and 83 deletions

View file

@ -89,62 +89,64 @@ page_utils.print_navbar(title, nav_url,
Selectively render information pages
--]]
if page == "historical" then
local schema = _GET["ts_schema"] or "subnet:traffic"
local selected_epoch = _GET["epoch"] or ""
local url = ntop.getHttpPrefix()..'/lua/network_details.lua?ifid='..ifId..'&network='..network_id..'&page=historical'
graph_utils.drawNewGraphs(network_name, interface.getId())
-- local schema = _GET["ts_schema"] or "subnet:traffic"
-- local selected_epoch = _GET["epoch"] or ""
-- local url = ntop.getHttpPrefix()..'/lua/network_details.lua?ifid='..ifId..'&network='..network_id..'&page=historical'
local tags = {
ifid = ifId,
subnet = network_name,
subnet_2 = subnet2,
}
local timeseries = {}
local all_timeseries = {
{schema="subnet:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
{schema="subnet:broadcast_traffic", label=i18n("broadcast_traffic")},
{schema="subnet:engaged_alerts", label=i18n("show_alerts.engaged_alerts")},
{schema="subnet:score", label=i18n("score"), split_directions = true},
{schema="subnet:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1},
{schema="subnet:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1},
{schema="subnet:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1},
{schema="subnet:tcp_keep_alive", label=i18n("graphs.tcp_packets_keep_alive"), nedge_exclude=1},
}
-- local tags = {
-- ifid = ifId,
-- subnet = network_name,
-- subnet_2 = subnet2,
-- }
-- local timeseries = {}
-- local all_timeseries = {
-- {schema="subnet:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
-- {schema="subnet:broadcast_traffic", label=i18n("broadcast_traffic")},
-- {schema="subnet:engaged_alerts", label=i18n("show_alerts.engaged_alerts")},
-- {schema="subnet:score", label=i18n("score"), split_directions = true},
-- {schema="subnet:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1},
-- {schema="subnet:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1},
-- {schema="subnet:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1},
-- {schema="subnet:tcp_keep_alive", label=i18n("graphs.tcp_packets_keep_alive"), nedge_exclude=1},
-- }
if ntop.isPro() then
local pro_timeseries = {
{schema="subnet:score_anomalies", label=i18n("graphs.iface_score_anomalies")},
{schema="subnet:score_behavior", label=i18n("graphs.iface_score_behavior"), split_directions = true, first_timeseries_only = true, metrics_labels = {i18n("graphs.score"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
{schema="subnet:traffic_anomalies", label=i18n("graphs.iface_traffic_anomalies")},
{schema="subnet:traffic_rx_behavior_v2", label=i18n("graphs.iface_traffic_rx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq, value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_rcvd"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
{schema="subnet:traffic_tx_behavior_v2", label=i18n("graphs.iface_traffic_tx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq,value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_sent"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
}
all_timeseries = table.merge(all_timeseries, pro_timeseries)
-- if ntop.isPro() then
-- local pro_timeseries = {
-- {schema="subnet:score_anomalies", label=i18n("graphs.iface_score_anomalies")},
-- {schema="subnet:score_behavior", label=i18n("graphs.iface_score_behavior"), split_directions = true, first_timeseries_only = true, metrics_labels = {i18n("graphs.score"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="subnet:traffic_anomalies", label=i18n("graphs.iface_traffic_anomalies")},
-- {schema="subnet:traffic_rx_behavior_v2", label=i18n("graphs.iface_traffic_rx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq, value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_rcvd"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="subnet:traffic_tx_behavior_v2", label=i18n("graphs.iface_traffic_tx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = network_behavior_update_freq,value_formatter = {"NtopUtils.fbits_from_bytes", "NtopUtils.bytesToSize"}, metrics_labels = {i18n("graphs.traffic_sent"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- }
-- all_timeseries = table.merge(all_timeseries, pro_timeseries)
network.select(tonumber(network_id))
local net_stats = network.getNetworkStats() or {}
-- network.select(tonumber(network_id))
-- local net_stats = network.getNetworkStats() or {}
local net_matrix_ts = {}
-- local net_matrix_ts = {}
for second_subnet, _ in pairs(net_stats["intranet_traffic"]) do
local label_1 = getFullLocalNetworkName(network_name)
local label_2 = getFullLocalNetworkName(second_subnet)
-- for second_subnet, _ in pairs(net_stats["intranet_traffic"]) do
-- local label_1 = getFullLocalNetworkName(network_name)
-- local label_2 = getFullLocalNetworkName(second_subnet)
net_matrix_ts[#net_matrix_ts + 1] = {
schema="subnet:intranet_traffic_min",
label= i18n("graphs.intranet_traffic", { net_1 = label_1, net_2 = label_2 }),
split_directions = true --[[ split RX and TX directions ]],
extra_params = {
subnet_2 = second_subnet,
}
}
end
-- net_matrix_ts[#net_matrix_ts + 1] = {
-- schema="subnet:intranet_traffic_min",
-- label= i18n("graphs.intranet_traffic", { net_1 = label_1, net_2 = label_2 }),
-- split_directions = true --[[ split RX and TX directions ]],
-- extra_params = {
-- subnet_2 = second_subnet,
-- }
-- }
-- end
all_timeseries = table.merge(all_timeseries, net_matrix_ts)
end
-- all_timeseries = table.merge(all_timeseries, net_matrix_ts)
-- end
timeseries["timeseries"] = all_timeseries
-- timeseries["timeseries"] = all_timeseries
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, timeseries)
-- graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, timeseries)
elseif (page == "config") then
if(not isAdministrator()) then
return