Skip to content

Commit

Permalink
Added asset inventory logging preference
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Oct 21, 2024
1 parent 745a559 commit c6776f8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion include/Prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Prefs {
#ifdef NTOPNG_PRO
ndpi_bitmap* modbus_allowed_function_codes;
u_int modbus_too_many_exceptions;
bool netbox_enabled, asset_inventory_enabled, snmp_trap_enabled;
bool netbox_enabled, asset_inventory_enabled, snmp_trap_enabled, enable_asset_inventory_log;
#endif
ServiceAcceptance behaviour_analysis_learning_status_during_learning,
behaviour_analysis_learning_status_post_learning;
Expand Down Expand Up @@ -282,6 +282,10 @@ class Prefs {
inline void dont_change_user() { change_user = false; };
inline bool is_sql_log_enabled() { return (enable_sql_log); };
inline bool is_access_log_enabled() { return (enable_access_log); };
#ifdef NTOPNG_PRO
inline bool is_asset_inventory_log_enabled() { return (enable_asset_inventory_log); };
inline void do_asset_inventory_log(bool state = false) { enable_asset_inventory_log = state; };
#endif
inline void do_enable_access_log(bool state = true) {
enable_access_log = state;
};
Expand Down
1 change: 1 addition & 0 deletions include/ntop_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@
#define CONST_PREFS_ENABLE_NETWORK_DISCOVERY \
NTOPNG_PREFS_PREFIX ".network_discovery"
#define CONST_PREFS_ENABLE_ACCESS_LOG NTOPNG_PREFS_PREFIX ".enable_access_log"
#define CONST_PREFS_ENABLE_ASSET_INVENTORY_LOG NTOPNG_PREFS_PREFIX ".enable_asset_inventory_log"
#define CONST_PREFS_ENABLE_SQL_LOG NTOPNG_PREFS_PREFIX ".enable_sql_log"
#define CONST_TOP_TALKERS_ENABLED NTOPNG_PREFS_PREFIX ".host_top_sites_creation"
#define CONST_SITES_COLLECTION_ENABLED NTOPNG_PREFS_PREFIX ".sites_collection"
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7071,6 +7071,8 @@ local lang = {
["toggle_host_pools_log_description"] = "Toggle the creation of logs related to host pools. Logs include associations and disassociations of hosts to their host pools.",
["toggle_host_pools_log_title"] = "Enable Host Pool Events Log",
["toggle_host_tskey_description"] = "The key to use for data and timeseries dump for hosts in the local broadcast domain. In a DHCP network it's usually desiderable to choose 'MAC Address'.",
["toggle_asset_inventory_log_title"] = "Enable Asset Inventory Log",
["toggle_asset_inventory_log_description"] = "Enable the log of Asset Inventory, when a change in the assets of the network is detected.",
["toggle_host_tskey_title"] = "Local Broadcast Domain Hosts Identifier",
["toggle_http_auth"] = "Toggle HTTP Authentication",
["toggle_http_auth_descr"] = "Toggle gui authentication via an HTTP authenticator.",
Expand Down
8 changes: 8 additions & 0 deletions scripts/lua/admin/prefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,14 @@ if auth.has_capability(auth.capabilities.preferences) then
pref = "enable_host_pools_log"
})

if ntop.isEnterpriseL() then
prefsToggleButton(subpage_active, {
field = "toggle_asset_inventory_log",
default = "0",
pref = "enable_asset_inventory_log"
})
end

print(
'<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px" disabled="disabled">' ..
i18n("save") .. '</button></th></tr>')
Expand Down
1 change: 1 addition & 0 deletions scripts/lua/modules/http_lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,7 @@ local known_parameters = {
["toggle_sites_collection"] = validateBool,
["toggle_dns_cache"] = validateBool,
["toggle_http_enable_access_log"] = validateBool,
["toggle_asset_inventory_log"] = validateBool,
["toggle_captive_portal"] = validateBool,
["toggle_mdns_repeater"] = validateBool,
["toggle_informative_captive_portal"] = validateBool,
Expand Down
5 changes: 4 additions & 1 deletion scripts/lua/modules/prefs_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ local menu_subpages = {{
description = i18n("prefs.toggle_host_pools_log_description", {
product = info["product"]
})
},
toggle_asset_inventory_log = {
title = i18n("prefs.toggle_asset_inventory_log_title"),
description = i18n("prefs.toggle_asset_inventory_log_description")
}

}
}, {
id = "message_broker",
Expand Down
2 changes: 2 additions & 0 deletions src/Prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Prefs::Prefs(Ntop *_ntop) {
scripts_dir = strdup(CONST_DEFAULT_SCRIPTS_DIR);
callbacks_dir = strdup(CONST_DEFAULT_CALLBACKS_DIR);
#ifdef NTOPNG_PRO
enable_asset_inventory_log = false;
asset_inventory_enabled = CONST_DEFAULT_ASSET_INVENTORY_ENABLED;
netbox_enabled = CONST_DEFAULT_NETBOX_ENABLED;
snmp_trap_enabled = CONST_DEFAULT_SNMP_TRAP_ENABLED;
Expand Down Expand Up @@ -910,6 +911,7 @@ void Prefs::reloadPrefsFromRedis() {
getDefaultPrefsValue(CONST_MAX_AGGREGATED_FLOWS_UPPERBOUND, 10000);
max_aggregated_flows_traffic_upperbound =
getDefaultPrefsValue(CONST_MAX_AGGREGATED_FLOWS_TRAFFIC_UPPERBOUND, 1);
enable_asset_inventory_log = getDefaultBoolPrefsValue(CONST_PREFS_ENABLE_ASSET_INVENTORY_LOG, false);
#endif
// alert preferences
enable_access_log = getDefaultBoolPrefsValue(CONST_PREFS_ENABLE_ACCESS_LOG, false);
Expand Down

0 comments on commit c6776f8

Please sign in to comment.