diff --git a/include/HostsPortsAnalysis.h b/include/HostsPortsAnalysis.h index 950a4f4e98..3ae8a13007 100644 --- a/include/HostsPortsAnalysis.h +++ b/include/HostsPortsAnalysis.h @@ -26,36 +26,39 @@ class HostsPortsAnalysis { - private: - u_int16_t port = 0; - int l7_protocol_id = 0; - u_int8_t l4_protocol_id = 0; - std::unordered_map *hosts_details; +private: + u_int16_t port = 0; + int l7_protocol_id = 0; + u_int8_t l4_protocol_id = 0; + std::unordered_map *hosts_details; - public: - HostsPortsAnalysis(){ - hosts_details = new (std::nothrow) std::unordered_map; - }; - ~HostsPortsAnalysis() { - std::unordered_map::iterator it; - for (it = hosts_details->begin(); it != hosts_details->end(); ++it) - delete it->second; - if(hosts_details) - delete hosts_details; - }; +public: + HostsPortsAnalysis(){ + hosts_details = new (std::nothrow) std::unordered_map; + }; + ~HostsPortsAnalysis() { + std::unordered_map::iterator it; + + if(hosts_details) { + for (it = hosts_details->begin(); it != hosts_details->end(); ++it) + delete it->second; + + delete hosts_details; + } + }; - /* Getters */ - inline u_int16_t get_port() { return(port); }; - inline std::unordered_map* get_hosts_details() { return(hosts_details); }; - inline int get_l7_proto() { return(l7_protocol_id); }; - inline u_int8_t get_l4_proto() { return(l4_protocol_id); }; + /* Getters */ + inline u_int16_t get_port() { return(port); }; + inline std::unordered_map* get_hosts_details() { return(hosts_details); }; + inline int get_l7_proto() { return(l7_protocol_id); }; + inline u_int8_t get_l4_proto() { return(l4_protocol_id); }; - /* Setters */ - void add_host_details(HostDetails *host_details); - inline void set_port(u_int16_t _port) { port = _port; }; - inline void set_l7_proto(int l7_proto) { l7_protocol_id = l7_proto; }; - inline void set_l4_proto(u_int8_t l4_proto) { l4_protocol_id = l4_proto; }; + /* Setters */ + void add_host_details(HostDetails *host_details); + inline void set_port(u_int16_t _port) { port = _port; }; + inline void set_l7_proto(int l7_proto) { l7_protocol_id = l7_proto; }; + inline void set_l4_proto(u_int8_t l4_proto) { l4_protocol_id = l4_proto; }; }; #endif /* _HOSTS_PORTS_ANALYSIS_H_ */ diff --git a/include/LocalHost.h b/include/LocalHost.h index a9dc8d765a..d964d8c543 100644 --- a/include/LocalHost.h +++ b/include/LocalHost.h @@ -33,8 +33,7 @@ class LocalHost : public Host { std::unordered_map doh_dot_map; u_int8_t router_mac[6]; /* MAC address pf the first router used (no Mac* to avoid purging race conditions) */ - u_int8_t router_mac_set : 1, drop_all_host_traffic : 1, systemHost : 1, - _notused : 5; + u_int8_t router_mac_set : 1, drop_all_host_traffic : 1, systemHost : 1, _notused : 5; /* LocalHost data: update LocalHost::deleteHostData when adding new fields */ char *os_detail; diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index dfc33a1166..e5593b80f2 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -743,7 +743,7 @@ public: struct timeval periodicUpdateInitTime() const; virtual u_int32_t getFlowMaxIdle(); - virtual void lua(lua_State *vm); + virtual void lua(lua_State *vm, bool fullStats); void luaScore(lua_State *vm); void luaAlertedFlows(lua_State *vm); void luaAnomalies(lua_State *vm); diff --git a/include/SyslogCollectorInterface.h b/include/SyslogCollectorInterface.h index 271aedff61..adce69a07d 100644 --- a/include/SyslogCollectorInterface.h +++ b/include/SyslogCollectorInterface.h @@ -84,7 +84,7 @@ class SyslogCollectorInterface : public SyslogParserInterface { void startPacketPolling(); void shutdown(); bool set_packet_filter(char *filter); - virtual void lua(lua_State *vm); + virtual void lua(lua_State *vm, bool fullStats); }; #endif /* HAVE_NEDGE */ diff --git a/include/SyslogParserInterface.h b/include/SyslogParserInterface.h index fb912d9b72..6b3c36dc0d 100644 --- a/include/SyslogParserInterface.h +++ b/include/SyslogParserInterface.h @@ -44,7 +44,7 @@ class SyslogParserInterface : public ParserInterface { u_int8_t parseLog(char *log_line, char *client_ip); u_int32_t getNumDroppedPackets() { return 0; }; - virtual void lua(lua_State *vm); + virtual void lua(lua_State *vm, bool fullStats); virtual void startPacketPolling(); }; diff --git a/include/ZMQCollectorInterface.h b/include/ZMQCollectorInterface.h index 52a8145ebc..f6b01b48d7 100644 --- a/include/ZMQCollectorInterface.h +++ b/include/ZMQCollectorInterface.h @@ -61,7 +61,7 @@ class ZMQCollectorInterface : public ZMQParserInterface { void startPacketPolling(); bool set_packet_filter(char *filter); - virtual void lua(lua_State *vm); + virtual void lua(lua_State *vm, bool fullStats); virtual bool areTrafficDirectionsSupported() { return (true); }; }; diff --git a/include/ZMQParserInterface.h b/include/ZMQParserInterface.h index b39301620f..a52d805ccd 100644 --- a/include/ZMQParserInterface.h +++ b/include/ZMQParserInterface.h @@ -139,7 +139,7 @@ class ZMQParserInterface : public ParserInterface { u_int32_t getNumDroppedPackets() { return zmq_remote_stats ? zmq_remote_stats->sflow_pkt_sample_drops : 0; }; - virtual void lua(lua_State *vm); + virtual void lua(lua_State *vm, bool fullStats); inline u_int32_t getFlowMaxIdle() { return (returned_flow_max_idle); } }; diff --git a/include/ntop_includes.h b/include/ntop_includes.h index 3e1b7d930a..6840fa1454 100644 --- a/include/ntop_includes.h +++ b/include/ntop_includes.h @@ -508,4 +508,6 @@ using namespace std; #include "ntoppro_defines.h" #endif +extern bool trace_new_delete; + #endif /* _NTOP_H_ */ diff --git a/scripts/lua/modules/callback_utils.lua b/scripts/lua/modules/callback_utils.lua index 33b0e8558f..a85011fd76 100644 --- a/scripts/lua/modules/callback_utils.lua +++ b/scripts/lua/modules/callback_utils.lua @@ -27,7 +27,7 @@ function callback_utils.foreachInterface(ifnames, condition, callback, update_di interface.updateDirectionStats() end - local ifstats = interface.getStats() + local ifstats = interface.getStats(false) -- limited stats if condition == nil or condition(ifstats.id) then if((ifstats.type ~= "pcap dump") and (ifstats.type ~= "unknown")) then diff --git a/src/AddressResolution.cpp b/src/AddressResolution.cpp index bc4d4b6e35..84f2581e74 100644 --- a/src/AddressResolution.cpp +++ b/src/AddressResolution.cpp @@ -24,6 +24,8 @@ /* **************************************** */ AddressResolution::AddressResolution(int _num_resolvers) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_resolved_addresses = num_resolved_fails = 0; num_resolvers = _num_resolvers; @@ -34,6 +36,8 @@ AddressResolution::AddressResolution(int _num_resolvers) { /* **************************************** */ AddressResolution::~AddressResolution() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (ntop->getPrefs() && ntop->getPrefs()->is_dns_resolution_enabled()) { for (int i = 0; i < num_resolvers; i++) { if (resolveThreadLoop[i]) pthread_join(resolveThreadLoop[i], NULL); @@ -119,10 +123,9 @@ void AddressResolution::resolveHostName(const char *_numeric_ip, char *symbolic, inet_pton(AF_INET6, numeric_ip, &in6.sin6_addr); len = sizeof(struct sockaddr_in6), sa = (struct sockaddr *)&in6; } else { - ntop->getTrace()->traceEvent( - TRACE_INFO, - "Invalid IPv6 address to resolve '%s': already symbolic?", - numeric_ip); + ntop->getTrace()->traceEvent(TRACE_INFO, + "Invalid IPv6 address to resolve '%s': already symbolic?", + numeric_ip); return; /* Invalid format */ } } else { diff --git a/src/AddressTree.cpp b/src/AddressTree.cpp index b3577d0677..958455f123 100644 --- a/src/AddressTree.cpp +++ b/src/AddressTree.cpp @@ -30,6 +30,8 @@ static void free_ptree_data(void *data) { /* **************************************** */ AddressTree::AddressTree(bool handleIPv6, ndpi_void_fn_t data_free_func) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + if (data_free_func) free_func = data_free_func; else @@ -73,7 +75,10 @@ void AddressTree::init(bool handleIPv6) { /* **************************************** */ -AddressTree::~AddressTree() { cleanup(); } +AddressTree::~AddressTree() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + cleanup(); +} /* ******************************************* */ diff --git a/src/AggregatedFlowsStats.cpp b/src/AggregatedFlowsStats.cpp index 9131ed35c0..792b8bb93e 100644 --- a/src/AggregatedFlowsStats.cpp +++ b/src/AggregatedFlowsStats.cpp @@ -25,6 +25,7 @@ AggregatedFlowsStats::AggregatedFlowsStats(const IpAddress* c, const IpAddress* s, u_int8_t _l4_proto, u_int64_t bytes_sent, u_int64_t bytes_rcvd, u_int32_t score) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); num_flows = tot_sent = tot_rcvd = tot_score = key = vlan_id = flow_device_ip = proto_key = 0; l4_proto = _l4_proto; @@ -36,6 +37,7 @@ AggregatedFlowsStats::AggregatedFlowsStats(const IpAddress* c, const IpAddress* /* *************************************** */ AggregatedFlowsStats::~AggregatedFlowsStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (proto_name) free(proto_name); if (info_key) free(info_key); if (client) delete client; diff --git a/src/AlertCounter.cpp b/src/AlertCounter.cpp index 9a23a4a22a..8e10648b50 100644 --- a/src/AlertCounter.cpp +++ b/src/AlertCounter.cpp @@ -26,6 +26,7 @@ /* *************************************** */ AlertCounter::AlertCounter() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); trailing_window_max_since_hits_reset = 0; hits_reset_req = false; reset_window(); diff --git a/src/AlertableEntity.cpp b/src/AlertableEntity.cpp index 12f1a7b0de..083cb23824 100644 --- a/src/AlertableEntity.cpp +++ b/src/AlertableEntity.cpp @@ -24,6 +24,8 @@ /* ****************************************** */ AlertableEntity::AlertableEntity(NetworkInterface *iface, AlertEntity entity) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + alert_iface = iface; entity_type = entity; num_engaged_alerts = 0; @@ -32,6 +34,7 @@ AlertableEntity::AlertableEntity(NetworkInterface *iface, AlertEntity entity) { /* ****************************************** */ AlertableEntity::~AlertableEntity() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); #if 0 if(getNumEngagedAlerts() > 0) { /* Cannot destroy an alertable entity with currently engaged alerts, diff --git a/src/AlertsQueue.cpp b/src/AlertsQueue.cpp index 65a0d10881..28ae517906 100644 --- a/src/AlertsQueue.cpp +++ b/src/AlertsQueue.cpp @@ -23,7 +23,10 @@ /* **************************************************** */ -AlertsQueue::AlertsQueue(NetworkInterface *_iface) { iface = _iface; } +AlertsQueue::AlertsQueue(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + iface = _iface; +} /* **************************************************** */ diff --git a/src/AutonomousSystem.cpp b/src/AutonomousSystem.cpp index bd96529bf7..6715f717ae 100644 --- a/src/AutonomousSystem.cpp +++ b/src/AutonomousSystem.cpp @@ -27,6 +27,8 @@ AutonomousSystem::AutonomousSystem(NetworkInterface *_iface, IpAddress *ipa) : GenericHashEntry(_iface), GenericTrafficElement(), Score(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + asname = NULL; round_trip_time = 0; alerted_flows_as_client = alerted_flows_as_server = 0; @@ -64,6 +66,7 @@ void AutonomousSystem::set_hash_entry_state_idle() { ; /* Nothing to do */ } /* *************************************** */ AutonomousSystem::~AutonomousSystem() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (asname) free(asname); /* TODO: decide if it is useful to dump AS stats to redis */ /* diff --git a/src/AutonomousSystemHash.cpp b/src/AutonomousSystemHash.cpp index 2482bc0095..788f71e8f1 100644 --- a/src/AutonomousSystemHash.cpp +++ b/src/AutonomousSystemHash.cpp @@ -27,7 +27,7 @@ AutonomousSystemHash::AutonomousSystemHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "AutonomousSystemHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/Bitmask.cpp b/src/Bitmask.cpp index fd09f5c01e..293cede5fc 100644 --- a/src/Bitmask.cpp +++ b/src/Bitmask.cpp @@ -28,6 +28,8 @@ * @param num_tot_elems The bitmask size in number of bit. */ Bitmask::Bitmask(u_int32_t num_tot_elems) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + tot_elems = num_tot_elems; num_elems = tot_elems / 8; @@ -53,6 +55,7 @@ Bitmask::Bitmask(u_int32_t num_tot_elems) { * Destructor. */ Bitmask::~Bitmask() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (bits) free(bits); } @@ -122,4 +125,4 @@ bool Bitmask::bitmask_isset(u_int32_t n) { /* ********************************************************** */ -void Bitmask::bitmask_clr_all() { memset(bits, 0, num_elems); } \ No newline at end of file +void Bitmask::bitmask_clr_all() { memset(bits, 0, num_elems); } diff --git a/src/Bloom.cpp b/src/Bloom.cpp index c436bdb721..f5fe8a1aec 100644 --- a/src/Bloom.cpp +++ b/src/Bloom.cpp @@ -38,7 +38,10 @@ Bloom::Bloom(u_int32_t _num_bloom_bits) { /** * Destructor. */ -Bloom::~Bloom() { delete bitmask; } +Bloom::~Bloom() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + delete bitmask; +} /* ******************************************************* */ diff --git a/src/BroadcastDomains.cpp b/src/BroadcastDomains.cpp index 79f33a930b..2e1bff33a4 100644 --- a/src/BroadcastDomains.cpp +++ b/src/BroadcastDomains.cpp @@ -26,6 +26,7 @@ /* *************************************** */ BroadcastDomains::BroadcastDomains(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); iface = _iface; inline_broadcast_domains = new (std::nothrow) AddressTree(false); broadcast_domains = broadcast_domains_shadow = NULL; @@ -36,6 +37,8 @@ BroadcastDomains::BroadcastDomains(NetworkInterface *_iface) { /* *************************************** */ BroadcastDomains::~BroadcastDomains() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (inline_broadcast_domains) { delete (inline_broadcast_domains); inline_broadcast_domains = NULL; diff --git a/src/CategoryCounter.cpp b/src/CategoryCounter.cpp index 8a890614b4..d05f785e8d 100644 --- a/src/CategoryCounter.cpp +++ b/src/CategoryCounter.cpp @@ -23,11 +23,15 @@ /* *********************************************** */ -CategoryCounter::CategoryCounter() { duration = 0, last_epoch_update = 0; } +CategoryCounter::CategoryCounter() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + duration = 0, last_epoch_update = 0; +} /* *********************************************** */ CategoryCounter::CategoryCounter(const CategoryCounter &c) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); bytes = c.bytes, duration = c.duration, last_epoch_update = c.last_epoch_update; }; diff --git a/src/Check.cpp b/src/Check.cpp index 09f5cfdbe6..f9cda3de57 100644 --- a/src/Check.cpp +++ b/src/Check.cpp @@ -25,6 +25,8 @@ Check::Check(NtopngEdition _edition, bool _packet_interface_only, bool _nedge_exclude, bool _nedge_only) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + check_edition = _edition; packet_interface_only = _packet_interface_only; nedge_exclude = _nedge_exclude; @@ -34,7 +36,9 @@ Check::Check(NtopngEdition _edition, bool _packet_interface_only, /* **************************************************** */ -Check::~Check(){}; +Check::~Check(){ + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +}; /* **************************************************** */ diff --git a/src/ChecksLoader.cpp b/src/ChecksLoader.cpp index 0efaf364ea..42cd44e769 100644 --- a/src/ChecksLoader.cpp +++ b/src/ChecksLoader.cpp @@ -25,6 +25,8 @@ /* **************************************************** */ ChecksLoader::ChecksLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + /* Set the ntopng version matching the loaded checks */ if (ntop->getPrefs()->is_enterprise_l_edition()) checks_edition = ntopng_edition_enterprise_l; @@ -38,4 +40,6 @@ ChecksLoader::ChecksLoader() { /* **************************************************** */ -ChecksLoader::~ChecksLoader() {} +ChecksLoader::~ChecksLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} diff --git a/src/Condvar.cpp b/src/Condvar.cpp index a3bf395ae6..0731e5d551 100644 --- a/src/Condvar.cpp +++ b/src/Condvar.cpp @@ -23,7 +23,10 @@ /* ************************************ */ -Condvar::Condvar() { init(); } +Condvar::Condvar() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + init(); +} /* ************************************ */ @@ -36,6 +39,7 @@ void Condvar::init() { /* ************************************ */ Condvar::~Condvar() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); pthread_mutex_destroy(&mutex); pthread_cond_destroy(&condvar); } diff --git a/src/ContainerStats.cpp b/src/ContainerStats.cpp index b3d0d605dd..1656a0a9b2 100644 --- a/src/ContainerStats.cpp +++ b/src/ContainerStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ ContainerStats::ContainerStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); num_flows_as_client = num_flows_as_server = 0; tot_rtt_as_client = tot_rtt_variance_as_client = 0; tot_rtt_as_server = tot_rtt_variance_as_server = 0; diff --git a/src/ContinuousPing.cpp b/src/ContinuousPing.cpp index 1e6a69f35b..74c411f855 100644 --- a/src/ContinuousPing.cpp +++ b/src/ContinuousPing.cpp @@ -60,6 +60,7 @@ static void *pollerFctn(void *ptr) { ContinuousPing::ContinuousPing() { ntop_if_t *devpointer, *cur; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); started = false; /* Create default pinger */ @@ -111,6 +112,8 @@ ContinuousPing::ContinuousPing() { /* ***************************************** */ ContinuousPing::~ContinuousPing() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (std::map::iterator it = v4_results.begin(); it != v4_results.end(); ++it) diff --git a/src/CountriesHash.cpp b/src/CountriesHash.cpp index e3fae423ff..8ae19d21bd 100644 --- a/src/CountriesHash.cpp +++ b/src/CountriesHash.cpp @@ -26,7 +26,7 @@ CountriesHash::CountriesHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "CountriesHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/Country.cpp b/src/Country.cpp index d6497bbb5d..18f25d120b 100644 --- a/src/Country.cpp +++ b/src/Country.cpp @@ -28,6 +28,7 @@ Country::Country(NetworkInterface *_iface, const char *country) GenericTrafficElement(), Score(_iface), dirstats(_iface, 0) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); country_name = strdup(country); #ifdef COUNTRY_DEBUG @@ -43,9 +44,9 @@ void Country::set_hash_entry_state_idle() { ; /* Nothing to do */ } /* *************************************** */ Country::~Country() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); #ifdef COUNTRY_DEBUG - ntop->getTrace()->traceEvent(TRACE_NORMAL, "Deleted Country %s", - country_name); + ntop->getTrace()->traceEvent(TRACE_NORMAL, "Deleted Country %s", country_name); #endif free(country_name); diff --git a/src/DB.cpp b/src/DB.cpp index b51f05d4e6..681452017d 100644 --- a/src/DB.cpp +++ b/src/DB.cpp @@ -24,6 +24,8 @@ /* ******************************************* */ DB::DB(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + running = false; iface = _iface; diff --git a/src/DSCPStats.cpp b/src/DSCPStats.cpp index bf94107720..d9b0b83f53 100644 --- a/src/DSCPStats.cpp +++ b/src/DSCPStats.cpp @@ -67,7 +67,10 @@ u_int8_t DSCPStats::ds2Precedence(u_int8_t ds_id) { /* *************************************** */ -DSCPStats::DSCPStats() { memset(counters, 0, sizeof(counters)); } +DSCPStats::DSCPStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(counters, 0, sizeof(counters)); +} /* *************************************** */ diff --git a/src/DnsStats.cpp b/src/DnsStats.cpp index 5541036cde..7dd6b3d558 100644 --- a/src/DnsStats.cpp +++ b/src/DnsStats.cpp @@ -24,6 +24,8 @@ /* *************************************** */ DnsStats::DnsStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(&sent_stats.breakdown, 0, sizeof(sent_stats.breakdown)), memset(&rcvd_stats.breakdown, 0, sizeof(rcvd_stats.breakdown)); sent_stats.num_queries.reset(), sent_stats.num_replies_ok.reset(), diff --git a/src/DummyInterface.cpp b/src/DummyInterface.cpp index eb911626db..81ce8d8927 100644 --- a/src/DummyInterface.cpp +++ b/src/DummyInterface.cpp @@ -26,6 +26,7 @@ /* **************************************************** */ DummyInterface::DummyInterface() : ZMQParserInterface("dummy") { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); ntop->getTrace()->traceEvent(TRACE_NORMAL, "Initialized dummy interface"); } diff --git a/src/ElasticSearch.cpp b/src/ElasticSearch.cpp index 8070b2ee6c..f8aa1f4428 100644 --- a/src/ElasticSearch.cpp +++ b/src/ElasticSearch.cpp @@ -38,6 +38,8 @@ static void *esLoop(void *ptr) { /* **************************************** */ ElasticSearch::ElasticSearch(NetworkInterface *_iface) : DB(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + snprintf(es_version, sizeof(es_version), "%c", '0'); es_version_inited = false; num_queued_elems = 0; @@ -64,6 +66,7 @@ ElasticSearch::ElasticSearch(NetworkInterface *_iface) : DB(_iface) { /* **************************************** */ ElasticSearch::~ElasticSearch() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); shutdown(); if (es_template_push_url) free(es_template_push_url); if (es_version_query_url) free(es_version_query_url); diff --git a/src/EthStats.cpp b/src/EthStats.cpp index 6a0edd3d85..e9122a6c84 100644 --- a/src/EthStats.cpp +++ b/src/EthStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -EthStats::EthStats() { cleanup(); } +EthStats::EthStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + cleanup(); +} /* *************************************** */ diff --git a/src/ExportInterface.cpp b/src/ExportInterface.cpp index 700443fb3a..c49cc0c71e 100644 --- a/src/ExportInterface.cpp +++ b/src/ExportInterface.cpp @@ -28,6 +28,7 @@ /* **************************************************** */ ExportInterface::ExportInterface(const char *_endpoint, const char *_topic) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); topic = strdup(_topic), endpoint = strdup(_endpoint); if ((context = zmq_ctx_new()) == NULL) { @@ -111,6 +112,7 @@ ExportInterface::ExportInterface(const char *_endpoint, const char *_topic) { /* **************************************************** */ ExportInterface::~ExportInterface() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (topic) free(topic); if (endpoint) free(endpoint); diff --git a/src/Flow.cpp b/src/Flow.cpp index f8142b3b65..a0926b31ca 100644 --- a/src/Flow.cpp +++ b/src/Flow.cpp @@ -43,6 +43,8 @@ Flow::Flow(NetworkInterface *_iface, time_t _first_seen, time_t _last_seen, u_int8_t *_view_cli_mac, u_int8_t *_view_srv_mac) : GenericHashEntry(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + iface_index = _iface_idx, vlanId = _vlanId, protocol = _protocol, cli_port = _cli_port, srv_port = _srv_port, privateFlowId = _private_flow_id; @@ -337,9 +339,9 @@ void Flow::freeDPIMemory() { Flow::~Flow() { bool is_oneway_tcp_udp_flow = (((protocol == IPPROTO_TCP) || (protocol == IPPROTO_UDP)) && isOneWay()) - ? true - : false; + ? true : false; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (getUses() != 0 && !ntop->getGlobals()->isShutdown()) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[%s] Deleting flow [%u]", __FUNCTION__, getUses()); diff --git a/src/FlowAlert.cpp b/src/FlowAlert.cpp index e74b8989f8..b4c815e133 100644 --- a/src/FlowAlert.cpp +++ b/src/FlowAlert.cpp @@ -24,6 +24,7 @@ /* **************************************************** */ FlowAlert::FlowAlert(FlowCheck *c, Flow *f) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); flow = f; cli_attacker = srv_attacker = false; cli_victim = srv_victim = false; @@ -32,7 +33,9 @@ FlowAlert::FlowAlert(FlowCheck *c, Flow *f) { /* **************************************************** */ -FlowAlert::~FlowAlert() {} +FlowAlert::~FlowAlert() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} /* ***************************************************** */ diff --git a/src/FlowAlertsLoader.cpp b/src/FlowAlertsLoader.cpp index d2b6201de4..35efc0abd4 100644 --- a/src/FlowAlertsLoader.cpp +++ b/src/FlowAlertsLoader.cpp @@ -25,6 +25,7 @@ /* **************************************************** */ FlowAlertsLoader::FlowAlertsLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(&alert_to_score, 0, sizeof(alert_to_score)); /* Set all alerts to no risk, then initialize risk-based alerts */ diff --git a/src/FlowCheck.cpp b/src/FlowCheck.cpp index 1f0df43b91..f57eb07003 100644 --- a/src/FlowCheck.cpp +++ b/src/FlowCheck.cpp @@ -28,6 +28,7 @@ FlowCheck::FlowCheck(NtopngEdition _edition, bool _packet_interface_only, bool _has_protocol_detected, bool _has_periodic_update, bool _has_flow_end, bool _has_flow_begin) : Check(_edition, _packet_interface_only, _nedge_exclude, _nedge_only) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); has_protocol_detected = _has_protocol_detected; has_periodic_update = _has_periodic_update; has_flow_end = _has_flow_end; @@ -39,7 +40,9 @@ FlowCheck::FlowCheck(NtopngEdition _edition, bool _packet_interface_only, /* **************************************************** */ -FlowCheck::~FlowCheck(){}; +FlowCheck::~FlowCheck() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +}; /* **************************************************** */ diff --git a/src/FlowChecksExecutor.cpp b/src/FlowChecksExecutor.cpp index acf6457f08..bd5f2de27f 100644 --- a/src/FlowChecksExecutor.cpp +++ b/src/FlowChecksExecutor.cpp @@ -25,6 +25,7 @@ FlowChecksExecutor::FlowChecksExecutor(FlowChecksLoader *fcl, NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); iface = _iface; loadFlowChecks(fcl); }; @@ -32,6 +33,7 @@ FlowChecksExecutor::FlowChecksExecutor(FlowChecksLoader *fcl, /* **************************************************** */ FlowChecksExecutor::~FlowChecksExecutor() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (protocol_detected) delete protocol_detected; if (periodic_update) delete periodic_update; if (flow_end) delete flow_end; diff --git a/src/FlowChecksLoader.cpp b/src/FlowChecksLoader.cpp index 81c1645923..5fb612ce65 100644 --- a/src/FlowChecksLoader.cpp +++ b/src/FlowChecksLoader.cpp @@ -29,6 +29,7 @@ FlowChecksLoader::FlowChecksLoader() : ChecksLoader() { Assuments all risks as unhanlded. Bits corresponding to risks handled by checks will be set to zero during checks registration. */ + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); NDPI_BITMASK_SET_ALL(unhandled_ndpi_risks); NDPI_CLR_BIT(unhandled_ndpi_risks, NDPI_NO_RISK); } @@ -36,6 +37,8 @@ FlowChecksLoader::FlowChecksLoader() : ChecksLoader() { /* **************************************************** */ FlowChecksLoader::~FlowChecksLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (std::map::const_iterator it = cb_all.begin(); it != cb_all.end(); ++it) delete it->second; diff --git a/src/FlowGrouper.cpp b/src/FlowGrouper.cpp index 7f2643f76c..cdbff43f0c 100644 --- a/src/FlowGrouper.cpp +++ b/src/FlowGrouper.cpp @@ -24,6 +24,8 @@ /* *************************************** */ FlowGrouper::FlowGrouper(sortField sf) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + sorter = sf; app_protocol = 0; table_index = 1; @@ -33,7 +35,9 @@ FlowGrouper::FlowGrouper(sortField sf) { /* *************************************** */ -FlowGrouper::~FlowGrouper() {} +FlowGrouper::~FlowGrouper() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} /* *************************************** */ diff --git a/src/FlowHash.cpp b/src/FlowHash.cpp index e34fb7a7c4..321bb7f608 100644 --- a/src/FlowHash.cpp +++ b/src/FlowHash.cpp @@ -26,7 +26,7 @@ FlowHash::FlowHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "FlowHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); }; /* ************************************ */ diff --git a/src/FlowStats.cpp b/src/FlowStats.cpp index 30984a1555..ef4335ba00 100644 --- a/src/FlowStats.cpp +++ b/src/FlowStats.cpp @@ -23,11 +23,15 @@ /* *************************************** */ -FlowStats::FlowStats() { resetStats(); } +FlowStats::FlowStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + resetStats(); } /* *************************************** */ -FlowStats::~FlowStats() {} +FlowStats::~FlowStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} /* *************************************** */ diff --git a/src/FlowTrafficStats.cpp b/src/FlowTrafficStats.cpp index 7ed510ddb9..de0d33601f 100644 --- a/src/FlowTrafficStats.cpp +++ b/src/FlowTrafficStats.cpp @@ -24,6 +24,8 @@ /* *************************************** */ FlowTrafficStats::FlowTrafficStats() : PartializableFlowTrafficStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ndpi_init_data_analysis(&cli2srv_bytes_stats, 0), ndpi_init_data_analysis(&srv2cli_bytes_stats, 0); } @@ -32,6 +34,8 @@ FlowTrafficStats::FlowTrafficStats() : PartializableFlowTrafficStats() { FlowTrafficStats::FlowTrafficStats(const FlowTrafficStats& fts) : PartializableFlowTrafficStats(fts) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ndpi_init_data_analysis(&cli2srv_bytes_stats, 0), ndpi_init_data_analysis(&srv2cli_bytes_stats, 0); } @@ -39,6 +43,8 @@ FlowTrafficStats::FlowTrafficStats(const FlowTrafficStats& fts) /* *************************************** */ FlowTrafficStats::~FlowTrafficStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + ndpi_free_data_analysis(&cli2srv_bytes_stats, 0), ndpi_free_data_analysis(&srv2cli_bytes_stats, 0); } diff --git a/src/GenericHash.cpp b/src/GenericHash.cpp index e6c489e2b9..f3791c92e9 100644 --- a/src/GenericHash.cpp +++ b/src/GenericHash.cpp @@ -25,6 +25,8 @@ GenericHash::GenericHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size, const char *_name) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_hashes = _num_hashes; current_size = 0; /* Allow the total number of entries (that is, active and those idle but still diff --git a/src/GenericHashEntry.cpp b/src/GenericHashEntry.cpp index e4f788244c..45e281a5a2 100644 --- a/src/GenericHashEntry.cpp +++ b/src/GenericHashEntry.cpp @@ -24,6 +24,8 @@ /* ***************************************** */ GenericHashEntry::GenericHashEntry(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + hash_next = NULL, iface = _iface, first_seen = last_seen = 0; num_uses = 0; hash_table = NULL; @@ -38,7 +40,9 @@ GenericHashEntry::GenericHashEntry(NetworkInterface *_iface) { /* ***************************************** */ -GenericHashEntry::~GenericHashEntry() { ; } +GenericHashEntry::~GenericHashEntry() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} /* ***************************************** */ diff --git a/src/GenericTrafficElement.cpp b/src/GenericTrafficElement.cpp index 986e882704..479f2262aa 100644 --- a/src/GenericTrafficElement.cpp +++ b/src/GenericTrafficElement.cpp @@ -24,6 +24,8 @@ /* *************************************** */ GenericTrafficElement::GenericTrafficElement() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + /* NOTE NOTE NOTE: keep in sync with copy constructor below */ ndpiStats = NULL; diff --git a/src/Geolocation.cpp b/src/Geolocation.cpp index 14638c8874..f58ada3443 100644 --- a/src/Geolocation.cpp +++ b/src/Geolocation.cpp @@ -31,6 +31,8 @@ /* *************************************** */ Geolocation::Geolocation() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + #ifdef HAVE_MAXMINDDB char docs_path[MAX_PATH]; const char *lookup_paths[] = { diff --git a/src/HTTPserver.cpp b/src/HTTPserver.cpp index 8762260f03..89d441897c 100644 --- a/src/HTTPserver.cpp +++ b/src/HTTPserver.cpp @@ -1788,6 +1788,8 @@ HTTPserver::HTTPserver(const char *_docs_dir, const char *_scripts_dir) { bool good_ssl_cert = false; struct timeval tv; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(ports, 0, sizeof(ports)), memset(access_log_path, 0, sizeof(access_log_path)); use_http = true; @@ -1952,6 +1954,8 @@ void HTTPserver::startHttpServer() { /* ****************************************** */ HTTPserver::~HTTPserver() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (httpd_v4) mg_stop(httpd_v4); #ifdef HAVE_NEDGE if (httpd_captive_v4) mg_stop(httpd_captive_v4); diff --git a/src/HTTPstats.cpp b/src/HTTPstats.cpp index cd120efb49..777c3e5d29 100644 --- a/src/HTTPstats.cpp +++ b/src/HTTPstats.cpp @@ -33,6 +33,8 @@ struct http_walk_info { HTTPstats::HTTPstats(Host *_host) { struct timeval tv; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + host = _host; h = host->getInterface()->get_hosts_hash(), warning_shown = false; memset(&query, 0, sizeof(query)); @@ -55,6 +57,7 @@ HTTPstats::HTTPstats(Host *_host) { /* *************************************** */ HTTPstats::~HTTPstats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (virtualHosts) delete (virtualHosts); } diff --git a/src/Host.cpp b/src/Host.cpp index 9a617b6afe..79bbaa0801 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -30,6 +30,7 @@ Host::Host(NetworkInterface *_iface, int32_t _iface_idx, HostAlertableEntity(_iface, alert_entity_host), Score(_iface), HostChecksStatus() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); ip.set(ipAddress); initialize(NULL, _iface_idx, _vlan_id, observation_point_id); } @@ -43,6 +44,8 @@ Host::Host(NetworkInterface *_iface, int32_t _iface_idx, HostAlertableEntity(_iface, alert_entity_host), Score(_iface), HostChecksStatus() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ip.set(_ip); #ifdef BROADCAST_DEBUG @@ -59,6 +62,8 @@ Host::Host(NetworkInterface *_iface, int32_t _iface_idx, /* *************************************** */ Host::~Host() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if ((getUses() > 0) /* View hosts are not in sync with viewed flows so during shutdown it can be normal */ diff --git a/src/HostAlert.cpp b/src/HostAlert.cpp index e57e9045eb..8b3395532f 100644 --- a/src/HostAlert.cpp +++ b/src/HostAlert.cpp @@ -41,18 +41,22 @@ void HostAlert::init(HostCheckID _check_id, std::string _check_name, Host *h, HostAlert::HostAlert(HostCheckID _check_id, std::string _check_name, Host *h, risk_percentage _cli_pctg) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); init(_check_id, _check_name, h, _cli_pctg); } /* **************************************************** */ HostAlert::HostAlert(HostCheck *c, Host *h, risk_percentage _cli_pctg) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); init(c->getID(), c->getName(), h, _cli_pctg); } /* **************************************************** */ -HostAlert::~HostAlert() {} +HostAlert::~HostAlert() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +} /* ***************************************************** */ diff --git a/src/HostAlertableEntity.cpp b/src/HostAlertableEntity.cpp index 62dc68540d..66fe93edf9 100644 --- a/src/HostAlertableEntity.cpp +++ b/src/HostAlertableEntity.cpp @@ -26,12 +26,16 @@ HostAlertableEntity::HostAlertableEntity(NetworkInterface *iface, AlertEntity entity) : AlertableEntity(iface, entity) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(engaged_alerts, 0, sizeof(engaged_alerts)); } /* ****************************************** */ -HostAlertableEntity::~HostAlertableEntity() { clearEngagedAlerts(); } +HostAlertableEntity::~HostAlertableEntity() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + clearEngagedAlerts(); +} /* *************************************** */ diff --git a/src/HostCheck.cpp b/src/HostCheck.cpp index 3df64f41b5..88c401d4d0 100644 --- a/src/HostCheck.cpp +++ b/src/HostCheck.cpp @@ -26,12 +26,15 @@ HostCheck::HostCheck(NtopngEdition _edition, bool _packet_interface_only, bool _nedge_exclude, bool _nedge_only) : Check(_edition, _packet_interface_only, _nedge_exclude, _nedge_only) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); periodicity_secs = 0; }; /* **************************************************** */ -HostCheck::~HostCheck(){}; +HostCheck::~HostCheck() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); +}; /* **************************************************** */ diff --git a/src/HostChecksExecutor.cpp b/src/HostChecksExecutor.cpp index 35f4d37a61..716ae3f4e8 100644 --- a/src/HostChecksExecutor.cpp +++ b/src/HostChecksExecutor.cpp @@ -25,6 +25,7 @@ HostChecksExecutor::HostChecksExecutor(HostChecksLoader *fcl, NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); iface = _iface; memset(host_cb_arr, 0, sizeof(host_cb_arr)); loadHostChecks(fcl); @@ -33,6 +34,8 @@ HostChecksExecutor::HostChecksExecutor(HostChecksLoader *fcl, /* **************************************************** */ HostChecksExecutor::~HostChecksExecutor() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (periodic_host_cb) delete periodic_host_cb; }; diff --git a/src/HostChecksLoader.cpp b/src/HostChecksLoader.cpp index 407959e164..18c3365b07 100644 --- a/src/HostChecksLoader.cpp +++ b/src/HostChecksLoader.cpp @@ -24,11 +24,15 @@ /* **************************************************** */ -HostChecksLoader::HostChecksLoader() : ChecksLoader() {} +HostChecksLoader::HostChecksLoader() : ChecksLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); +} /* **************************************************** */ HostChecksLoader::~HostChecksLoader() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (std::map::const_iterator it = cb_all.begin(); it != cb_all.end(); ++it) delete it->second; diff --git a/src/HostHash.cpp b/src/HostHash.cpp index a18843a1cb..f2d0a7bf9e 100644 --- a/src/HostHash.cpp +++ b/src/HostHash.cpp @@ -26,6 +26,8 @@ HostHash::HostHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "HostHash") { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_http_hosts = 0; } diff --git a/src/HostPoolStats.cpp b/src/HostPoolStats.cpp index 6507b57a41..b92d310347 100644 --- a/src/HostPoolStats.cpp +++ b/src/HostPoolStats.cpp @@ -23,8 +23,9 @@ /* ***************************************** */ -HostPoolStats::HostPoolStats(NetworkInterface *iface) - : GenericTrafficElement() { +HostPoolStats::HostPoolStats(NetworkInterface *iface) : GenericTrafficElement() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ndpiStats = new (std::nothrow) nDPIStats(); totalStats = new (std::nothrow) nDPIStats(); mustReset = false; diff --git a/src/HostPools.cpp b/src/HostPools.cpp index acc07911d3..9c22051b5e 100644 --- a/src/HostPools.cpp +++ b/src/HostPools.cpp @@ -26,6 +26,8 @@ /* *************************************** */ HostPools::HostPools(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + tree = tree_shadow = NULL; stats = stats_shadow = NULL; #ifdef NTOPNG_PRO diff --git a/src/HostStats.cpp b/src/HostStats.cpp index d4d445e018..c5fc56cb3a 100644 --- a/src/HostStats.cpp +++ b/src/HostStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ HostStats::HostStats(Host* _host) : GenericTrafficElement() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); host = _host; alerted_flows_as_client = alerted_flows_as_server = 0; diff --git a/src/ICMPinfo.cpp b/src/ICMPinfo.cpp index 5c839e5ddc..d96e10652c 100644 --- a/src/ICMPinfo.cpp +++ b/src/ICMPinfo.cpp @@ -24,12 +24,14 @@ /* *************************************** */ ICMPinfo::ICMPinfo() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); unreach = NULL; reset(); } /* *************************************** */ ICMPinfo::ICMPinfo(const ICMPinfo &_icmp_info) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); unreach = NULL; reset(); @@ -57,6 +59,7 @@ void ICMPinfo::reset() { /* *************************************** */ ICMPinfo::~ICMPinfo() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (unreach) free(unreach); } diff --git a/src/ICMPstats.cpp b/src/ICMPstats.cpp index ee9ceddda7..890cd5d1a7 100644 --- a/src/ICMPstats.cpp +++ b/src/ICMPstats.cpp @@ -23,13 +23,18 @@ /* *************************************** */ -ICMPstats::ICMPstats() { num_destination_unreachable.reset(); } +ICMPstats::ICMPstats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_destination_unreachable.reset(); +} /* *************************************** */ ICMPstats::~ICMPstats() { std::map::const_iterator it; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (it = stats.begin(); it != stats.end(); ++it) { if (it->second.last_host_sent_peer) free(it->second.last_host_sent_peer); if (it->second.last_host_rcvd_peer) free(it->second.last_host_rcvd_peer); diff --git a/src/IEC104Stats.cpp b/src/IEC104Stats.cpp index 09557c7635..683359681b 100644 --- a/src/IEC104Stats.cpp +++ b/src/IEC104Stats.cpp @@ -33,6 +33,8 @@ /* *************************************** */ IEC104Stats::IEC104Stats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(&pkt_lost, 0, sizeof(pkt_lost)); last_type_i = 0; memset(&last_i_apdu, 0, sizeof(last_i_apdu)); @@ -46,7 +48,10 @@ IEC104Stats::IEC104Stats() { /* *************************************** */ -IEC104Stats::~IEC104Stats() { ndpi_free_data_analysis(i_s_apdu, 1); } +IEC104Stats::~IEC104Stats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ndpi_free_data_analysis(i_s_apdu, 1); +} /* *************************************** */ diff --git a/src/InfluxDBTimeseriesExporter.cpp b/src/InfluxDBTimeseriesExporter.cpp index e831668ff1..538b315eb3 100644 --- a/src/InfluxDBTimeseriesExporter.cpp +++ b/src/InfluxDBTimeseriesExporter.cpp @@ -41,6 +41,8 @@ */ InfluxDBTimeseriesExporter::InfluxDBTimeseriesExporter(NetworkInterface* _if) : TimeseriesExporter(_if) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_cached_entries = 0; cursize = num_exports = 0; fp = NULL; diff --git a/src/InterarrivalStats.cpp b/src/InterarrivalStats.cpp index 4ee76443e7..222664b310 100644 --- a/src/InterarrivalStats.cpp +++ b/src/InterarrivalStats.cpp @@ -24,6 +24,8 @@ /* ******************************************** */ InterarrivalStats::InterarrivalStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(&lastTime, 0, sizeof(lastTime)); ndpi_init_data_analysis(&delta_ms, 0); } diff --git a/src/InterfaceStatsHash.cpp b/src/InterfaceStatsHash.cpp index cf4a28b3ee..134a6d886d 100644 --- a/src/InterfaceStatsHash.cpp +++ b/src/InterfaceStatsHash.cpp @@ -24,6 +24,8 @@ /* ************************************ */ InterfaceStatsHash::InterfaceStatsHash(u_int _max_hash_size) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + max_hash_size = _max_hash_size; buckets = (sFlowInterfaceStats **)calloc(sizeof(sFlowInterfaceStats *), max_hash_size); diff --git a/src/IpAddress.cpp b/src/IpAddress.cpp index 3b909253d7..7a47350bf5 100644 --- a/src/IpAddress.cpp +++ b/src/IpAddress.cpp @@ -24,6 +24,8 @@ /* ******************************************* */ IpAddress::IpAddress() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ip_key = 0; memset(&addr, 0, sizeof(addr)); compute_key(); diff --git a/src/JobQueue.cpp b/src/JobQueue.cpp index f361660c5d..3451edb742 100644 --- a/src/JobQueue.cpp +++ b/src/JobQueue.cpp @@ -29,6 +29,8 @@ /* ******************************* */ JobQueue::JobQueue() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + max_num_jobs = MAX_NUM_CONCURRENT_JOBS; job_id = 0; } diff --git a/src/ListeningPorts.cpp b/src/ListeningPorts.cpp index bd69d89742..5af569c924 100644 --- a/src/ListeningPorts.cpp +++ b/src/ListeningPorts.cpp @@ -25,8 +25,7 @@ /* ************************************************ */ -void ListeningPorts::parsePortInfo( - json_object *z, std::map *info) { +void ListeningPorts::parsePortInfo(json_object *z, std::map *info) { json_object *p; ListeningPortInfo pinfo; u_int16_t port = 0; diff --git a/src/LocalHost.cpp b/src/LocalHost.cpp index 321b7fda64..d727ac094d 100644 --- a/src/LocalHost.cpp +++ b/src/LocalHost.cpp @@ -27,6 +27,8 @@ LocalHost::LocalHost(NetworkInterface *_iface, int32_t _iface_idx, Mac *_mac, u_int16_t _vlanId, u_int16_t _observation_point_id, IpAddress *_ip) : Host(_iface, _iface_idx, _mac, _vlanId, _observation_point_id, _ip) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + #ifdef LOCALHOST_DEBUG char buf[48]; @@ -42,12 +44,14 @@ LocalHost::LocalHost(NetworkInterface *_iface, int32_t _iface_idx, char *ipAddress, u_int16_t _vlanId, u_int16_t _observation_point_id) : Host(_iface, _iface_idx, ipAddress, _vlanId, _observation_point_id) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); initialize(); } /* *************************************** */ LocalHost::~LocalHost() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); addInactiveData(); if (initial_ts_point) delete (initial_ts_point); freeLocalHostData(); diff --git a/src/LocalHostStats.cpp b/src/LocalHostStats.cpp index bad54699e3..c67797a780 100644 --- a/src/LocalHostStats.cpp +++ b/src/LocalHostStats.cpp @@ -24,6 +24,8 @@ /* *************************************** */ LocalHostStats::LocalHostStats(Host *_host) : HostStats(_host) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + top_sites = new (std::nothrow) MostVisitedList(HOST_SITES_TOP_NUMBER); dns = new (std::nothrow) DnsStats(); diff --git a/src/LocalTrafficStats.cpp b/src/LocalTrafficStats.cpp index 422af68e72..535df630d4 100644 --- a/src/LocalTrafficStats.cpp +++ b/src/LocalTrafficStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ LocalTrafficStats::LocalTrafficStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(&packets, 0, sizeof(packets)); memset(&bytes, 0, sizeof(bytes)); } diff --git a/src/LuaEngine.cpp b/src/LuaEngine.cpp index ce3aac0b1b..533ec939f4 100644 --- a/src/LuaEngine.cpp +++ b/src/LuaEngine.cpp @@ -123,6 +123,8 @@ static void *l_alloc(void *ud, void *ptr, size_t old_size, size_t new_size) { LuaEngine::LuaEngine(lua_State *vm) { std::bad_alloc bax; void *ctx; + + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); ntop->incNumLuaVMs(); start_epoch= (u_int32_t)time(NULL); @@ -155,6 +157,8 @@ LuaEngine::LuaEngine(lua_State *vm) { /* ******************************* */ LuaEngine::~LuaEngine() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (L) { NtopngLuaContext *ctx; diff --git a/src/LuaEngineInterface.cpp b/src/LuaEngineInterface.cpp index 91ad31b6b4..34a574d672 100644 --- a/src/LuaEngineInterface.cpp +++ b/src/LuaEngineInterface.cpp @@ -3928,13 +3928,17 @@ static int ntop_interface_store_triggered_alert(lua_State *vm) { static int ntop_get_interface_stats(lua_State *vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); - + bool full_stats = true; + ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); if (!ntop_interface) return (ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_ERROR)); - ntop_interface->lua(vm); + if (lua_type(vm, 1) == LUA_TBOOLEAN) + full_stats = lua_toboolean(vm, 1) ? true : false; + + ntop_interface->lua(vm, full_stats); return (ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_OK)); } diff --git a/src/LuaEngineNtop.cpp b/src/LuaEngineNtop.cpp index ce5a7806d8..47d59424bb 100644 --- a/src/LuaEngineNtop.cpp +++ b/src/LuaEngineNtop.cpp @@ -7583,6 +7583,14 @@ static int ntop_force_run_daily_activities(lua_State *vm) { /* **************************************************************** */ +static int ntop_toggle_new_delete_trace(lua_State *vm) { + trace_new_delete = !trace_new_delete; + lua_pushboolean(vm, trace_new_delete); + return (ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_OK)); +} + +/* **************************************************************** */ + static luaL_Reg _ntop_reg[] = { {"getDirs", ntop_get_dirs}, {"getInfo", ntop_get_info}, @@ -8014,6 +8022,7 @@ static luaL_Reg _ntop_reg[] = { /* Debug */ {"forceRunDailyActivities", ntop_force_run_daily_activities }, + {"toggleNewDeleteTrace", ntop_toggle_new_delete_trace }, {NULL, NULL} }; diff --git a/src/MDNS.cpp b/src/MDNS.cpp index 27b3436f55..d2b44c55e8 100644 --- a/src/MDNS.cpp +++ b/src/MDNS.cpp @@ -34,6 +34,8 @@ static void *resolverCheckFctn(void *ptr) { /* ******************************* */ MDNS::MDNS(NetworkInterface *iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + if (((udp_sock = Utils::openSocket(AF_INET, SOCK_DGRAM, 0, "MDNS UDP")) == -1) || ((batch_udp_sock = @@ -49,6 +51,7 @@ MDNS::MDNS(NetworkInterface *iface) { /* ******************************* */ MDNS::~MDNS() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); Utils::closeSocket(udp_sock); Utils::closeSocket(batch_udp_sock); diff --git a/src/Mac.cpp b/src/Mac.cpp index 00fea682b2..040050d043 100644 --- a/src/Mac.cpp +++ b/src/Mac.cpp @@ -25,6 +25,7 @@ Mac::Mac(NetworkInterface *_iface, u_int8_t _mac[6]) : GenericHashEntry(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memcpy(mac, _mac, 6); broadcast_mac = Utils::isBroadcastMac(mac); @@ -74,6 +75,8 @@ Mac::Mac(NetworkInterface *_iface, u_int8_t _mac[6]) /* *************************************** */ Mac::~Mac() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + /* Serialize Mac before shutdown */ if((!broadcast_mac) && (!special_mac)) dumpToRedis(); diff --git a/src/MacHash.cpp b/src/MacHash.cpp index 25e93178b0..f51247bc2e 100644 --- a/src/MacHash.cpp +++ b/src/MacHash.cpp @@ -26,7 +26,7 @@ MacHash::MacHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "MacHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/MacManufacturers.cpp b/src/MacManufacturers.cpp index 63aaf540e1..9069ad2042 100644 --- a/src/MacManufacturers.cpp +++ b/src/MacManufacturers.cpp @@ -31,6 +31,8 @@ /* *************************************** */ MacManufacturers::MacManufacturers(const char *home) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + snprintf(manufacturers_file, sizeof(manufacturers_file), "%s/other/%s", home ? home : "", "EtherOUI.txt"); ntop->fixPath(manufacturers_file); @@ -130,6 +132,8 @@ void MacManufacturers::init() { MacManufacturers::~MacManufacturers() { std::map::const_iterator it; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (it = mac_manufacturers.begin(); it != mac_manufacturers.end(); ++it) { free(it->second.manufacturer_name); free(it->second.short_name); diff --git a/src/MacStats.cpp b/src/MacStats.cpp index 3b3a2db4cf..52d721c032 100644 --- a/src/MacStats.cpp +++ b/src/MacStats.cpp @@ -24,6 +24,8 @@ /* *************************************** */ MacStats::MacStats(NetworkInterface* _iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + iface = _iface; arp_stats.sent.requests.reset(), arp_stats.sent.replies.reset(), arp_stats.rcvd.requests.reset(), arp_stats.rcvd.replies.reset(); diff --git a/src/MostVisitedList.cpp b/src/MostVisitedList.cpp index 598e4c1804..34217ff626 100644 --- a/src/MostVisitedList.cpp +++ b/src/MostVisitedList.cpp @@ -24,6 +24,7 @@ /* *************************************** */ MostVisitedList::MostVisitedList(u_int32_t _max_num_items) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); top_data = new (std::nothrow) FrequentStringItems(_max_num_items); old_data = shadow_old_data = NULL; max_num_items = _max_num_items; @@ -33,6 +34,7 @@ MostVisitedList::MostVisitedList(u_int32_t _max_num_items) { /* *************************************** */ MostVisitedList::~MostVisitedList() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (top_data) delete (top_data); if (old_data) free(old_data); if (shadow_old_data) free(shadow_old_data); diff --git a/src/Mutex.cpp b/src/Mutex.cpp index 8d4c290a28..8ce48a5673 100644 --- a/src/Mutex.cpp +++ b/src/Mutex.cpp @@ -24,6 +24,8 @@ /* ******************************* */ Mutex::Mutex() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + pthread_mutex_init(&the_mutex, NULL); locked = false; #ifdef MUTEX_DEBUG diff --git a/src/MySQLDB.cpp b/src/MySQLDB.cpp index decc9c1657..a06170058f 100644 --- a/src/MySQLDB.cpp +++ b/src/MySQLDB.cpp @@ -506,6 +506,7 @@ bool MySQLDB::createDBSchema() { /* ******************************************* */ MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); mysqlEnqueuedFlows = 0; log_fd = NULL; open_log(); @@ -517,6 +518,8 @@ MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) { /* ******************************************* */ MySQLDB::~MySQLDB() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + shutdown(); disconnectFromDB(&mysql); diff --git a/src/NetworkDiscovery.cpp b/src/NetworkDiscovery.cpp index fe8a5aa070..00ecb48ba4 100644 --- a/src/NetworkDiscovery.cpp +++ b/src/NetworkDiscovery.cpp @@ -27,6 +27,8 @@ NetworkDiscovery::NetworkDiscovery(NetworkInterface *_iface) { char errbuf[PCAP_ERRBUF_SIZE]; const char *ifname; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + iface = _iface; ifname = iface->altDiscoverableName(); @@ -90,6 +92,8 @@ NetworkDiscovery::NetworkDiscovery(NetworkInterface *_iface) { /* ******************************* */ NetworkDiscovery::~NetworkDiscovery() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (pd) pcap_close(pd); Utils::closeSocket(udp_sock); diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index 7617b6a90a..f1ceab7c1c 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -41,6 +41,7 @@ static bool help_printed = false; /* Method used for collateral activities */ NetworkInterface::NetworkInterface() : NetworkInterfaceAlertableEntity(this, alert_entity_interface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); init(NULL); } @@ -48,11 +49,13 @@ NetworkInterface::NetworkInterface() NetworkInterface::NetworkInterface(const char *name, const char *custom_interface_type) - : NetworkInterfaceAlertableEntity(this, alert_entity_interface) { + : NetworkInterfaceAlertableEntity(this, alert_entity_interface) { char _ifname[MAX_INTERFACE_NAME_LEN], buf[MAX_INTERFACE_NAME_LEN]; /* We need to do it as isView() is not yet initialized */ char pcap_error_buffer[PCAP_ERRBUF_SIZE]; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + if (name == NULL) { if (!help_printed) ntop->getTrace()->traceEvent(TRACE_WARNING, @@ -944,6 +947,8 @@ NetworkInterface::~NetworkInterface() { std::map,InterfaceMemberAlertableEntity *>::iterator it; std::map::iterator it_o; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + #ifdef INTERFACE_PROFILING u_int64_t n = ethStats.getNumIngressPackets(); if (isPacketInterface() && n > 0) { @@ -7287,7 +7292,7 @@ void NetworkInterface::sumStats(TcpFlowStats *_tcpFlowStats, EthStats *_ethStats /* *************************************** */ -void NetworkInterface::lua(lua_State *vm) { +void NetworkInterface::lua(lua_State *vm, bool fullStats) { char buf[32]; TcpFlowStats _tcpFlowStats; EthStats _ethStats; @@ -7312,8 +7317,7 @@ void NetworkInterface::lua(lua_State *vm) { lua_push_str_table_entry(vm, "customIftype", (char *)customIftype); lua_push_bool_table_entry(vm, "isView", isView()); /* View interface */ lua_push_bool_table_entry(vm, "isViewed", isViewed()); /* Viewed interface */ - lua_push_bool_table_entry( - vm, "isSampledTraffic", + lua_push_bool_table_entry(vm, "isSampledTraffic", isSampledTraffic()); /* Whether this interface has sampled traffic */ if (isSubInterface()) luaSubInterface(vm); #ifdef NTOPNG_PRO @@ -7338,28 +7342,32 @@ void NetworkInterface::lua(lua_State *vm) { lua_push_bool_table_entry( vm, "has_traffic_directions", (areTrafficDirectionsSupported() || (!Utils::isEmptyMac(ifMac))) && (!isLoopback()) /* && (!isTrafficMirrored() || isGwMacConfigured())*/); - lua_push_bool_table_entry(vm, "has_seen_pods", hasSeenPods()); - lua_push_bool_table_entry(vm, "has_seen_containers", hasSeenContainers()); - lua_push_bool_table_entry(vm, "has_seen_external_alerts", - hasSeenExternalAlerts()); - lua_push_bool_table_entry(vm, "has_seen_ebpf_events", hasSeenEBPFEvents()); - - luaNumEngagedAlerts(vm); - luaAlertedFlows(vm); - lua_push_uint64_table_entry(vm, "num_dropped_alerts", - getNumDroppedAlertsSinceReset()); - - /* Those counters are absolute, i.e., they are not subject to reset */ - lua_push_uint64_table_entry(vm, "num_host_dropped_alerts", - num_host_dropped_alerts); - lua_push_uint64_table_entry(vm, "num_flow_dropped_alerts", - num_flow_dropped_alerts); - lua_push_uint64_table_entry(vm, "num_other_dropped_alerts", - num_other_dropped_alerts); - - lua_push_uint64_table_entry(vm, "periodic_stats_update_frequency_secs", - periodicStatsUpdateFrequency()); + if(fullStats) { + lua_push_bool_table_entry(vm, "has_seen_pods", hasSeenPods()); + lua_push_bool_table_entry(vm, "has_seen_containers", hasSeenContainers()); + lua_push_bool_table_entry(vm, "has_seen_external_alerts", + hasSeenExternalAlerts()); + lua_push_bool_table_entry(vm, "has_seen_ebpf_events", hasSeenEBPFEvents()); + + luaNumEngagedAlerts(vm); + luaAlertedFlows(vm); + + lua_push_uint64_table_entry(vm, "num_dropped_alerts", + getNumDroppedAlertsSinceReset()); + + /* Those counters are absolute, i.e., they are not subject to reset */ + lua_push_uint64_table_entry(vm, "num_host_dropped_alerts", + num_host_dropped_alerts); + lua_push_uint64_table_entry(vm, "num_flow_dropped_alerts", + num_flow_dropped_alerts); + lua_push_uint64_table_entry(vm, "num_other_dropped_alerts", + num_other_dropped_alerts); + + lua_push_uint64_table_entry(vm, "periodic_stats_update_frequency_secs", + periodicStatsUpdateFrequency()); + } + /* .stats */ lua_newtable(vm); lua_push_uint64_table_entry(vm, "packets", getNumPackets()); @@ -7383,10 +7391,13 @@ void NetworkInterface::lua(lua_State *vm) { lua_push_uint64_table_entry(vm, "throughput_trend_pps", pkts_thpt.getTrend()); l4Stats.luaStats(vm); - if (db) db->lua(vm, false /* Overall */); - - usedPorts.lua(vm, this); + if(fullStats) { + if (db) db->lua(vm, false /* Overall */); + + usedPorts.lua(vm, this); + } + lua_pushstring(vm, "stats"); lua_insert(vm, -2); lua_settable(vm, -3); @@ -7420,34 +7431,41 @@ void NetworkInterface::lua(lua_State *vm) { lua_push_uint64_table_entry(vm, "mtu", ifMTU); lua_push_str_table_entry(vm, "ip_addresses", (char *)getLocalIPAddresses()); - bcast_domains->lua(vm); - - if (top_sites && ntop->getPrefs()->are_top_talkers_enabled()) - top_sites->lua(vm, (char *)"sites", (char *)"sites.old"); - - luaAnomalies(vm); - luaScore(vm); + if(fullStats) { + bcast_domains->lua(vm); + + if (top_sites && ntop->getPrefs()->are_top_talkers_enabled()) + top_sites->lua(vm, (char *)"sites", (char *)"sites.old"); + luaAnomalies(vm); + luaScore(vm); + } + sumStats(&_tcpFlowStats, &_ethStats, &_localStats, NULL, &_pktStats, &_tcpPacketStats, &_discardedProbingStats, &_dscpStats, &_syslogStats, &_downloadStats, &_uploadStats); - _downloadStats.luaRTStats(vm, "download_stats"); - _uploadStats.luaRTStats(vm, "upload_stats"); - + if(fullStats) { + _downloadStats.luaRTStats(vm, "download_stats"); + _uploadStats.luaRTStats(vm, "upload_stats"); + } + _tcpFlowStats.lua(vm, "tcpFlowStats"); _ethStats.lua(vm); _localStats.lua(vm); luaNdpiStats(vm); - _pktStats.lua(vm, "pktSizeDistribution"); - _tcpPacketStats.lua(vm, "tcpPacketStats"); - _dscpStats.lua(this, vm); - _syslogStats.lua(vm); - - if (discardProbingTraffic()) - _discardedProbingStats.lua(vm, "discarded_probing_"); + if(fullStats) { + _pktStats.lua(vm, "pktSizeDistribution"); + _tcpPacketStats.lua(vm, "tcpPacketStats"); + + _dscpStats.lua(this, vm); + _syslogStats.lua(vm); + if (discardProbingTraffic()) + _discardedProbingStats.lua(vm, "discarded_probing_"); + } + if (!isView()) { #ifdef NTOPNG_PRO #ifndef HAVE_NEDGE @@ -7456,18 +7474,20 @@ void NetworkInterface::lua(lua_State *vm) { #endif } - if (host_pools) host_pools->lua(vm); - + if(fullStats) { + if (host_pools) host_pools->lua(vm); + #ifdef NTOPNG_PRO - traffic_rx_behavior->luaBehavior(vm, "traffic_rx_behavior"); - traffic_tx_behavior->luaBehavior(vm, "traffic_tx_behavior"); - score_behavior->luaBehavior(vm, "score_behavior"); - - if (custom_app_stats) custom_app_stats->lua(vm); - - if (pMap) pMap->lua(vm, "periodicity_map"); - if (sMap) sMap->lua(vm, "service_map"); + traffic_rx_behavior->luaBehavior(vm, "traffic_rx_behavior"); + traffic_tx_behavior->luaBehavior(vm, "traffic_tx_behavior"); + score_behavior->luaBehavior(vm, "score_behavior"); + + if (custom_app_stats) custom_app_stats->lua(vm); + + if (pMap) pMap->lua(vm, "periodicity_map"); + if (sMap) sMap->lua(vm, "service_map"); #endif + } } /* *************************************** */ diff --git a/src/NetworkStats.cpp b/src/NetworkStats.cpp index d92814cf85..8a6338100f 100644 --- a/src/NetworkStats.cpp +++ b/src/NetworkStats.cpp @@ -28,6 +28,9 @@ NetworkStats::NetworkStats(NetworkInterface *iface, u_int16_t _network_id) GenericTrafficElement(), Score(iface) { const char *netname; + + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + network_id = _network_id; numHosts = 0, alerted_flows_as_client = alerted_flows_as_server = 0; syn_recvd_last_min = synack_sent_last_min = 0; @@ -85,6 +88,8 @@ bool NetworkStats::match(AddressTree *tree) { } NetworkStats::~NetworkStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + #ifdef NTOPNG_PRO if (network_matrix) free(network_matrix); /* if (score_behavior) delete (score_behavior); diff --git a/src/Ntop.cpp b/src/Ntop.cpp index 9546881c82..ce8f47ad7e 100644 --- a/src/Ntop.cpp +++ b/src/Ntop.cpp @@ -46,6 +46,8 @@ extern struct keyval string_to_replace[]; /* LuaEngine.cpp */ /* ******************************************* */ Ntop::Ntop(const char *appName) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + // WTF: it's weird why do you want a global instance of ntop. ntop = this; globals = new (std::nothrow) NtopGlobals(); @@ -287,6 +289,8 @@ void Ntop::initTimezone() { Ntop::~Ntop() { int num_local_networks = local_network_tree.getNumAddresses(); + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (int i = 0; i < num_local_networks; i++) { if (local_network_names[i] != NULL) free(local_network_names[i]); if (local_network_aliases[i] != NULL) free(local_network_aliases[i]); diff --git a/src/NtopGlobals.cpp b/src/NtopGlobals.cpp index eadf09e20b..b0282d6bd6 100644 --- a/src/NtopGlobals.cpp +++ b/src/NtopGlobals.cpp @@ -24,6 +24,8 @@ /* **************************************** */ NtopGlobals::NtopGlobals() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + start_time = time(NULL); file_id = 0; trace = new (std::nothrow) Trace(); @@ -33,6 +35,8 @@ NtopGlobals::NtopGlobals() { /* **************************************** */ NtopGlobals::~NtopGlobals() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (trace) { delete trace; trace = NULL; diff --git a/src/ObservationPoint.cpp b/src/ObservationPoint.cpp index 5ab2ae9756..4015768ee0 100644 --- a/src/ObservationPoint.cpp +++ b/src/ObservationPoint.cpp @@ -29,6 +29,8 @@ ObservationPoint::ObservationPoint(NetworkInterface* _iface, GenericTrafficElement(), Score(_iface), dirstats(_iface, 0) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + obs_point = _obs_point; num_flows = 0; delete_requested = false; diff --git a/src/ObservationPointHash.cpp b/src/ObservationPointHash.cpp index 625a231a2f..0d1975c22c 100644 --- a/src/ObservationPointHash.cpp +++ b/src/ObservationPointHash.cpp @@ -27,7 +27,7 @@ ObservationPointHash::ObservationPointHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "ObservationPointHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/OperatingSystem.cpp b/src/OperatingSystem.cpp index 000f12f4c3..d21195aee3 100644 --- a/src/OperatingSystem.cpp +++ b/src/OperatingSystem.cpp @@ -26,7 +26,8 @@ /* *************************************** */ OperatingSystem::OperatingSystem(NetworkInterface* _iface, OSType _os_type) - : GenericHashEntry(_iface), GenericTrafficElement() { + : GenericHashEntry(_iface), GenericTrafficElement() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); os_type = _os_type; #ifdef AS_DEBUG diff --git a/src/OperatingSystemHash.cpp b/src/OperatingSystemHash.cpp index be43335530..e6167feef8 100644 --- a/src/OperatingSystemHash.cpp +++ b/src/OperatingSystemHash.cpp @@ -27,7 +27,7 @@ OperatingSystemHash::OperatingSystemHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "OperatingSystemHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/OtherAlertableEntity.cpp b/src/OtherAlertableEntity.cpp index 513e56cf90..0598f3cd47 100644 --- a/src/OtherAlertableEntity.cpp +++ b/src/OtherAlertableEntity.cpp @@ -25,7 +25,9 @@ OtherAlertableEntity::OtherAlertableEntity(NetworkInterface *iface, AlertEntity entity) - : AlertableEntity(iface, entity) {} + : AlertableEntity(iface, entity) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); +} /* ****************************************** */ diff --git a/src/PF_RINGInterface.cpp b/src/PF_RINGInterface.cpp index a1ebad45f0..ad1b178135 100644 --- a/src/PF_RINGInterface.cpp +++ b/src/PF_RINGInterface.cpp @@ -130,10 +130,12 @@ pfring *PF_RINGInterface::pfringSocketInit(const char *name) { /* **************************************************** */ PF_RINGInterface::PF_RINGInterface(const char *_name) - : NetworkInterface(_name) { + : NetworkInterface(_name) { char name[MAX_INTERFACE_NAME_LEN]; int err; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_pfring_handles = 0; pcap_datalink_type = DLT_EN10MB; dropped_packets = 0; @@ -184,6 +186,7 @@ PF_RINGInterface::PF_RINGInterface(const char *_name) PF_RINGInterface::~PF_RINGInterface() { int i; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); shutdown(); for (i = 0; i < num_pfring_handles; i++) { diff --git a/src/PacketDumper.cpp b/src/PacketDumper.cpp index 82df041d93..d39f265b69 100644 --- a/src/PacketDumper.cpp +++ b/src/PacketDumper.cpp @@ -24,6 +24,7 @@ /* ********************************************* */ PacketDumper::PacketDumper(NetworkInterface *i, const char *path) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); init(i); out_path = strdup(path); } diff --git a/src/PacketDumperTuntap.cpp b/src/PacketDumperTuntap.cpp index 63ddcee8c8..e5be1ac31b 100644 --- a/src/PacketDumperTuntap.cpp +++ b/src/PacketDumperTuntap.cpp @@ -30,9 +30,11 @@ /* ********************************************* */ PacketDumperTuntap::PacketDumperTuntap(NetworkInterface *i) { - char *name = i->get_name(); - + char *name = i->get_name(); int ret = openTap(NULL, DUMP_MTU); + + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + if (ret < 0) { ntop->getTrace()->traceEvent(TRACE_ERROR, "Opening tap (%s) failed", name); init_ok = false; diff --git a/src/PacketStats.cpp b/src/PacketStats.cpp index 2e928c66b5..a910023859 100644 --- a/src/PacketStats.cpp +++ b/src/PacketStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -PacketStats::PacketStats() { resetStats(); } +PacketStats::PacketStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + resetStats(); +} /* *************************************** */ diff --git a/src/Paginator.cpp b/src/Paginator.cpp index 4e46ef3084..f0d4c338d6 100644 --- a/src/Paginator.cpp +++ b/src/Paginator.cpp @@ -24,6 +24,8 @@ /* **************************************************** */ Paginator::Paginator() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + /* char* */ sort_column = strdup("column_thpt"); country_filter = NULL; diff --git a/src/ParsedFlow.cpp b/src/ParsedFlow.cpp index 57565bd6fe..ff6de8f073 100644 --- a/src/ParsedFlow.cpp +++ b/src/ParsedFlow.cpp @@ -24,6 +24,8 @@ /* *************************************** */ ParsedFlow::ParsedFlow() : ParsedFlowCore(), ParsedeBPF() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + additional_fields_json = NULL; additional_fields_tlv = NULL; l7_info = NULL; diff --git a/src/ParsedFlowCore.cpp b/src/ParsedFlowCore.cpp index 026aca1e5e..e1b459905d 100644 --- a/src/ParsedFlowCore.cpp +++ b/src/ParsedFlowCore.cpp @@ -24,6 +24,8 @@ /* *************************************** */ ParsedFlowCore::ParsedFlowCore() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + src_ip.reset(), dst_ip.reset(); memset(&src_mac, 0, sizeof(src_mac)); memset(&dst_mac, 0, sizeof(dst_mac)); diff --git a/src/ParsedeBPF.cpp b/src/ParsedeBPF.cpp index c9a81d327f..cfde4c6bb5 100644 --- a/src/ParsedeBPF.cpp +++ b/src/ParsedeBPF.cpp @@ -24,6 +24,8 @@ /* *************************************** */ ParsedeBPF::ParsedeBPF() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ifname = NULL; event_type = ebpf_event_type_unknown; diff --git a/src/ParserInterface.cpp b/src/ParserInterface.cpp index 13bdd164d9..96d6218878 100644 --- a/src/ParserInterface.cpp +++ b/src/ParserInterface.cpp @@ -28,6 +28,8 @@ ParserInterface::ParserInterface(const char *endpoint, const char *custom_interface_type) : NetworkInterface(endpoint, custom_interface_type) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_companion_interfaces = 0; companion_interfaces = new (std::nothrow) NetworkInterface *[MAX_NUM_COMPANION_INTERFACES](); diff --git a/src/PartializableFlowTrafficStats.cpp b/src/PartializableFlowTrafficStats.cpp index 9bada646f4..4317e78386 100644 --- a/src/PartializableFlowTrafficStats.cpp +++ b/src/PartializableFlowTrafficStats.cpp @@ -24,6 +24,8 @@ /* *************************************** */ PartializableFlowTrafficStats::PartializableFlowTrafficStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ndpiDetectedProtocol = Flow::ndpiUnknownProtocol; cli2srv_packets = srv2cli_packets = 0; cli2srv_bytes = srv2cli_bytes = 0; diff --git a/src/PcapInterface.cpp b/src/PcapInterface.cpp index afbfac7abc..dd1879a4e6 100644 --- a/src/PcapInterface.cpp +++ b/src/PcapInterface.cpp @@ -37,6 +37,7 @@ PcapInterface::PcapInterface(const char *name, u_int8_t ifIdx, char pcap_error_buffer[PCAP_ERRBUF_SIZE]; struct stat buf; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); delete_pcap_when_done = _delete_pcap_when_done; memset(pcap_handle, 0, sizeof(pcap_handle)); memset(pcap_ifaces, 0, sizeof(pcap_ifaces)); diff --git a/src/PeriodicActivities.cpp b/src/PeriodicActivities.cpp index 4533b778f0..9cd310a05d 100644 --- a/src/PeriodicActivities.cpp +++ b/src/PeriodicActivities.cpp @@ -44,6 +44,8 @@ static activity_descr ad[] = { /* ******************************************* */ PeriodicActivities::PeriodicActivities() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_activities = 0; memset(activities, 0, sizeof(activities)); @@ -55,6 +57,8 @@ PeriodicActivities::PeriodicActivities() { /* ******************************************* */ PeriodicActivities::~PeriodicActivities() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + delete th_pool; /* Now it's safe to delete the activities as no other thread is executing diff --git a/src/PeriodicScript.cpp b/src/PeriodicScript.cpp index f47009466e..1e71766eb5 100644 --- a/src/PeriodicScript.cpp +++ b/src/PeriodicScript.cpp @@ -30,6 +30,7 @@ PeriodicScript::PeriodicScript(const char* _path, bool _exclude_viewed_interfaces, bool _exclude_pcap_dump_interfaces, ThreadPool* _pool) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); path = strdup(_path); periodicity = _periodicity_seconds; max_duration_secs = _max_duration_seconds; @@ -42,5 +43,6 @@ PeriodicScript::PeriodicScript(const char* _path, /* ******************************************* */ PeriodicScript::~PeriodicScript() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); if (path) free((char*)path); } diff --git a/src/Ping.cpp b/src/Ping.cpp index 3191dfdc33..53d8ddff40 100644 --- a/src/Ping.cpp +++ b/src/Ping.cpp @@ -57,6 +57,8 @@ void Ping::setOpts(int fd) { /* ****************************************** */ Ping::Ping(char *_ifname) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ping_id = rand(), cnt = 0; running = false; @@ -148,6 +150,8 @@ Ping::Ping(char *_ifname) { /* ****************************************** */ Ping::~Ping() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + if (running) { running = false; pthread_join(resultPoller, NULL); diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 7a1369b8d4..e7b6c2d6e4 100644 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -37,6 +37,8 @@ extern "C" { /* ******************************************* */ Prefs::Prefs(Ntop *_ntop) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_deferred_interfaces_to_register = 0, cli = NULL; ntop = _ntop, pcap_file_purge_hosts_flows = false, ignore_vlans = false, simulate_vlans = false, simulate_macs = false, ignore_macs = false; diff --git a/src/ProtoCounter.cpp b/src/ProtoCounter.cpp index 20a0187e83..247cf9f041 100644 --- a/src/ProtoCounter.cpp +++ b/src/ProtoCounter.cpp @@ -25,6 +25,7 @@ ProtoCounter::ProtoCounter(u_int16_t _proto_id, bool enable_throughput_stats, bool enable_behavior_stats) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); proto_id = _proto_id; duration = last_epoch_update = total_flows = 0; diff --git a/src/ProtoStats.cpp b/src/ProtoStats.cpp index 2dbd844f3f..fbd30f56c9 100644 --- a/src/ProtoStats.cpp +++ b/src/ProtoStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -ProtoStats::ProtoStats() { reset(); } +ProtoStats::ProtoStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + reset(); +} /* *************************************** */ diff --git a/src/RRDTimeseriesExporter.cpp b/src/RRDTimeseriesExporter.cpp index 7040bf1f85..3066ab031d 100644 --- a/src/RRDTimeseriesExporter.cpp +++ b/src/RRDTimeseriesExporter.cpp @@ -24,7 +24,8 @@ /* ******************************************************* */ RRDTimeseriesExporter::RRDTimeseriesExporter(NetworkInterface* _if) - : TimeseriesExporter(_if) { + : TimeseriesExporter(_if) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); ts_queue = new (std::nothrow) StringFifoQueue(MAX_RRD_QUEUE_LEN); } diff --git a/src/Radius.cpp b/src/Radius.cpp index 60d0928897..e7e5658fa6 100644 --- a/src/Radius.cpp +++ b/src/Radius.cpp @@ -31,6 +31,8 @@ Radius::Radius(bool _use_chap) { https://it.wikipedia.org/wiki/Password_authentication_protocol https://en.wikipedia.org/wiki/Challenge-Handshake_Authentication_Protocol */ + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + result = 0, use_chap = _use_chap; /* true = CHAP, false = PAP */ radiusAuthServer = radiusAcctServer = radiusSecret = radiusAdminGroup = radiusUnprivCapabilitiesGroup = NULL; diff --git a/src/RecipientQueue.cpp b/src/RecipientQueue.cpp index a7073484e9..772ef28472 100644 --- a/src/RecipientQueue.cpp +++ b/src/RecipientQueue.cpp @@ -26,6 +26,8 @@ /* *************************************** */ RecipientQueue::RecipientQueue(u_int16_t _recipient_id) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + recipient_id = _recipient_id; queue = NULL, drops = 0, uses = 0; last_use = 0; diff --git a/src/Recipients.cpp b/src/Recipients.cpp index 5e190b74af..72e5c175c8 100644 --- a/src/Recipients.cpp +++ b/src/Recipients.cpp @@ -24,6 +24,8 @@ /* *************************************** */ Recipients::Recipients() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + memset(&recipient_queues, 0, sizeof(recipient_queues)); default_recipient_minimum_severity = alert_level_none; } diff --git a/src/Redis.cpp b/src/Redis.cpp index 3747060e29..42efed80f2 100644 --- a/src/Redis.cpp +++ b/src/Redis.cpp @@ -28,6 +28,8 @@ Redis::Redis(const char *_redis_host, const char *_redis_password, u_int16_t _redis_port, u_int8_t _redis_db_id, bool giveup_on_failure) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + redis_host = _redis_host ? strdup(_redis_host) : NULL; redis_password = _redis_password ? strdup(_redis_password) : NULL; redis_port = _redis_port, redis_db_id = _redis_db_id; diff --git a/src/RemoteHost.cpp b/src/RemoteHost.cpp index 527709e03a..079c47e161 100644 --- a/src/RemoteHost.cpp +++ b/src/RemoteHost.cpp @@ -27,6 +27,8 @@ RemoteHost::RemoteHost(NetworkInterface *_iface, int32_t _iface_idx, Mac *_mac, u_int16_t _u_int16_t, u_int16_t _observation_point_id, IpAddress *_ip) : Host(_iface, _iface_idx, _mac, _u_int16_t, _observation_point_id, _ip) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + #ifdef REMOTEHOST_DEBUG char buf[48]; ntop->getTrace()->traceEvent(TRACE_NORMAL, "Instantiating REMOTE host %s", diff --git a/src/RoundTripStats.cpp b/src/RoundTripStats.cpp index 3e4130c74b..5bd152af36 100644 --- a/src/RoundTripStats.cpp +++ b/src/RoundTripStats.cpp @@ -24,6 +24,8 @@ /* **************************************** */ RoundTripStats::RoundTripStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + stats_it = ROUND_TRIP_LENGTH - 1; /* Last Item */ memset(stats, 0, sizeof(stats)); } diff --git a/src/RwLock.cpp b/src/RwLock.cpp index ccec7f49ef..16620b914a 100644 --- a/src/RwLock.cpp +++ b/src/RwLock.cpp @@ -31,6 +31,7 @@ RwLock::RwLock() { #else pthread_rwlock_init(&the_rwlock, NULL); #endif + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ******************************* */ diff --git a/src/SNMP.cpp b/src/SNMP.cpp index a9950ccdf7..de225cc431 100644 --- a/src/SNMP.cpp +++ b/src/SNMP.cpp @@ -43,6 +43,7 @@ SNMPSession::~SNMPSession() { /* ******************************* */ SNMP::SNMP() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); batch_mode = false; #ifdef HAVE_LIBSNMP init_snmp("ntopng"); diff --git a/src/SQLiteAlertStore.cpp b/src/SQLiteAlertStore.cpp index 166f0a4c3d..558a3eb740 100644 --- a/src/SQLiteAlertStore.cpp +++ b/src/SQLiteAlertStore.cpp @@ -27,6 +27,7 @@ SQLiteAlertStore::SQLiteAlertStore(int interface_id, const char *filename) : SQLiteStoreManager(interface_id) { char filePath[MAX_PATH + 256]; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); /* Create the directories needed to keep the alerts database */ snprintf(filePath, sizeof(filePath), "%s/%d/alerts/", ntop->get_working_dir(), ifid); diff --git a/src/SQLiteStoreManager.cpp b/src/SQLiteStoreManager.cpp index de77fcf56f..a0f2f9c06d 100644 --- a/src/SQLiteStoreManager.cpp +++ b/src/SQLiteStoreManager.cpp @@ -24,6 +24,8 @@ /* **************************************************** */ SQLiteStoreManager::SQLiteStoreManager(int interface_id) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + ifid = interface_id; iface = ntop->getInterfaceById(interface_id); db = NULL; diff --git a/src/Score.cpp b/src/Score.cpp index 78d3f8e0a3..0efa73de3b 100644 --- a/src/Score.cpp +++ b/src/Score.cpp @@ -24,6 +24,8 @@ /* ***************************************************** */ Score::Score(NetworkInterface *_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + view_interface_score = _iface->isView(); score = NULL; } diff --git a/src/ScoreStats.cpp b/src/ScoreStats.cpp index c805e7a317..da9245efa9 100644 --- a/src/ScoreStats.cpp +++ b/src/ScoreStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ ScoreStats::ScoreStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(&cli_score, 0, sizeof(cli_score)), memset(&srv_score, 0, sizeof(srv_score)); } diff --git a/src/StatsManager.cpp b/src/StatsManager.cpp index 3daee23f83..881bded84a 100644 --- a/src/StatsManager.cpp +++ b/src/StatsManager.cpp @@ -30,6 +30,8 @@ StatsManager::StatsManager(int interface_id, const char *filename) char filePath[MAX_PATH + 16], fileFullPath[MAX_PATH + 162], fileName[MAX_PATH + 16]; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + MINUTE_CACHE_NAME = "MINUTE_STATS"; HOUR_CACHE_NAME = "HOUR_STATS"; DAY_CACHE_NAME = "DAY_STATS"; diff --git a/src/SyslogCollectorInterface.cpp b/src/SyslogCollectorInterface.cpp index 7e6d47c858..6556947150 100644 --- a/src/SyslogCollectorInterface.cpp +++ b/src/SyslogCollectorInterface.cpp @@ -31,10 +31,11 @@ bool SyslogCollectorInterface::openSocket(syslog_socket *ss, struct sockaddr_in listen_addr; int reuse = 1; - ntop->getTrace()->traceEvent( - TRACE_NORMAL, "Starting %s syslog collector on %s:%d", - protocol == SOCK_DGRAM ? "UDP" : "TCP", server_address, server_port); - + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + + ntop->getTrace()->traceEvent(TRACE_NORMAL, "Starting %s syslog collector on %s:%d", + protocol == SOCK_DGRAM ? "UDP" : "TCP", server_address, server_port); + ss->sock = Utils::openSocket(AF_INET, protocol, 0, "SyslogCollectorInterface"); @@ -532,8 +533,8 @@ bool SyslogCollectorInterface::set_packet_filter(char *filter) { /* **************************************************** */ -void SyslogCollectorInterface::lua(lua_State *vm) { - SyslogParserInterface::lua(vm); +void SyslogCollectorInterface::lua(lua_State *vm, bool fullStats) { + SyslogParserInterface::lua(vm, fullStats); lua_push_bool_table_entry(vm, "isSyslog", true); diff --git a/src/SyslogDump.cpp b/src/SyslogDump.cpp index 2c1604fa7f..0aa7c5c4de 100644 --- a/src/SyslogDump.cpp +++ b/src/SyslogDump.cpp @@ -30,6 +30,8 @@ /* **************************************** */ SyslogDump::SyslogDump(NetworkInterface *_iface) : DB(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + openlog(NULL /* If ident is NULL, the program name is used */, LOG_PID /* Include PID with each message */ | LOG_CONS /* Write directly to system console if there is an diff --git a/src/SyslogLuaEngine.cpp b/src/SyslogLuaEngine.cpp index fcbdd87961..55c8f13287 100644 --- a/src/SyslogLuaEngine.cpp +++ b/src/SyslogLuaEngine.cpp @@ -24,6 +24,8 @@ /* ****************************************** */ SyslogLuaEngine::SyslogLuaEngine(NetworkInterface *iface) : LuaEngine(NULL) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + initialized = false; snprintf(script_path, sizeof(script_path), "%s/%s", diff --git a/src/SyslogParserInterface.cpp b/src/SyslogParserInterface.cpp index fde24647ec..4f1a1492fb 100644 --- a/src/SyslogParserInterface.cpp +++ b/src/SyslogParserInterface.cpp @@ -30,6 +30,7 @@ SyslogParserInterface::SyslogParserInterface(const char *endpoint, const char *custom_interface_type) : ParserInterface(endpoint, custom_interface_type) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); le = NULL; producers_reload_requested = true; } @@ -201,7 +202,9 @@ exit: /* **************************************************** */ -void SyslogParserInterface::lua(lua_State *vm) { NetworkInterface::lua(vm); } +void SyslogParserInterface::lua(lua_State *vm, bool fullStats) { + NetworkInterface::lua(vm, fullStats); +} /* **************************************************** */ diff --git a/src/SyslogStats.cpp b/src/SyslogStats.cpp index c124d26ed5..9aff9d19d8 100644 --- a/src/SyslogStats.cpp +++ b/src/SyslogStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -SyslogStats::SyslogStats() { resetStats(); } +SyslogStats::SyslogStats() { + //if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + resetStats(); +} /* *************************************** */ diff --git a/src/TcpFlowStats.cpp b/src/TcpFlowStats.cpp index 2e00c1a1b5..1436211807 100644 --- a/src/TcpFlowStats.cpp +++ b/src/TcpFlowStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ TcpFlowStats::TcpFlowStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); numSynFlows = numEstablishedFlows = numResetFlows = numFinFlows = 0; } diff --git a/src/TcpPacketStats.cpp b/src/TcpPacketStats.cpp index 54a4572f77..4cb50d8dbb 100644 --- a/src/TcpPacketStats.cpp +++ b/src/TcpPacketStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ TcpPacketStats::TcpPacketStats() { + //if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); pktRetr = pktOOO = pktLost = pktKeepAlive = 0; } diff --git a/src/ThreadPool.cpp b/src/ThreadPool.cpp index 613ed5ed9a..2dcb461425 100644 --- a/src/ThreadPool.cpp +++ b/src/ThreadPool.cpp @@ -36,6 +36,7 @@ static void *doRun(void *ptr) { /* **************************************************** */ ThreadPool::ThreadPool(char *comma_separated_affinity_mask) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); m = new (std::nothrow) Mutex(); pthread_cond_init(&condvar, NULL); terminating = false; diff --git a/src/ThreadedActivity.cpp b/src/ThreadedActivity.cpp index 12e4fe01f4..31d4f37aa7 100644 --- a/src/ThreadedActivity.cpp +++ b/src/ThreadedActivity.cpp @@ -32,9 +32,9 @@ ThreadedActivity::ThreadedActivity(const char *_path, bool delayed_activity, bool _exclude_viewed_interfaces, bool _exclude_pcap_dump_interfaces, ThreadPool *_pool) { - periodic_script = new (std::nothrow) PeriodicScript( - _path, _periodicity_seconds, _max_duration_seconds, _align_to_localtime, - _exclude_viewed_interfaces, _exclude_pcap_dump_interfaces, _pool); + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + periodic_script = new (std::nothrow) PeriodicScript(_path, _periodicity_seconds, _max_duration_seconds, _align_to_localtime, + _exclude_viewed_interfaces, _exclude_pcap_dump_interfaces, _pool); randomDelaySchedule = delayed_activity; setDeadlineApproachingSecs(); force_run = false; diff --git a/src/ThreadedActivityStats.cpp b/src/ThreadedActivityStats.cpp index 86355aa758..001242506f 100644 --- a/src/ThreadedActivityStats.cpp +++ b/src/ThreadedActivityStats.cpp @@ -26,6 +26,7 @@ ticks ThreadedActivityStats::tickspersec = Utils::gettickspersec(); /* ******************************************* */ ThreadedActivityStats::ThreadedActivityStats(const ThreadedActivity *ta) { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(&ta_stats, 0, sizeof(ta_stats)); last_start_time = in_progress_since = 0; last_queued_time = deadline = scheduled_time = 0; diff --git a/src/ThroughputStats.cpp b/src/ThroughputStats.cpp index 5e917350ec..bec1ede49e 100644 --- a/src/ThroughputStats.cpp +++ b/src/ThroughputStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -ThroughputStats::ThroughputStats() { resetStats(); } +ThroughputStats::ThroughputStats() { + // if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + resetStats(); +} /* *************************************** */ diff --git a/src/TimelineExtract.cpp b/src/TimelineExtract.cpp index 9c472df657..9f85fbceab 100644 --- a/src/TimelineExtract.cpp +++ b/src/TimelineExtract.cpp @@ -24,6 +24,8 @@ /* ********************************************* */ TimelineExtract::TimelineExtract() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + extraction.id = 0; status_code = 0; running = false; diff --git a/src/TimeseriesExporter.cpp b/src/TimeseriesExporter.cpp index 23189b1863..952face180 100644 --- a/src/TimeseriesExporter.cpp +++ b/src/TimeseriesExporter.cpp @@ -23,7 +23,10 @@ /* ******************************************************* */ -TimeseriesExporter::TimeseriesExporter(NetworkInterface *_if) { iface = _if; } +TimeseriesExporter::TimeseriesExporter(NetworkInterface *_if) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + iface = _if; +} /* ******************************************************* */ diff --git a/src/Trace.cpp b/src/Trace.cpp index 62a689f965..fcab68aac7 100644 --- a/src/Trace.cpp +++ b/src/Trace.cpp @@ -24,6 +24,7 @@ /* ******************************* */ Trace::Trace() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); traceLevel = TRACE_LEVEL_NORMAL; logFile = NULL; logFd = NULL; diff --git a/src/TrafficStats.cpp b/src/TrafficStats.cpp index 1216f4b993..002016cdbd 100644 --- a/src/TrafficStats.cpp +++ b/src/TrafficStats.cpp @@ -23,7 +23,10 @@ /* *************************************** */ -TrafficStats::TrafficStats() { numPkts.reset(), numBytes.reset(); } +TrafficStats::TrafficStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + numPkts.reset(), numBytes.reset(); +} /* *************************************** */ diff --git a/src/UsedPorts.cpp b/src/UsedPorts.cpp index ae49f029d6..04b26118c1 100644 --- a/src/UsedPorts.cpp +++ b/src/UsedPorts.cpp @@ -23,7 +23,9 @@ /* *************************************** */ -UsedPorts::UsedPorts() { ; } +UsedPorts::UsedPorts() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); +} /* *************************************** */ diff --git a/src/VLAN.cpp b/src/VLAN.cpp index a16b075a9c..3f1e39fed0 100644 --- a/src/VLAN.cpp +++ b/src/VLAN.cpp @@ -25,6 +25,7 @@ VLAN::VLAN(NetworkInterface* _iface, u_int16_t _vlan_id) : GenericHashEntry(_iface), GenericTrafficElement(), Score(_iface) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); vlan_id = _vlan_id; #ifdef VLAN_DEBUG diff --git a/src/VLANAddressTree.cpp b/src/VLANAddressTree.cpp index d545c56dfb..b2b366d662 100644 --- a/src/VLANAddressTree.cpp +++ b/src/VLANAddressTree.cpp @@ -24,6 +24,7 @@ /* **************************************** */ VLANAddressTree::VLANAddressTree(ndpi_void_fn_t data_free_func) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); free_func = data_free_func; tree = new (std::nothrow) AddressTree *[MAX_NUM_VLAN]; memset(tree, 0, sizeof(AddressTree *) * MAX_NUM_VLAN); diff --git a/src/VLANHash.cpp b/src/VLANHash.cpp index 337192a4a1..fc49a3e5a4 100644 --- a/src/VLANHash.cpp +++ b/src/VLANHash.cpp @@ -26,7 +26,7 @@ VLANHash::VLANHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "VLANHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* ************************************ */ diff --git a/src/ViewInterface.cpp b/src/ViewInterface.cpp index 7cb0b9ffd5..41181f0722 100644 --- a/src/ViewInterface.cpp +++ b/src/ViewInterface.cpp @@ -27,6 +27,7 @@ ViewInterface::ViewInterface(const char *_endpoint) : NetworkInterface(_endpoint) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); is_view = true; /* This is a view interface */ is_packet_interface = true; diff --git a/src/ViewScoreStats.cpp b/src/ViewScoreStats.cpp index 7757b72536..7f53b2eaab 100644 --- a/src/ViewScoreStats.cpp +++ b/src/ViewScoreStats.cpp @@ -24,6 +24,7 @@ /* *************************************** */ ViewScoreStats::ViewScoreStats() : ScoreStats() { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); memset(&cli_dec, 0, sizeof(cli_dec)), memset(&srv_dec, 0, sizeof(srv_dec)); } diff --git a/src/VirtualHost.cpp b/src/VirtualHost.cpp index f867c19767..6910f07019 100644 --- a/src/VirtualHost.cpp +++ b/src/VirtualHost.cpp @@ -25,6 +25,7 @@ VirtualHost::VirtualHost(HostHash *_h, char *_name) : GenericHashEntry(_h->getInterface()) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); h = _h, name = strdup(_name), last_num_requests = 0, last_diff = 0, trend = trend_stable; vhost_key = Utils::hashString(name); diff --git a/src/VirtualHostHash.cpp b/src/VirtualHostHash.cpp index db1b20ef98..2361cf1bfc 100644 --- a/src/VirtualHostHash.cpp +++ b/src/VirtualHostHash.cpp @@ -26,7 +26,7 @@ VirtualHostHash::VirtualHostHash(NetworkInterface *_iface, u_int _num_hashes, u_int _max_hash_size) : GenericHash(_iface, _num_hashes, _max_hash_size, "VirtualHostHash") { - ; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); } /* *********************************************************** */ diff --git a/src/ZCCollectorInterface.cpp b/src/ZCCollectorInterface.cpp index 76929126aa..94733f6e7b 100644 --- a/src/ZCCollectorInterface.cpp +++ b/src/ZCCollectorInterface.cpp @@ -32,8 +32,9 @@ ZCCollectorInterface::ZCCollectorInterface(const char *name) char ifname[32]; char *at; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + cluster_id = queue_id = 0; - snprintf(ifname, sizeof(ifname), "%s", &name[7]); at = strchr(ifname, '@'); diff --git a/src/ZMQCollectorInterface.cpp b/src/ZMQCollectorInterface.cpp index 7cdee41d7e..d6527ce424 100644 --- a/src/ZMQCollectorInterface.cpp +++ b/src/ZMQCollectorInterface.cpp @@ -34,6 +34,8 @@ ZMQCollectorInterface::ZMQCollectorInterface(const char *_endpoint) : ZMQParserI char *tmp, *e, *t; const char **topics = Utils::getMessagingTopics(); + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + num_subscribers = 0; server_secret_key[0] = '\0'; server_public_key[0] = '\0'; @@ -661,8 +663,8 @@ bool ZMQCollectorInterface::set_packet_filter(char *filter) { /* **************************************************** */ -void ZMQCollectorInterface::lua(lua_State *vm) { - ZMQParserInterface::lua(vm); +void ZMQCollectorInterface::lua(lua_State *vm, bool fullStats) { + ZMQParserInterface::lua(vm, fullStats); lua_newtable(vm); lua_push_uint64_table_entry(vm, "flows", recvStats.num_flows); diff --git a/src/ZMQParserInterface.cpp b/src/ZMQParserInterface.cpp index 77e7b176b4..86a2cc3000 100644 --- a/src/ZMQParserInterface.cpp +++ b/src/ZMQParserInterface.cpp @@ -32,6 +32,8 @@ ZMQParserInterface::ZMQParserInterface(const char *endpoint, const char *custom_interface_type) : ParserInterface(endpoint, custom_interface_type) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + zmq_initial_bytes = 0, zmq_initial_pkts = 0; zmq_remote_stats = zmq_remote_stats_shadow = NULL; memset(&last_zmq_remote_stats_update, 0, @@ -3093,11 +3095,11 @@ bool ZMQParserInterface::getCustomAppDetails(u_int32_t remapped_app_id, /* **************************************************** */ -void ZMQParserInterface::lua(lua_State *vm) { +void ZMQParserInterface::lua(lua_State *vm, bool fullStats) { ZMQ_RemoteStats *zrs = zmq_remote_stats; std::map::iterator it; - NetworkInterface::lua(vm); + NetworkInterface::lua(vm, fullStats); /* ************************************* */ diff --git a/src/ZMQPublisher.cpp b/src/ZMQPublisher.cpp index 099f455845..8abcce07d1 100644 --- a/src/ZMQPublisher.cpp +++ b/src/ZMQPublisher.cpp @@ -20,7 +20,8 @@ * @param endpoint The ZMQ endpoint. */ ZMQPublisher::ZMQPublisher(char *endpoint) { - + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + server_secret_key[0] = '\0'; server_public_key[0] = '\0'; diff --git a/src/main.cpp b/src/main.cpp index 35b1481bbb..b1f5e587be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,8 @@ extern char *rrd_strversion(void); AfterShutdownAction afterShutdownAction = after_shutdown_nop; +bool trace_new_delete = false; + /* ******************************** */ void sighup(int sig) { ; } diff --git a/src/nDPIStats.cpp b/src/nDPIStats.cpp index 2e17c60d86..db425a839f 100644 --- a/src/nDPIStats.cpp +++ b/src/nDPIStats.cpp @@ -26,6 +26,8 @@ nDPIStats::nDPIStats(bool _enable_throughput_stats, bool _enable_behavior_stats) { + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + #ifdef NTOPNG_PRO nextMinPeriodicUpdate = 0; #endif @@ -38,6 +40,8 @@ nDPIStats::nDPIStats(bool _enable_throughput_stats, nDPIStats::nDPIStats(nDPIStats &stats) { std::unordered_map::iterator it; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); + #ifdef NTOPNG_PRO nextMinPeriodicUpdate = 0; #endif @@ -74,6 +78,8 @@ nDPIStats::nDPIStats(nDPIStats &stats) { nDPIStats::~nDPIStats() { std::unordered_map::iterator it; + if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[delete] %s", __FILE__); + for (it = counters.begin(); it != counters.end(); ++it) { ProtoCounter *c = it->second;