diff --git a/src/LuaEngineNtop.cpp b/src/LuaEngineNtop.cpp index 6d3bd12aaf7f..959ad73a71d5 100644 --- a/src/LuaEngineNtop.cpp +++ b/src/LuaEngineNtop.cpp @@ -7776,6 +7776,36 @@ static int ntop_toggle_new_delete_trace(lua_State *vm) { return(ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_OK)); } +/* **************************************************************** */ + +static int ntop_get_license_limits(lua_State *vm) { + lua_newtable(vm); + + lua_newtable(vm); + lua_push_uint32_table_entry(vm, "num_flow_exporters", ntop->getNumFlowExporters()); + lua_push_uint32_table_entry(vm, "num_flow_exporter_interfaces", ntop->getNumFlowExportersInterfaces()); +#if 0 + lua_push_uint32_table_entry(vm, "num_host_pools", ); + lua_push_uint32_table_entry(vm, "num_pool_members", ); + lua_push_uint32_table_entry(vm, "num_profiles", ); +#endif + lua_pushstring(vm, "current"); + lua_insert(vm, -2); + lua_settable(vm, -3); + + lua_newtable(vm); + lua_push_uint32_table_entry(vm, "num_flow_exporters", get_max_num_flow_exporters()); + lua_push_uint32_table_entry(vm, "num_flow_exporter_interfaces", get_max_num_flow_exporters_interfaces()); + lua_push_uint32_table_entry(vm, "num_host_pools", MAX_NUM_HOST_POOLS); + lua_push_uint32_table_entry(vm, "num_pool_members", MAX_NUM_POOL_MEMBERS); + lua_push_uint32_table_entry(vm, "num_profiles", MAX_NUM_PROFILES); + lua_pushstring(vm, "max"); + lua_insert(vm, -2); + lua_settable(vm, -3); + + return(ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_OK)); +} + #if defined(NTOPNG_PRO) /* **************************************************************** */ @@ -8316,6 +8346,9 @@ static luaL_Reg _ntop_reg[] = { /* Debug */ { "toggleNewDeleteTrace", ntop_toggle_new_delete_trace }, + /* License */ + { "getLicenseLimits", ntop_get_license_limits }, + #if defined(NTOPNG_PRO) /* TODO: move to message_broker engine */ { "publish", m_broker_publish }, diff --git a/src/ParserInterface.cpp b/src/ParserInterface.cpp index 487988d2a145..4bee29d627b7 100644 --- a/src/ParserInterface.cpp +++ b/src/ParserInterface.cpp @@ -86,13 +86,6 @@ bool ParserInterface::processFlow(ParsedFlow *zflow) { if ((zflow->vlan_id == 0) && ntop->getPrefs()->do_simulate_vlans()) zflow->vlan_id = rand() % SIMULATE_VLANS_MAX_VALUE; -#ifdef TRACE_EXPORTERS - ntop->getTrace()->traceEvent(TRACE_NORMAL, - "[unique_source_id: %u];device_ip: %u][probe_ip: %u][iface: %u->%u]", - unique_source_id, zflow->exporter_device_ip, - zflow->nprobe_ip, zflow->inIndex, zflow->outIndex); -#endif - #ifdef NTOPNG_PRO if(unique_source_id != 0) { if (!flow_interfaces_stats->checkExporters(unique_source_id, @@ -101,11 +94,18 @@ bool ParserInterface::processFlow(ParsedFlow *zflow) { static bool shown = false; if(!shown) { + ntop->getTrace()->traceEvent(TRACE_NORMAL, "Flow dropped due to limits to the license"); + ntop->getTrace()->traceEvent(TRACE_NORMAL, - "Flow dropped due to limits to the license. Exporters limit: %d (%d active)" - " | Interfaces limit: %d (%d active)", - get_max_num_flow_exporters(), ntop->getNumFlowExporters(), - get_max_num_flow_exporters_interfaces(), ntop->getNumFlowExportersInterfaces()); + "Exporters t: %d/%d max | Exporter Interfaces: %d/%d max", + ntop->getNumFlowExporters(), get_max_num_flow_exporters(), + ntop->getNumFlowExportersInterfaces(), get_max_num_flow_exporters_interfaces()); + + ntop->getTrace()->traceEvent(TRACE_NORMAL, + "Discarded [unique_source_id: %u];device_ip: %u][probe_ip: %u][iface: %u->%u]", + unique_source_id, zflow->exporter_device_ip, + zflow->nprobe_ip, zflow->inIndex, zflow->outIndex); + ntop->getRedis()->set(EXPORTERS_EXCEEDED_LIMITS_KEY, "1"); shown = true; }