Updated available timeseries

This commit is contained in:
MatteoBiscosi 2022-11-08 17:41:48 +01:00
parent 4624d07289
commit 47cb8dac30
4 changed files with 36 additions and 120 deletions

View file

@ -2317,94 +2317,6 @@ elseif (page == "config") then
elseif(page == "historical") then
graph_utils.drawNewGraphs(nil, interface.getId())
-- host_url = "host="..host_ip
-- host_key = host_ip
-- if(host_vlan and (host_vlan > 0)) then
-- host_url = host_url.."&vlan="..host_vlan
-- host_key = host_key.."@"..host_vlan
-- end
-- local schema = _GET["ts_schema"] or "host:traffic"
-- local selected_epoch = _GET["epoch"] or ""
-- local tags = {
-- ifid = ifId,
-- host = host_key,
-- protocol = _GET["protocol"],
-- category = _GET["category"],
-- l4proto = _GET["l4proto"],
-- dscp_class = _GET["dscp_class"],
-- }
-- local items = split(_GET["ts_query"], ",") or {}
-- for _, concat_tag in pairs(items) do
-- local tag = split(concat_tag, ":")
-- if (tag) and (tag[1] == "dscp_class") then
-- tags["dscp_class"] = tag[2]
-- break
-- end
-- end
-- local url = hostinfo2detailsurl(host, {page = "historical"})
-- local show_graph = true
-- if not host["localhost"] or
-- (host["localhost"] == false or
-- host["is_multicast"] == true) then
-- show_graph = false
-- end
-- local timeseries = table.merge({
-- {schema="host:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
-- {schema="host:score", label=i18n("score"), metrics_labels = { i18n("graphs.cli_score"), i18n("graphs.srv_score")}},
-- {schema="host:active_flows", label=i18n("graphs.active_flows")},
-- {schema="host:total_flows", label=i18n("db_explorer.total_flows")},
-- {schema="host:num_blacklisted_flows", label=i18n("graphs.num_blacklisted_flows")},
-- {schema="host:alerted_flows", label=i18n("graphs.total_alerted_flows")},
-- {schema="host:unreachable_flows", label=i18n("graphs.total_unreachable_flows")},
-- {schema="host:contacts", label=i18n("graphs.active_host_contacts")},
-- {schema="host:total_alerts", label=i18n("details.alerts")},
-- {schema="host:engaged_alerts", label=i18n("show_alerts.engaged_alerts")},
-- {schema="host:host_unreachable_flows", label=i18n("graphs.host_unreachable_flows")},
-- {schema="host:dns_qry_sent_rsp_rcvd", label=i18n("graphs.dns_qry_sent_rsp_rcvd")},
-- {schema="host:dns_qry_rcvd_rsp_sent", label=i18n("graphs.dns_qry_rcvd_rsp_sent")},
-- {schema="host:udp_pkts", label=i18n("graphs.udp_packets")},
-- {schema="host:tcp_rx_stats", label=i18n("graphs.tcp_rx_stats")},
-- {schema="host:tcp_tx_stats", label=i18n("graphs.tcp_tx_stats")},
-- {schema="host:echo_reply_packets", label=i18n("graphs.echo_reply_packets")},
-- {schema="host:echo_packets", label=i18n("graphs.echo_request_packets")},
-- {schema="host:tcp_packets", label=i18n("graphs.tcp_packets")},
-- {schema="host:udp_sent_unicast", label=i18n("graphs.udp_sent_unicast_vs_non_unicast")},
-- {schema="host:dscp", label=i18n("graphs.dscp_classes")},
-- }, graph_utils.getDeviceCommonTimeseries())
-- if(ntop.isPro()) then
-- timeseries = table.merge(timeseries, {
-- {schema="host:contacts_behaviour", label=i18n("graphs.host_contacts_behaviour"), split_directions = true, metrics_labels = {i18n("graphs.contacts"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="host:srv_score_behaviour", label=i18n("graphs.srv_score_behaviour"), split_directions = true, metrics_labels = {i18n("graphs.score"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="host:cli_score_behaviour", label=i18n("graphs.cli_score_behaviour"), split_directions = true, metrics_labels = {i18n("graphs.score"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="host:srv_active_flows_behaviour", label=i18n("graphs.srv_active_flows_behaviour"), split_directions = true, metrics_labels = {i18n("graphs.active_flows"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="host:cli_active_flows_behaviour", label=i18n("graphs.cli_active_flows_behaviour"), split_directions = true, metrics_labels = {i18n("graphs.active_flows"), i18n("graphs.lower_bound"), i18n("graphs.upper_bound")}},
-- {schema="host:srv_score_anomalies", label=i18n("graphs.srv_score_anomalies")},
-- {schema="host:cli_score_anomalies", label=i18n("graphs.cli_score_anomalies")},
-- {schema="host:srv_active_flows_anomalies", label=i18n("graphs.srv_active_flows_anomalies")},
-- {schema="host:cli_active_flows_anomalies", label=i18n("graphs.cli_active_flows_anomalies")},
-- })
-- end
-- graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], url, selected_epoch, {
-- top_protocols = "top:host:ndpi",
-- top_categories = "top:host:ndpi_categories",
-- l4_protocols = "host:l4protos",
-- dscp_classes = "iface:dscp",
-- show_historical = true,
-- tskey = tskey,
-- timeseries = timeseries,
-- device_timeseries_mac = host["mac"],
-- }, show_graph, true)
elseif(page == "traffic_report") then
package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/?.lua;" .. package.path
local traffic_report = require "traffic_report"

View file

@ -1479,38 +1479,6 @@ elseif(page == "sites") then
elseif(page == "historical") then
graph_utils.drawNewGraphs(interface.getId())
-- local schema = _GET["ts_schema"]
-- local selected_epoch = _GET["epoch"] or ""
-- local tags = {
-- ifid = ifid,
-- protocol = _GET["protocol"],
-- category = _GET["category"],
-- l4proto = _GET["l4proto"],
-- dscp_class = _GET["dscp_class"],
-- }
-- url = url.."&page=historical"
-- if(schema == nil) then
-- if(ifstats.has_traffic_directions) then
-- schema = "iface:traffic_rxtx"
-- else
-- schema = "iface:traffic"
-- end
-- end
-- local top_enabled = top_talkers_utils.areTopEnabled(ifid)
-- graph_utils.drawGraphs(ifstats.id, schema, tags, _GET["zoom"], url, selected_epoch, {
-- top_protocols = "top:iface:ndpi",
-- top_categories = "top:iface:ndpi_categories",
-- top_profiles = "top:profile:traffic",
-- top_senders = ternary(top_enabled, "top:local_senders", nil),
-- top_receivers = ternary(top_enabled, "top:local_receivers", nil),
-- l4_protocols = "iface:l4protos",
-- dscp_classes = "iface:dscp",
-- show_historical = not ifstats.isViewed,
-- timeseries = graph_utils.get_default_timeseries()
-- }, nil, true)
elseif(page == "trafficprofiles") then
print("<table class=\"table table-striped table-bordered\">\n")

View file

@ -319,12 +319,23 @@ end
-- #################################
local function add_top_host_timeseries(tags, timeseries)
local host_ts_creation = ntop.getPref("ntopng.prefs.hosts_ts_creation")
local host_ts_enabled = ntop.getCache("ntopng.prefs.host_ndpi_timeseries_creation")
local has_top_protocols = host_ts_enabled == "both" or host_ts_enabled == "per_protocol" or host_ts_enabled ~= "0"
local has_top_categories = host_ts_enabled == "both" or host_ts_enabled == "per_category"
ts_utils.loadSchemas()
-- L4 Protocols
if host_ts_creation == "full" then
local series = ts_utils.listSeries("host:l4protos", table.clone(tags), os.time() - 1800 --[[ 30 min is the default time ]])
if not table.empty(series) then
for _, serie in pairs(series or {}) do
timeseries[#timeseries + 1] = { schema = "top:host:ndpi", group = i18n("graphs.l4_proto"), priority = 2, query = "l4proto:" .. serie.l4proto , label = i18n(serie.l4proto) or serie.l4proto, measure_unit = "bps", scale = 0, timeseries = { bytes_sent = { label = serie.l4proto .. " " .. i18n('graphs.metric_labels.sent'), color = timeseries_info.get_timeseries_color('bytes') }, bytes_rcvd = { label = serie.l4proto .. " " .. i18n('graphs.metric_labels.rcvd'), color = timeseries_info.get_timeseries_color('bytes') }} }
end
end
end
-- Top l7 Protocols
if has_top_protocols then
local series = ts_utils.listSeries("host:ndpi", table.clone(tags), os.time() - 1800 --[[ 30 min is the default time ]])
@ -360,6 +371,28 @@ local function add_top_interface_timeseries(tags, timeseries)
ts_utils.loadSchemas()
-- Top Traffic Profiles
if ntop.isPro() then
local series = ts_utils.listSeries("profile:traffic", table.clone(tags), os.time() - 1800 --[[ 30 min is the default time ]])
if not table.empty(series) then
for _, serie in pairs(series) do
timeseries[#timeseries + 1] = { schema = "top:profile:traffic", group = i18n("graphs.top_profiles"), priority = 2, query = "profile:" .. serie.profile , label = serie.profile, measure_unit = "bps", scale = 0, timeseries = { bytes = { label = serie.profile, color = timeseries_info.get_timeseries_color('bytes') }} }
end
end
end
-- L4 Protocols
if interface_ts_enabled then
local series = ts_utils.listSeries("iface:l4protos", table.clone(tags), os.time() - 1800 --[[ 30 min is the default time ]])
if not table.empty(series) then
for _, serie in pairs(series) do
timeseries[#timeseries + 1] = { schema = "top:iface:l4protos", group = i18n("graphs.l4_proto"), priority = 2, query = "protocol:" .. serie.l4proto , label = i18n(serie.l4proto) or serie.l4proto, measure_unit = "bps", scale = 0, timeseries = { bytes = { label = serie.l4proto, color = timeseries_info.get_timeseries_color('bytes') }} }
end
end
end
-- Top l7 Protocols
if has_top_protocols then
local series = ts_utils.listSeries("iface:ndpi", table.clone(tags), os.time() - 1800 --[[ 30 min is the default time ]])