mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 06:59:33 +00:00
Augment host labels with Network Configuration info
This commit is contained in:
parent
1f9e505575
commit
2e69dce74c
4 changed files with 29 additions and 8 deletions
|
|
@ -527,7 +527,7 @@ class Host : public GenericHashEntry,
|
|||
void lua_get_listening_ports(lua_State* vm);
|
||||
void lua_get_labels(lua_State* vm) const;
|
||||
|
||||
inline u_int64_t getLabels() const { return labels_bitmap; }
|
||||
u_int64_t getLabels();
|
||||
void setLabels(u_int64_t bitmap);
|
||||
|
||||
void resolveHostName();
|
||||
|
|
|
|||
|
|
@ -502,6 +502,7 @@ local lang = {
|
|||
["merge_wazuh_info_success"] = "Wazuh asset information successfully merged.",
|
||||
["netbios_name"] = "NetBIOS",
|
||||
["http_servers"] = "HTTP(S) Servers",
|
||||
["network_gateway"] = "Network Gateway",
|
||||
["ntp_server"] = "NTP Server",
|
||||
["ntp_servers"] = "NTP Servers",
|
||||
["offline"] = "Offline",
|
||||
|
|
@ -521,7 +522,6 @@ local lang = {
|
|||
["switch_port"] = "Switch Port",
|
||||
["smtp_server"] = "SMTP Server",
|
||||
["smtp_servers"] = "SMTP Servers",
|
||||
["network_gateway"] = "Network Gateway",
|
||||
["ssh_server"] = "SSH Server",
|
||||
["ssid"] = "<a class='ntopng-external-link' href='https://en.wikipedia.org/wiki/Service_set_(802.11_network)'>SSID</A>",
|
||||
["tcp_fingerprint"] = "TCP Fingerprint",
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ local label_badge_utils = {}
|
|||
-- Built-in host labels (bits 0-31).
|
||||
-- Keep in sync with include/ntop_defines.h
|
||||
label_badge_utils.builtin_labels = {
|
||||
[0] = { i18n = "checks.dns_server" }, -- HOST_LABEL_DNS_SERVER
|
||||
[1] = { i18n = "checks.ntp_server" }, -- HOST_LABEL_NTP_SERVER
|
||||
[2] = { i18n = "checks.dhcp_server" }, -- HOST_LABEL_DHCP_SERVER
|
||||
[3] = { i18n = "checks.smtp_server" }, -- HOST_LABEL_SMTP_SERVER
|
||||
[4] = { i18n = "checks.network_gateway" }, -- HOST_LABEL_NETWORK_GATEWAY
|
||||
[0] = { i18n = "asset_details.dns_server" }, -- HOST_LABEL_DNS_SERVER
|
||||
[1] = { i18n = "asset_details.ntp_server" }, -- HOST_LABEL_NTP_SERVER
|
||||
[2] = { i18n = "asset_details.dhcp_server" }, -- HOST_LABEL_DHCP_SERVER
|
||||
[3] = { i18n = "asset_details.smtp_server" }, -- HOST_LABEL_SMTP_SERVER
|
||||
[4] = { i18n = "asset_details.network_gateway" }, -- HOST_LABEL_NETWORK_GATEWAY
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
|
@ -31,11 +31,16 @@ local function get_default_labels_table()
|
|||
|
||||
-- Bits 0-31: ntop built-in labels (read-only, auto-assigned by ntopng)
|
||||
for id, entry in pairs(label_badge_utils.builtin_labels) do
|
||||
local name = i18n(entry.i18n)
|
||||
if name == nil then
|
||||
traceError(TRACE_WARNING, TRACE_CONSOLE,
|
||||
"label_badge_utils: i18n key not found: " .. entry.i18n)
|
||||
end
|
||||
labels[id] = {
|
||||
id = id,
|
||||
color = "#0d6efd",
|
||||
description = "",
|
||||
name = i18n(entry.i18n),
|
||||
name = name,
|
||||
reserved = "true"
|
||||
}
|
||||
end
|
||||
|
|
|
|||
16
src/Host.cpp
16
src/Host.cpp
|
|
@ -1159,6 +1159,22 @@ char* Host::get_host_label(char* const buf, ssize_t buf_len) {
|
|||
|
||||
/* ***************************************** */
|
||||
|
||||
u_int64_t Host::getLabels() {
|
||||
u_int64_t bm = labels_bitmap;
|
||||
Prefs* p = ntop->getPrefs();
|
||||
u_int16_t vlan = vlan_id;
|
||||
|
||||
if (p->isDNSServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_DNS_SERVER);
|
||||
if (p->isNTPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_NTP_SERVER);
|
||||
if (p->isDHCPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_DHCP_SERVER);
|
||||
if (p->isSMTPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_SMTP_SERVER);
|
||||
if (p->isGateway(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_NETWORK_GATEWAY);
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
||||
/* ***************************************** */
|
||||
|
||||
void Host::setLabels(u_int64_t bitmap) {
|
||||
labels_bitmap = bitmap;
|
||||
iface->setHostLabels(this, bitmap);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue