Updated timeseries pages

This commit is contained in:
MatteoBiscosi 2022-11-07 18:30:43 +01:00
parent f2644d1413
commit 2daaedb5ed
9 changed files with 122 additions and 123 deletions

View file

@ -138,43 +138,8 @@ if isEmptyString(page) or page == "historical" then
print(" "..i18n("as_details.as_timeseries_enable_message",{url = ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=on_disk_ts",icon_flask="<i class=\"fas fa-flask\"></i>"})..'</div>')
else
local schema = _GET["ts_schema"] or default_schema
local selected_epoch = _GET["epoch"] or ""
local asn_url = ntop.getHttpPrefix()..'/lua/as_details.lua?ifid='..ifId..'&asn='..asn..'&page=historical'
local tags = {
ifid = ifId,
asn = asn,
protocol = _GET["protocol"],
}
local all_timeseries = {
{schema="asn:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
{schema="asn:rtt", label=i18n("graphs.num_ms_rtt"), nedge_exclude=1},
{schema="asn:traffic_sent", label=i18n("graphs.traffic_sent"), nedge_exclude=1},
{schema="asn:traffic_rcvd", label=i18n("graphs.traffic_rcvd"), nedge_exclude=1},
{schema="asn:score", label=i18n("score"), split_directions = true},
{schema="asn:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1},
{schema="asn:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1},
{schema="asn:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1},
{schema="asn:tcp_keep_alive", label=i18n("graphs.tcp_packets_keep_alive"), nedge_exclude=1},
}
if ntop.isPro() then
local pro_timeseries = {
{schema="asn:score_anomalies", label=i18n("graphs.iface_score_anomalies")},
{schema="asn: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="asn:traffic_anomalies", label=i18n("graphs.iface_traffic_anomalies")},
{schema="asn:traffic_rx_behavior_v2", label=i18n("graphs.iface_traffic_rx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = asn_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="asn:traffic_tx_behavior_v2", label=i18n("graphs.iface_traffic_tx_behavior"), split_directions = true, first_timeseries_only = true, time_elapsed = asn_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)
end
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], asn_url, selected_epoch, {
top_protocols = "top:asn:ndpi",
timeseries = all_timeseries,
})
-- top_protocols = "top:asn:ndpi"
graph_utils.drawNewGraphs(tonumber(asn), interface.getId())
end
print[[

View file

@ -57,21 +57,7 @@ local title = i18n("country_details.country") .. ": "..country
Selectively render information pages
--]]
if page == "historical" then
local schema = _GET["ts_schema"] or "country:traffic"
local selected_epoch = _GET["epoch"] or ""
local url = ntop.getHttpPrefix()..'/lua/country_details.lua?ifid='..ifId..'&country='..country..'&page=historical'
local tags = {
ifid = ifId,
country = country,
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, {
timeseries = {
{schema="country:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
{schema="country:score", label=i18n("score"), split_directions = true},
}
})
graph_utils.drawNewGraphs(country, interface.getId())
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")

View file

@ -91,6 +91,8 @@ local community_timeseries = {
{ schema = "iface:tcp_synack", label = i18n("graphs.tcp_synack_packets"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.packets'), timeseries = { packets = { label = i18n('graphs.tcp_syn_packets'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
{ schema = "iface:tcp_finack", label = i18n("graphs.tcp_finack_packets"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.packets'), timeseries = { packets = { label = i18n('graphs.tcp_finack_packets'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
{ schema = "iface:tcp_rst", label = i18n("graphs.tcp_rst_packets"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.packets'), timeseries = { packets = { label = i18n('graphs.tcp_rst_packets'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
-- host_details.lua (HOST): --
{ schema = "host:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
{ schema = "host:score", label = i18n("graphs.score"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.score'), timeseries = { cli_score = { label = i18n('graphs.cli_score'), color = timeseries_info.get_timeseries_color('cli_score') }, srv_score = { label = i18n('graphs.srv_score'), color = timeseries_info.get_timeseries_color('srv_score') }}},
{ schema = "host:active_flows", label = i18n("graphs.active_flows"), priority = 0, measure_unit = "fps", scale = 0, timeseries = { flows_as_client = { label = i18n('graphs.flows_as_client'), color = timeseries_info.get_timeseries_color('flows') }, flows_as_server = { label = i18n('graphs.flows_as_server'), color = timeseries_info.get_timeseries_color('flows') }}},
@ -114,18 +116,47 @@ local community_timeseries = {
{ schema = "host:udp_sent_unicast", label = i18n("graphs.udp_sent_unicast_vs_non_unicast"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent_unicast = { label = i18n('graphs.metric_labels.sent_uni'), color = timeseries_info.get_timeseries_color('bytes') }, bytes_sent_non_uni = { label = i18n('graphs.metric_labels.sent_non_uni'), color = timeseries_info.get_timeseries_color('bytes') }}},
{ schema = "host:dscp", label = i18n("graphs.dscp_classes"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes') }, bytes_rcvd = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes') }}},
{ schema = "host:host_tcp_unidirectional_flows", label = i18n("graphs.unidirectional_tcp_flows"), priority = 0, measure_unit = "fps",scale = 0, timeseries = { flows_as_client = { label = i18n('graphs.flows_as_client'), color = timeseries_info.get_timeseries_color('flows') }, flows_as_server = { label = i18n('graphs.flows_as_server'), color = timeseries_info.get_timeseries_color('flows') }}},
{ schema = "mac:traffic", label = i18n("traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
-- mac_details.lua (MAC): --
{ schema = "mac:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
-- network_details.lua (SUBNET): --
{ schema = "subnet:traffic", label = i18n("traffic"), measure_unit = "bps", scale = 0, timeseries = { bytes_egress = { label = i18n('graphs.metrics_suffixes.egress') }, bytes_ingress = { label = i18n('graphs.metrics_suffixes.ingress') }, bytes_inner = { label = i18n('graphs.metrics_suffixes.inner') }}, default_visible = true },
{ schema = "subnet:traffic", label = i18n("graphs.traffic"), measure_unit = "bps", scale = 0, timeseries = { bytes_egress = { label = i18n('graphs.metrics_suffixes.egress') }, bytes_ingress = { label = i18n('graphs.metrics_suffixes.ingress') }, bytes_inner = { label = i18n('graphs.metrics_suffixes.inner') }}, default_visible = true },
{ schema = "subnet:broadcast_traffic", label = i18n("broadcast_traffic"), measure_unit = "bps", scale = 0, timeseries = { bytes_egress = { label = i18n('graphs.metrics_suffixes.egress') }, bytes_ingress = { label = i18n('graphs.metrics_suffixes.ingress') }, bytes_inner = { label = i18n('graphs.metrics_suffixes.inner') }} },
{ schema = "subnet:engaged_alerts", label = i18n("show_alerts.engaged_alerts"), measure_unit = "number", scale = 0, timeseries = { alerts = { label = i18n('graphs.engaged_alerts') }} },
{ schema = "subnet:score", label = i18n("score"), measure_unit = "number", scale = 0, timeseries = { score = { label = i18n('score') }, scoreAsClient = { label = i18n('score_as_client') }, scoreAsServer = { label = i18n('score_as_server') } }},
{ schema = "subnet:tcp_retransmissions", label = i18n("graphs.tcp_packets_retr"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_out_of_order", label = i18n("graphs.tcp_packets_ooo"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_lost", label = i18n("graphs.tcp_packets_lost"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_keep_alive", label = i18n("graphs.tcp_packets_keep_alive"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_out_of_order", label = i18n("graphs.tcp_packets_ooo"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_lost", label = i18n("graphs.tcp_packets_lost"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
{ schema = "subnet:tcp_keep_alive", label = i18n("graphs.tcp_packets_keep_alive"), measure_unit = "number", scale = 0, timeseries = { packets_ingress = { label = i18n('if_stats_overview.ingress_packets') }, packets_egress = { label = i18n('if_stats_overview.egress_packets') }, packets_inner = { label = 'Inner Packets' } }},
-- as_details.lua (ASN): --
{ schema = "asn:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
{ schema = "asn:rtt", label = i18n("graphs.rtt"), priority = 0, measure_unit = "ms", scale = 0, timeseries = { millis_rtt = { label = i18n('graphs.metric_labels.rtt'), color = timeseries_info.get_timeseries_color('default') } }, nedge_exclude = true },
{ schema = "asn:traffic_sent", label = i18n("graphs.traffic_sent"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') } }, nedge_exclude = true },
{ schema = "asn:traffic_rcvd", label = i18n("graphs.traffic_rcvd"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') } }, nedge_exclude = true },
{ schema = "asn:score", label = i18n("graphs.score"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.score'), timeseries = { score = { label = i18n('graphs.metric_labels.score'), color = timeseries_info.get_timeseries_color('score') }, cli_score = { label = i18n('graphs.metric_labels.cli_score'), color = timeseries_info.get_timeseries_color('cli_score') }, srv_score = { label = i18n('graphs.metric_labels.srv_score'), color = timeseries_info.get_timeseries_color('srv_score') } }},
{ schema = "asn:tcp_retransmissions", label = i18n("graphs.tcp_packets_retr"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.packets'), timeseries = { packets_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('packets') }, packets_rcvd = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
{ schema = "asn:tcp_keep_alive", label = i18n("graphs.tcp_packets_keep_alive"), priority = 0, measure_unit = "number", scale = i18n('graphs.metric_labels.packets'), timeseries = { packets_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('packets') }, packets_rcvd = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
{ schema = "asn:tcp_out_of_order", label = i18n("graphs.tcp_packets_ooo"), priority = 0, measure_unit = "number", scale = i18n('graphs.tcp_packets_ooo'), timeseries = { packets_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('packets') }, packets_rcvd = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
{ schema = "asn:tcp_lost", label = i18n("graphs.tcp_packets_lost"), priority = 0, measure_unit = "number", scale = i18n('graphs.tcp_packets_lost'), timeseries = { packets_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('packets') }, packets_rcvd = { label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('packets') }}, nedge_exclude = true },
-- country_details.lua (Country): --
{ schema = "country:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_egress = { label = i18n('graphs.metrics_suffixes.egress') }, bytes_ingress = { label = i18n('graphs.metrics_suffixes.ingress') }, bytes_inner = { label = i18n('graphs.metrics_suffixes.inner') }}, default_visible = true },
{ schema = "country:score", label = i18n("score"), priority = 0, measure_unit = "number", scale = 0, timeseries = { score = { label = i18n('score') }, scoreAsClient = { label = i18n('score_as_client') }, scoreAsServer = { label = i18n('score_as_server') } }},
-- os_details.lua (Operative System): --
{ schema = "os:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_egress = { label = i18n('graphs.metrics_suffixes.egress') }, bytes_ingress = { label = i18n('graphs.metrics_suffixes.ingress') }}, default_visible = true },
-- vlan_details.lua (VLAN): --
{ schema = "vlan:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
{ schema = "vlan:score", label = i18n("score"), priority = 0, measure_unit = "number", scale = 0, timeseries = { score = { label = i18n('score') }, scoreAsClient = { label = i18n('score_as_client') }, scoreAsServer = { label = i18n('score_as_server') } }},
-- pool_details.lua (Host Pool): --
{ schema = "host_pool:traffic", label = i18n("graphs.traffic"), priority = 0, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes_sent') }, bytes_rcvd = { invert_direction = true, label = i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes_rcvd') }}, default_visible = true },
{ schema = "host_pool:blocked_flows", label = i18n("graphs.blocked_flows"), priority = 0, measure_unit = "number", scale = 0, timeseries = { num_flows = { label = i18n('graphs.metric_labels.num_flows'), color = timeseries_info.get_timeseries_color('default') } } },
{ schema = "host_pool:hosts", label = i18n("graphs.active_hosts"), priority = 0, measure_unit = "number", scale = 0, timeseries = { num_hosts = { label = i18n('graphs.metric_labels.num_hosts'), color = timeseries_info.get_timeseries_color('default') } } },
{ schema = "host_pool:devices", label = i18n("graphs.active_devices"), priority = 0, measure_unit = "number", scale = 0, timeseries = { num_devices = { label = i18n('graphs.metric_labels.num_devices'), color = timeseries_info.get_timeseries_color('default') } } },
}
-- #################################
@ -253,22 +284,4 @@ end
-- #################################
function timeseries_info.get_interface_timeseries(tags)
return timeseries_info.retrieve_specific_timeseries(tags, 'iface')
end
-- #################################
function timeseries_info.get_host_timeseries(tags)
return timeseries_info.retrieve_specific_timeseries(tags, 'host')
end
-- #################################
function timeseries_info.get_mac_timeseries(tags)
return timeseries_info.retrieve_specific_timeseries(tags, 'mac')
end
-- #################################
return timeseries_info

View file

@ -40,7 +40,7 @@ end
--[[
Create Menu Bar with buttons
--]]
local nav_url = ntop.getHttpPrefix().."/lua/os_details.lua?country="..OS
local nav_url = ntop.getHttpPrefix().."/lua/os_details.lua?os="..OS
local title = i18n("os_details.os") .. ": "..OS
page_utils.print_navbar(title, nav_url,
@ -57,20 +57,7 @@ local title = i18n("os_details.os") .. ": "..OS
Selectively render information pages
--]]
if page == "historical" then
local schema = _GET["ts_schema"] or "os:traffic"
local selected_epoch = _GET["epoch"] or ""
local url = ntop.getHttpPrefix()..'/lua/os_details.lua?ifid='..ifId..'&os='..OS..'&page=historical'
local tags = {
ifid = ifId,
os = OS,
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, {
timeseries = {
{schema="os:traffic", label=i18n("traffic"), split_directions = true},
}
})
graph_utils.drawNewGraphs(tonumber(os), interface.getId())
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")

View file

@ -125,25 +125,8 @@ elseif page == "historical" then
print("<div class=\"alert alert alert-danger\"><i class='fas fa-exclamation-triangle fa-lg fa-ntopng-warning'></i> "..i18n("pool_details.no_available_data_for_host_pool_message",{pool_name=pool_name}))
print(" "..i18n("pool_details.host_pool_timeseries_enable_message",{url=ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=on_disk_ts",icon_flask="<i class=\"fas fa-flask\"></i>"})..'</div>')
else
local schema = _GET["ts_schema"] or "host_pool:traffic"
local selected_epoch = _GET["epoch"] or ""
local url = getPageUrl(base_url, page_params)
local tags = {
ifid = ifId,
pool = pool_id,
protocol = _GET["protocol"],
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, {
top_protocols = "top:host_pool:ndpi",
timeseries = {
{schema="host_pool:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
{schema="host_pool:blocked_flows", label=i18n("graphs.blocked_flows")},
{schema="host_pool:hosts", label=i18n("graphs.active_hosts")},
{schema="host_pool:devices", label=i18n("graphs.active_devices")},
},
})
--top_protocols = "top:host_pool:ndpi",
graph_utils.drawNewGraphs(tonumber(pool_id), interface.getId())
end
end

View file

@ -81,14 +81,8 @@ else
vlan = vlan_id,
protocol = _GET["protocol"],
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], vlan_url, selected_epoch, {
top_protocols = "top:vlan:ndpi",
timeseries = {
{schema="vlan:traffic", label=i18n("traffic")},
{schema="vlan:score", label=i18n("score"), split_directions = true},
},
})
-- top_protocols = "top:vlan:ndpi",
graph_utils.drawNewGraphs(tonumber(vlan_id), interface.getId())
elseif (page == "config") then
if(not isAdministrator()) then
return