diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index fa0ba88cfc..e9c108b64f 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -110,11 +110,6 @@ class NetworkInterface { bool user_scripts_reload_inline, user_scripts_reload_periodic; lua_State *L_user_scripts_inline, *L_user_scripts_periodic; - /* Second update */ - u_int64_t lastSecTraffic, - lastMinuteTraffic[60], /* Delta bytes (per second) of the last minute */ - currentMinuteTraffic[60]; /* Delta bytes (per second) of the current minute */ - time_t lastSecUpdate; u_int nextFlowAggregation; TcpFlowStats tcpFlowStats; TcpPacketStats tcpPacketStats; @@ -277,10 +272,6 @@ class NetworkInterface { inline void incRetransmittedPkts(u_int32_t num) { tcpPacketStats.incRetr(num); }; inline void incOOOPkts(u_int32_t num) { tcpPacketStats.incOOO(num); }; inline void incLostPkts(u_int32_t num) { tcpPacketStats.incLost(num); }; - inline void resetSecondTraffic() { - memset(currentMinuteTraffic, 0, sizeof(currentMinuteTraffic)); lastSecTraffic = 0, lastSecUpdate = 0; - }; - void updateSecondTraffic(time_t when); void checkPointCounters(bool drops_only); u_int64_t getCheckPointNumPackets(); u_int64_t getCheckPointNumBytes(); @@ -291,7 +282,6 @@ class NetworkInterface { ethStats.incStats(eth_proto, num_pkts, pkt_len, pkt_overhead); ndpiStats.incStats(when, ndpi_proto, 0, 0, 1, pkt_len); pktStats.incStats(pkt_len); - if(lastSecUpdate == 0) lastSecUpdate = when; else if(lastSecUpdate != when) updateSecondTraffic(when); }; inline void incLocalStats(u_int num_pkts, u_int pkt_len, bool localsender, bool localreceiver) { @@ -490,7 +480,6 @@ class NetworkInterface { NetworkStats* getNetworkStats(u_int8_t networkId); void allocateNetworkStats(); void getsDPIStats(lua_State *vm); - inline u_int64_t* getLastMinuteTrafficStats() { return((u_int64_t*)lastMinuteTraffic); } #ifdef NTOPNG_PRO void updateFlowProfiles(); inline FlowProfile* getFlowProfile(Flow *f) { return(flow_profiles ? flow_profiles->getFlowProfile(f) : NULL); } diff --git a/src/Lua.cpp b/src/Lua.cpp index c3bfe602b6..033b8da135 100644 --- a/src/Lua.cpp +++ b/src/Lua.cpp @@ -2517,21 +2517,6 @@ static int ntop_refresh_hosts_alerts_configuration(lua_State* vm) { /* ****************************************** */ -static int ntop_set_second_traffic(lua_State* vm) { - NetworkInterface *ntop_interface = getCurrentInterface(vm); - - ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); - - if(!ntop_interface) return(CONST_LUA_ERROR); - - ntop_interface->updateSecondTraffic(time(NULL)); - - lua_pushnil(vm); - return(CONST_LUA_OK); -} - -/* ****************************************** */ - static int ntop_set_host_dump_policy(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); char *host_ip; @@ -5837,7 +5822,6 @@ static const luaL_Reg ntop_interface_reg[] = { { "findHostByMac", ntop_get_interface_find_host_by_mac }, { "updateHostTrafficPolicy", ntop_update_host_traffic_policy }, { "refreshHostsAlertsConfiguration", ntop_refresh_hosts_alerts_configuration }, - { "setSecondTraffic", ntop_set_second_traffic }, { "setHostDumpPolicy", ntop_set_host_dump_policy }, { "getLatestActivityHostsInfo", ntop_get_interface_latest_activity_hosts_info }, { "getInterfaceDumpDiskPolicy", ntop_get_interface_dump_disk_policy }, diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index dfa6e34985..16ff50e1f8 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -98,7 +98,7 @@ NetworkInterface::NetworkInterface(const char *name, } } - pkt_dumper_tap = NULL, lastSecUpdate = 0; + pkt_dumper_tap = NULL; ifname = strdup(name); ifDescription = strdup(Utils::getInterfaceDescription(ifname, buf, sizeof(buf))); snmp = new SNMP(); @@ -256,7 +256,7 @@ void NetworkInterface::init() { next_idle_flow_purge = next_idle_host_purge = 0, running = false, numSubInterfaces = 0, numVirtualInterfaces = 0, flowHashing = NULL, - pcap_datalink_type = 0, mtuWarningShown = false, lastSecUpdate = 0, + pcap_datalink_type = 0, mtuWarningShown = false, purge_idle_flows_hosts = true, id = (u_int8_t)-1, last_remote_pps = 0, last_remote_bps = 0, sprobe_interface = false, has_vlan_packets = false, @@ -278,9 +278,6 @@ void NetworkInterface::init() { pcap_datalink_type = 0, cpu_affinity = -1, pkt_dumper = NULL; - memset(lastMinuteTraffic, 0, sizeof(lastMinuteTraffic)); - resetSecondTraffic(); - L_user_scripts_inline = L_user_scripts_periodic = NULL; forceLuaInterpreterReload(); @@ -1836,7 +1833,6 @@ void NetworkInterface::purgeIdle(time_t when) { } if(pkt_dumper) pkt_dumper->idle(when); - updateSecondTraffic(when); } /* **************************************************** */ @@ -5002,22 +4998,6 @@ NetworkStats* NetworkInterface::getNetworkStats(u_int8_t networkId) { /* **************************************** */ -void NetworkInterface::updateSecondTraffic(time_t when) { - u_int64_t bytes = ethStats.getNumBytes(); - u_int16_t sec = when % 60; - - if(sec == 0) { - /* Beginning of a new minute */ - memcpy(lastMinuteTraffic, currentMinuteTraffic, sizeof(currentMinuteTraffic)); - resetSecondTraffic(); - } - - currentMinuteTraffic[sec] = max_val(0, bytes-lastSecTraffic); - lastSecTraffic = bytes; -}; - -/* **************************************** */ - void NetworkInterface::checkPointCounters(bool drops_only) { if(!drops_only) { checkpointPktCount = getNumPackets(),