Skip to content

Commit

Permalink
Added ntopng assets inventory pref (#8513)
Browse files Browse the repository at this point in the history
* Fixed #8492, removed unused formatting function in lua

* Fixed host pool doc #8487

* Fixed ebroken menu entry highlight #8498

* Fixed geomap REST location: #8486

* Removed log

* Added german #8488

* Implemented ticket: #7648

* Added new endpoints to python API

* Implemented flow exporter table: #8490

* Added table config for flow exporter

* Added ntopng assets inventory pref
  • Loading branch information
DGabri authored Jul 10, 2024
1 parent 51ee7ef commit 01faee3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/Prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Prefs {
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO) && defined(HAVE_MYSQL)
char *ch_user; /* In case of ch cloud, 2 users are needed,
one for mysql and one for ch */
bool ntopng_assets_inventory_enabled;
#endif
#if !defined(WIN32) && !defined(__APPLE__)
int flows_syslog_facility;
Expand Down
5 changes: 5 additions & 0 deletions include/ntop_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@
NTOPNG_PREFS_PREFIX ".toggle_netbox"
#define CONST_DEFAULT_NETBOX_ENABLED \
0 // disabled by default

#define CONST_PREFS_NTOPNG_ASSETS_INVENTORY_ENABLED \
NTOPNG_PREFS_PREFIX ".toggle_ntopng_assets_inventory"
#define CONST_DEFAULT_NTOPNG_ASSETS_INVENTORY_ENABLED \
0 // disabled by default

#define CONST_PREFS_NETBOX_ENABLED \
NTOPNG_PREFS_PREFIX ".toggle_netbox"
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7003,6 +7003,8 @@ local lang = {
["toggle_ndpi_timeseries_creation_title"] = "Layer-7 Applications",
["toggle_netbox_description"] = "Toggle NetBox integration",
["toggle_netbox_title"] = "NetBox",
["toggle_ntopng_assets_inventory_title"] = "ntopng Assets Inventory",
["toggle_ntopng_assets_inventory_description"] = "ntopng Assets Inventory",
["toggle_network_discovery_debug_description"] = "Toggle the debugging of Network Discovery. Enabling this will print extra information out to the ntopng logs.",
["toggle_network_discovery_debug_title"] = "Network Discovery Debug",
["toggle_network_discovery_description"] = "Toggle the periodic discovery of network devices using multiple techniques that include ARP scan, MDNS and SSDP.<p><b><b>NOTE</b>:</b> discovery can be <u>only</u> enabled on physical interfaces (i.e. no ZMQ) where we can send/receive traffic to the network (i.e. read-only interfaces such as those connected to port mirrors won't work). ",
Expand Down
9 changes: 8 additions & 1 deletion scripts/lua/admin/prefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2220,8 +2220,15 @@ if auth.has_capability(auth.capabilities.preferences) then
end
end

-- tprint(ntop.getPref("ntopng.prefs.toggle_netbox") .. " " .. tostring(showNetboxConfiguration))
-- ntop asset inventory
prefsToggleButton(subpage_active, {
field = "toggle_ntopng_assets_inventory",
default = "0",
pref = "toggle_ntopng_assets_inventory",
to_switch = {}
})

-- Netbox toggle
prefsToggleButton(subpage_active, {
field = "toggle_netbox",
default = "0",
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 @@ -2166,6 +2166,7 @@ local known_parameters = {
["rtt_threshold"] = validateNumber,
["bandwidth_threshold"] = validateNumber,
["toggle_netbox"] = validateBool,
["toggle_ntopng_assets_inventory"] = validateBool,
["netbox_activation_url"] = validateSingleWord,
["netbox_default_site"] = validateSingleWord,
["netbox_personal_access_token"] = validateSingleWord,
Expand Down
4 changes: 4 additions & 0 deletions scripts/lua/modules/prefs_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ local menu_subpages = {{
pro_only = false,
hidden = not ntop.isEnterpriseXL(),
entries = {
toggle_ntopng_assets_inventory = {
title = i18n("prefs.toggle_ntopng_assets_inventory_title"),
description = i18n("prefs.toggle_ntopng_assets_inventory_description")
},
toggle_netbox = {
title = i18n("prefs.toggle_netbox_title"),
description = i18n("prefs.toggle_netbox_description")
Expand Down
7 changes: 7 additions & 0 deletions scripts/lua/modules/prefs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,13 @@ function isNetBoxEnabled()
return (ntop.getPref("ntopng.prefs.toggle_netbox") == "1")
end

function isNtopngAssetsInventoryEnabled()
if not ntop.isEnterpriseXL() then
return false
end
return (ntop.getPref("ntopng.prefs.toggle_ntopng_assets_inventory") == "1")
end

function getNetBoxURL()
if not ntop.isEnterpriseXL() or not ntop.getPref("ntopng.prefs.toggle_netbox") == "1" then
return ""
Expand Down
5 changes: 5 additions & 0 deletions src/Prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Prefs::Prefs(Ntop *_ntop) {
mysql_host = mysql_dbname = mysql_user = mysql_pw = NULL;
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO) && defined(HAVE_MYSQL)
ch_user = NULL;
ntopng_assets_inventory_enabled = true;
#endif
mysql_port = CONST_DEFAULT_MYSQL_PORT;
clickhouse_tcp_port = CONST_DEFAULT_CLICKHOUSE_TCP_PORT;
Expand Down Expand Up @@ -1040,6 +1041,10 @@ void Prefs::reloadPrefsFromRedis() {
snmp_trap_enabled = getDefaultPrefsValue(CONST_PREFS_SNMP_TRAP_ENABLED,
CONST_DEFAULT_SNMP_TRAP_ENABLED);
#endif
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO) && defined(HAVE_MYSQL)
ntopng_assets_inventory_enabled = getDefaultPrefsValue(CONST_PREFS_NTOPNG_ASSETS_INVENTORY_ENABLED,
CONST_DEFAULT_NTOPNG_ASSETS_INVENTORY_ENABLED);
#endif

#ifdef PREFS_RELOAD_DEBUG
ntop->getTrace()->traceEvent(TRACE_NORMAL,
Expand Down

0 comments on commit 01faee3

Please sign in to comment.