Skip to content

Commit

Permalink
Added interfaces to exporters/probes page (#8777)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Oct 28, 2024
1 parent 2608f3a commit a90df1e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 10 deletions.
9 changes: 9 additions & 0 deletions http_src/vue/page-exporters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ const map_table_def_columns = (columns) => {
"ntopng_interface": (value, row) => {
return value
},
"exporter_interfaces": (value, row) => {
if (!value) {
return '';
} else {
return formatterUtils.getFormatter("number")(value)
}
},
"time_last_used": (value, row) => {
if (!value)
return '';
Expand Down Expand Up @@ -272,6 +279,8 @@ function columns_sorting(col, r0, r1) {
return sortingFunctions.sortByIP(r0.probe_ip, r1.probe_ip, col.sort);
} else if (col.id == "export_type") {
return sortingFunctions.sortByName(r0.export_type, r1.export_type, col.sort);
} else if (col.id == "exporter_interfaces") {
return sortingFunctions.sortByNumber(r0.exporter_interfaces, r1.exporter_interfaces, col.sort);
} else if (col.id == "time_last_used") {
return sortingFunctions.sortByName(r0.name, r1.name, col.sort);
} else if (col.id == "exported_flows") {
Expand Down
9 changes: 9 additions & 0 deletions http_src/vue/page-probes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ const map_table_def_columns = (columns) => {
return formatterUtils.getFormatter("number")(value)
}
},
"exporters_interfaces": (value, row) => {
if (!value) {
return '';
} else {
return formatterUtils.getFormatter("number")(value)
}
},
"dropped_flows": (value, row) => {
let diff_value = value
if (!first_open.value) {
Expand Down Expand Up @@ -285,6 +292,8 @@ function columns_sorting(col, r0, r1) {
return sortingFunctions.sortByName(r0.ntopng_interface, r1.ntopng_interface, col.sort);
} else if (col.id == "flow_exporters") {
return sortingFunctions.sortByNumber(r0.flow_exporters, r1.flow_exporters, col.sort);
} else if (col.id == "exporters_interfaces") {
return sortingFunctions.sortByNumber(r0.exporters_interfaces, r1.exporters_interfaces, col.sort);
} else if (col.id == "dropped_flows") {
return sortingFunctions.sortByNumber(r0.dropped_flows, r1.dropped_flows, col.sort);
} else if (col.id == "exported_flows") {
Expand Down
2 changes: 1 addition & 1 deletion httpdocs/dist
Submodule dist updated 1 files
+2 −2 ntopng.js
14 changes: 12 additions & 2 deletions httpdocs/tables_config/exporters.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
"text-nowrap"
]
},
{
"id": "exporter_interfaces",
"title_i18n": "if_stats_overview.flow_exporters_interfaces_num",
"data_field": "exporter_interfaces",
"sortable": true,
"class": [
"text-center",
"text-nowrap"
]
},
{
"id": "time_last_used",
"title_i18n": "flow_devices.exporter_time_last_used",
Expand Down Expand Up @@ -86,5 +96,5 @@
"text-nowrap"
]
}
]
}
]
}
10 changes: 10 additions & 0 deletions httpdocs/tables_config/probes.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
"text-nowrap"
]
},
{
"id": "exporters_interfaces",
"title_i18n": "if_stats_overview.flow_exporters_interfaces_num",
"data_field": "exporters_interfaces",
"sortable": true,
"class": [
"text-center",
"text-nowrap"
]
},
{
"id": "exported_flows",
"title_i18n": "nprobe_exported_flows",
Expand Down
1 change: 1 addition & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5106,6 +5106,7 @@ local lang = {
["exported_flows"] = "Exported Flows",
["family"] = "Family",
["flow_exporters_num"] = "Exporters",
["flow_exporters_interfaces_num"] = "Interfaces",
["flows_export_statistics"] = "Flows Export Statistics",
["handled_logs"] = "Detected Events",
["has_traffic_directions"] = "with RX/TX Directions",
Expand Down
24 changes: 17 additions & 7 deletions scripts/lua/rest/v2/get/interface/nprobes/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ for interface_id, probes_list in pairs(ifstats.probes or {}) do
local flow_drops = 0
local exported_flows = 0
local probe_interface
local num_ports = 0
local flow_exporters_num = table.len(probe_info.exporters)

if probe_info["probe.mode"] == "packet_collection" then
if probe_info["probe.mode"] == "packet_collection" then
flow_exporters_num = 1 -- Packet exporter
flow_drops = probe_info["drops.elk_flow_drops"] + probe_info["drops.flow_collection_udp_socket_drops"] +
probe_info["drops.export_queue_full"] + probe_info["drops.too_many_flows"] + probe_info["drops.flow_collection_drops"] +
probe_info["drops.sflow_pkt_sample_drops"] + probe_info["drops.elk_flow_drops"]
probe_info["drops.export_queue_full"] + probe_info["drops.too_many_flows"] +
probe_info["drops.flow_collection_drops"] +
probe_info["drops.sflow_pkt_sample_drops"] + probe_info["drops.elk_flow_drops"]
exported_flows = probe_info["zmq.num_flow_exports"]
probe_interface = probe_info["remote.name"]
local ports_table = interface.getFlowDeviceInfo(probe_info["probe.uuid_num"], true)
for _, ports in pairs(ports_table or {}) do
num_ports = num_ports + table.len(ports)
end
else
for _, values in pairs(probe_info.exporters) do
local ports_table = interface.getFlowDeviceInfo(values.unique_source_id, true)
for _, ports in pairs(ports_table or {}) do
num_ports = num_ports + table.len(ports)
end
flow_drops = flow_drops + values.num_drops
exported_flows = exported_flows + values.num_netflow_flows + values.num_sflow_flows
end
Expand All @@ -65,18 +75,18 @@ for interface_id, probes_list in pairs(ifstats.probes or {}) do
probe_edition = probe_info["probe.probe_edition"],
probe_license = probe_info["probe.probe_license"] or i18n("if_stats_overview.no_license"),
probe_maintenance = probe_info["probe.probe_maintenance"] or i18n("if_stats_overview.expired_maintenance"),
probe_last_update = (probe_info["probe.last_update"] or 0),
probe_last_update = (probe_info["probe.last_update"] or 0),
flow_exporters = flow_exporters_num,
exporters_interfaces = num_ports,
dropped_flows = flow_drops,
captured_packets = (probe_info["packets.total"] or 0),
dropped_packets = (probe_info["packets.drops"] or 0),
captured_packets = (probe_info["packets.total"] or 0),
dropped_packets = (probe_info["packets.drops"] or 0),
exported_flows = exported_flows,
ntopng_interface = if_names[tostring(interface_id)],
timeseries_enabled = timeseries_enabled,
ifid = interface_id,
}
end

end

rest_utils.answer(rc, res)

0 comments on commit a90df1e

Please sign in to comment.