Add links in host custom column

Implements #2860
This commit is contained in:
emanuele-f 2019-09-23 10:31:26 +02:00
parent 856ae1a7a5
commit e2a58a8c3d
2 changed files with 23 additions and 12 deletions

View file

@ -17,14 +17,14 @@ custom_column_utils.available_custom_columns = {
{ "traffic_sent", i18n("flows_page.total_bytes_sent"), "bytes.sent", bytesToSize, "right" },
{ "traffic_rcvd", i18n("flows_page.total_bytes_rcvd"), "bytes.rcvd", bytesToSize, "right" },
{ "traffic_unknown", i18n("flows_page.total_bytes_unknown"), "bytes.ndpi.unknown", bytesToSize, "right" },
{ "num_flows_as_client", i18n("flows_page.flows_as_client"), "active_flows.as_client", format_utils.formatValue, "center" },
{ "num_flows_as_server", i18n("flows_page.flows_as_server"), "active_flows.as_server", format_utils.formatValue, "center" },
{ "total_num_anomalous_flows_as_client", i18n("total_outgoing_anomalous_flows"), "anomalous_flows.as_client", format_utils.formatValue, "center" },
{ "total_num_anomalous_flows_as_server", i18n("total_incoming_anomalous_flows"), "anomalous_flows.as_server", format_utils.formatValue, "center" },
{ "num_flows_as_client", i18n("flows_page.flows_as_client"), "active_flows.as_client", format_utils.formatValue, "center", "page=flows" },
{ "num_flows_as_server", i18n("flows_page.flows_as_server"), "active_flows.as_server", format_utils.formatValue, "center", "page=flows" },
{ "total_num_anomalous_flows_as_client", i18n("total_outgoing_anomalous_flows"), "anomalous_flows.as_client", format_utils.formatValue, "center", "page=flows&flow_status=misbehaving" },
{ "total_num_anomalous_flows_as_server", i18n("total_incoming_anomalous_flows"), "anomalous_flows.as_server", format_utils.formatValue, "center", "page=flows&flow_status=misbehaving" },
{ "total_num_unreachable_flows_as_client", i18n("total_outgoing_unreachable_flows"), "unreachable_flows.as_client", format_utils.formatValue, "center" },
{ "total_num_unreachable_flows_as_server", i18n("total_incoming_unreachable_flows"), "unreachable_flows.as_server", format_utils.formatValue, "center" },
{ "alerts", i18n("show_alerts.engaged_alerts"), "num_alerts", format_utils.formatValue, "center" },
{ "total_alerts", i18n("alerts_dashboard.total_alerts"), "total_alerts", format_utils.formatValue, "center" },
{ "alerts", i18n("show_alerts.engaged_alerts"), "num_alerts", format_utils.formatValue, "center", "page=alerts" },
{ "total_alerts", i18n("alerts_dashboard.total_alerts"), "total_alerts", format_utils.formatValue, "center", "page=alerts" },
}
local available_custom_columns = custom_column_utils.available_custom_columns
@ -34,18 +34,28 @@ function custom_column_utils.hostStatsToColumnValue(host_stats, column, formatte
for _, c in ipairs(available_custom_columns) do
if c[1] == column then
local k = c[3]
local val = nil
if formatted then
local val = host_stats[c[3]]
val = host_stats[c[3]]
if val ~= nil and val > 0 then
return c[4](val)
val = c[4](val)
else
return "0"
val = "0"
end
if((c[6] ~= nil) and (tonumber(val) ~= 0)) then
local url = ntop.getHttpPrefix() .. "/lua/host_details.lua?host=" ..
hostinfo2hostkey({host = host_stats["ip"], vlan = host_stats["vlan"]}) .. "&" .. c[6]
val = '<a href="' .. url .. '">' .. val .. '</a>'
end
else
return host_stats[c[3]]
val = host_stats[c[3]]
end
return(val)
end
end
end