diff --git a/include/HistoricalInterface.h b/include/HistoricalInterface.h deleted file mode 100755 index cb21971dee..0000000000 --- a/include/HistoricalInterface.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * - * (C) 2013-15 - ntop.org - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _HISTORICAL_INTERFACE_H_ -#define _HISTORICAL_INTERFACE_H_ - -#include "ntop_includes.h" - -class HistoricalInterface : public ParserInterface { - private: - u_int32_t num_historicals, /*< Number of historical files loaded*/ - num_query_error, /*< Number of query error*/ - num_open_error, /*< Number of error while opening a files*/ - num_missing_file ; /*< Number of missing files*/ - - int interface_id; /*< Interface index of the current data*/ - time_t from_epoch; /*< From epoch of the current data*/ - time_t to_epoch; /*< To Epoch of the current data*/ - bool on_load; /*< Set on true when loading historical data, false otherwise*/ - - /** - * @brief Callback for the sqlite_exe - * @details For each flows read on the DB call @ParserInterface::parse_flows, - * in order to inject the flow into the Interface. - * - * @param data - * @param argc Number of columns in the result. - * @param argv An array of pointers to strings, one for each column. - * @param azColName An array of pointers to strings where each entry represents the name of corresponding result column. - * @return non-zero in case of error, zero otherwise. - */ - static int sqlite_callback(void *data, int argc, char **argv, char **azColName); - /** - * @brief Rest all statistic information of historical interface instance. - * @details Reset information of current data and the counter of error and loaded files. - */ - void resetStats(); - - public: - /** - * @brief Constructor - * @details Create a new instance and set @ref purge_idle_flows_hosts to false in order to show all the flows. - * - * @param _endpoint Interface name. - */ - HistoricalInterface(const char *_endpoint); - - /** - * @brief Get interface type - * @return sqlite - */ - inline const char* get_type() { return(CONST_INTERFACE_TYPE_SQLITE); }; - /** - * @brief Check if ndpi is enable for this interface - * @return True if ndpi is enable, false otherwise. - */ - inline bool is_ndpi_enabled() { return(false); }; - /** - * @brief Check if the loading process running - * @return True if is running, false otherwise. - */ - inline bool is_on_load() { return(on_load); }; - /** - * @brief Set current interface index - * - * @param p_id Interface index - */ - inline void setDataIntrefaceId(int p_id) { interface_id = p_id; }; - /** - * @brief Set current from epoch - * @details Epoch of first loaded files. - * - * @param p_epoch Epoch time - */ - inline void setFromEpoch(time_t p_epoch) { from_epoch = p_epoch; }; - /** - * @brief Set current to epoch - * @details Epoch of last loaded files. - * - * @param p_epoch Epoch time - */ - inline void setToEpoch(time_t p_epoch) { to_epoch = p_epoch; }; - - /** - * @brief Get current interface index. - * @return Data interface index if set, otherwise return zero. - */ - inline int getDataInterfaceId() { return interface_id;}; - /** - * @brief Get from epoch - * @details Epoch of first loaded files.] - * @return Epoch time if set, zero otherwise. - */ - inline time_t getFromEpoch() { return from_epoch;}; - /** - * @brief Get to epoch - * @details Epoch of last loaded files. - * @return Epoch time if set, zero otherwise. - */ - inline time_t getToEpoch() { return to_epoch;}; - - /** - * @brief Get number of open error - * @return Number of errors encountered while opening files. - */ - inline u_int32_t getOpenError() { return num_open_error;}; - /** - * @brief Get number of query error - * @return Number of errors encountered during the execution of the query. - */ - inline u_int32_t getQueryError() { return num_query_error;}; - /** - * @brief Get number of missing error - * @return Number of missing files. - */ - inline u_int32_t getMissingFiles() { return num_missing_file;}; - /** - * @brief Get total number of file inside the interval - * @return Number of files. - */ - inline u_int32_t getNumFiles() { return num_historicals;}; - - /** - * @brief Load historical data - * @details Check if the file exists and then load flows from it. - * - * @param p_file_name Path to the historical data file - * @param limit Max number of rows to load from the DB (-1 for no limit) - * @return CONST_HISTORICAL_OK in case of success, CONST_HISTORICAL_FILE_ERROR or CONST_HISTORICAL_OPEN_ERROR in case of error. - */ - int loadData(char * p_file_name, int limit); - /** - * @brief Load historical data - * @details Loop on the interval, with step of 5 minute. For each step make a correct file path and the load flows form it. - * Until an error occurs. - * - * @return CONST_HISTORICAL_OK. - */ - int loadData(); - /** - * @brief Start loading historical data process - * @details Cleanup the interface, set on true @ref on_load and initialize the interval values. - * - * @param p_from_epoch Epoch time - * @param p_to_epoch Epoch time - * @param p_interface_id Index of the interface from which you want to load the data - */ - void startLoadData(time_t p_from_epoch, time_t p_to_epoch, int p_interface_id); - /** - * @brief Get Number of dropped packets - * @return Zero - */ - inline u_int getNumDroppedPackets() { return 0; }; - /** - * @brief For this interface is impossible set packet filter. - * @return False - */ - bool set_packet_filter(char *filter); - - /** - * @brief Shutdown the interface - * @details Reset the stats and cleanup the interface. - */ - void shutdown(); - /** - * @brief Cleanup - * @details Remove all information about flows, hosts and reset the interface stats. - */ - void cleanup(); -}; - -#endif /* _HISTORICAL_INTERFACE_H_ */ - diff --git a/include/Ntop.h b/include/Ntop.h index 65e0734187..c492b5fdce 100644 --- a/include/Ntop.h +++ b/include/Ntop.h @@ -65,7 +65,6 @@ class Ntop { Categorization *categorization; HTTPBL* httpbl; ExportInterface *export_interface; - int historical_interface_id; long time_offset; time_t start_time; /**< Time when start() was called */ int udp_socket; @@ -353,24 +352,6 @@ class Ntop { void createExportInterface(); void initRedis(); -// Historical Interface -/** - * @brief Get Historical Interface - * @details Use @ref historical_interface_id to identify the Historical Interface - * @return Pointer to Historical Interface instance - */ - NetworkInterface* getHistoricalInterface(); - /** - * @brief Get Historical Interface index - * @return index of current historical interface instance - */ - inline int getHistoricalInterfaceId() { return historical_interface_id; }; - /** - * @brief Create a new Historical Interface instance - * @details Create a new instance and register the interface - */ - void createHistoricalInterface(); - inline u_int32_t getUptime() { return((u_int32_t)((start_time > 0) ? (time(NULL)-start_time) : 0)); } inline int getUdpSock() { return(udp_socket); } diff --git a/include/Prefs.h b/include/Prefs.h index a30544d7af..1de2e2f7ce 100644 --- a/include/Prefs.h +++ b/include/Prefs.h @@ -50,7 +50,7 @@ class Prefs { u_int32_t max_num_hosts, max_num_flows; u_int http_port, https_port; u_int8_t num_interfaces, num_interface_views; - bool dump_flows_on_sqlite, dump_flows_on_es, dump_flows_on_mysql; + bool dump_flows_on_es, dump_flows_on_mysql; bool enable_taps; InterfaceInfo ifNames[MAX_NUM_INTERFACES]; InterfaceInfo ifViewNames[MAX_NUM_INTERFACES]; @@ -124,7 +124,6 @@ class Prefs { inline char* get_user() { return(user); }; inline u_int8_t get_num_user_specified_interfaces() { return(num_interfaces); }; inline u_int8_t get_num_user_specified_interface_views() { return(num_interface_views); }; - inline bool do_dump_flows_on_sqlite() { return(dump_flows_on_sqlite); }; inline bool do_dump_flows_on_es() { return(dump_flows_on_es); }; inline bool do_dump_flows_on_mysql() { return(dump_flows_on_mysql); }; inline char* get_if_name(u_int id) { return((id < MAX_NUM_INTERFACES) ? ifNames[id].name : NULL); }; diff --git a/include/ntop_includes.h b/include/ntop_includes.h index 705d85740c..b078a59bfd 100644 --- a/include/ntop_includes.h +++ b/include/ntop_includes.h @@ -184,7 +184,6 @@ using namespace std; #endif #include "ParserInterface.h" #include "CollectorInterface.h" -#include "HistoricalInterface.h" #include "ExportInterface.h" #include "Geolocation.h" #include "GenericHost.h" diff --git a/ntopng.8 b/ntopng.8 index dde4e6fa3e..cf14319733 100644 --- a/ntopng.8 +++ b/ntopng.8 @@ -282,7 +282,6 @@ detected they will be discarded. .It \-F|\-\-dump\-flows\ If ntopng is compiled with sqlite support, flows can dumped persistently on disk using this option. The mode can be set to -sqlite - Dump on local SQLite dabatase. Databases are created daily under //db. Using this option you can reload the dumped flows via the Historical Interface specify the time interval and the interface. es - Dump on ntopng.es queue in Elasticsearch format that be insert on a ES database. In this case the format is "es;;;;:". Example: -F "es;flows;ntopng-%Y.%m.%d;http://localhost:9200/_bulk;user:pwd". The accepts the strftime() format. mysql - Dump flows in MySQL tables. In this case the format is "::::". Example -F "mysql;localhost;ntopng;flows-%Y.%m.%d;root;". diff --git a/scripts/callbacks/minute.lua b/scripts/callbacks/minute.lua index 85bc5fb143..e6d8cb6fbe 100644 --- a/scripts/callbacks/minute.lua +++ b/scripts/callbacks/minute.lua @@ -87,9 +87,10 @@ for _,_ifname in pairs(ifnames) do -- Dump topTalkers every minute if((ifstats.type ~= "pcap dump") and (ifstats.type ~= "unknown")) then - talkers = makeTopJSON(ifstats.id, _ifname) + talkers = makeTopJSON(ifstats.id, _ifname) ntop.insertMinuteSampling(ifstats.id, talkers) + --if(verbose) then print(talkers); end -- Run RRD update every 5 minutes -- Use 30 just to avoid rounding issues diff = when % 300 diff --git a/scripts/callbacks/second.lua b/scripts/callbacks/second.lua index 728038f26f..57d67b7117 100644 --- a/scripts/callbacks/second.lua +++ b/scripts/callbacks/second.lua @@ -34,7 +34,7 @@ for _,ifname in pairs(ifnames) do dirs = ntop.getDirs() basedir = fixPath(dirs.workingdir .. "/" .. ifstats.id .. "/rrd") - -- io.write(basedir.."\n") + --io.write(basedir.."\n") if(not(ntop.exists(basedir))) then if(enable_second_debug == 1) then io.write('Creating base directory ', basedir, '\n') end ntop.mkdir(basedir) diff --git a/scripts/lua/config_historical_interface.lua b/scripts/lua/config_historical_interface.lua deleted file mode 100644 index 0db302bb95..0000000000 --- a/scripts/lua/config_historical_interface.lua +++ /dev/null @@ -1,33 +0,0 @@ --- --- (C) 2013-15 - ntop.org --- - -dirs = ntop.getDirs() -package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path - -require "lua_utils" - -sendHTTPHeader('application/html') - -if(_GET["csrf"] ~= nil) then -interface_name = _GET["id"] -from = tonumber(_GET["from"]) -to = tonumber(_GET["to"]) -epoch = tonumber(_GET["epoch"]) - -ret = false - -if (interface_name ~= nil) then - interface_id = tonumber(interface.name2id(interface_name)) -end -if ((from ~= nil) and (to ~= nil) and (interface_id ~= nil)) then --- io.write(from .. '-' .. to.. '-' .. interface_id .. '\n') - ret = interface.loadHistoricalInterval(from,to,interface_id) -end - -if (ret) then - print "{ \"result\" : \"0\"}"; -else - print ( "{ \"result\" : \"-1\"}" ); -end -end \ No newline at end of file diff --git a/scripts/lua/flow_details.lua b/scripts/lua/flow_details.lua index 130919076d..e9320ad153 100644 --- a/scripts/lua/flow_details.lua +++ b/scripts/lua/flow_details.lua @@ -14,7 +14,6 @@ local json = require ("dkjson") sendHTTPHeader('text/html; charset=iso-8859-1') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") -is_historical = interface.isHistoricalInterface(interface.name2id(ifname)) warn_shown = 0 function displayProc(proc) @@ -253,7 +252,7 @@ else print("\n") end - if((flow.client_process == nil) and (flow.server_process == nil) and (not is_historical)) then + if((flow.client_process == nil) and (flow.server_process == nil)) then print("
Actual / Peak Throughput") if (throughput_type == "bps") then print("" .. bitsToSize(8*flow["throughput_bps"]) .. " ") @@ -484,9 +483,7 @@ print [[/lua/flow_stats.lua', ]] -if not is_historical then - print ("setInterval(update,3000);\n") -end +print ("setInterval(update,3000);\n") print [[ diff --git a/scripts/lua/flows_stats.lua b/scripts/lua/flows_stats.lua index 8062356b07..fe5c288d86 100644 --- a/scripts/lua/flows_stats.lua +++ b/scripts/lua/flows_stats.lua @@ -26,7 +26,6 @@ network_name=_GET["network_name"] prefs = ntop.getPrefs() interface.select(ifname) -is_historical = interface.isHistoricalInterface(interface.name2id(ifname)) ifstats = interface.getStats() ndpistats = interface.getnDPIStats() @@ -129,7 +128,7 @@ ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/flows_stats_id.inc") -- Set the flow table option if(ifstats.iface_vlan) then print ('flow_rows_option["vlan"] = true;\n') end -if(is_historical) then print ('clearInterval(flow_table_interval);\n') end + print [[ var table = $("#table-flows").datatable({ @@ -139,11 +138,7 @@ print ('rowCallback: function ( row ) { return flow_table_setID(row); },\n') preference = tablePreferences("rows_number",_GET["perPage"]) if (preference ~= "") then print ('perPage: '..preference.. ",\n") end -if not is_historical then - print(" title: \"Active ".. (application or vhost or "").." Flows") -else - print(" title: \"All Flows") -end +print(" title: \"Active ".. (application or vhost or "").." Flows") if(network_name ~= nil) then print(" [ Network "..network_name.." ]") diff --git a/scripts/lua/get_top_talkers.lua b/scripts/lua/get_top_talkers.lua index 91de1ba6ff..3250cb20d0 100644 --- a/scripts/lua/get_top_talkers.lua +++ b/scripts/lua/get_top_talkers.lua @@ -18,10 +18,6 @@ mod = require("top_scripts.top_talkers") if (type(mod) == type(true)) then print("[ ]\n") else - if (epoch ~= nil) then - top_talkers = mod.getHistoricalTop(ifid, ifname, epoch) - else - top_talkers = mod.getTop(ifid, ifname, epoch) - end - print(top_talkers) + top_talkers = mod.getTop(ifid, ifname, epoch) + print(top_talkers) end diff --git a/scripts/lua/host_details.lua b/scripts/lua/host_details.lua index 5463a5d662..8d4f9b74d9 100644 --- a/scripts/lua/host_details.lua +++ b/scripts/lua/host_details.lua @@ -61,7 +61,6 @@ end if(protocol_id == nil) then protocol_id = "" end interface.select(ifname) -is_historical = interface.isHistoricalInterface(interface.name2id(ifname)) ifstats = interface.getStats() ifId = ifstats.id @@ -128,11 +127,7 @@ else -- Added global javascript variable, in order to disable the refresh of pie chart in case -- of historical interface - if not is_historical then - print('\n\n') - else - print('\n\n') - end + print('\n\n') if(host["ip"] ~= nil) then host_name = hostinfo2hostkey(host) @@ -311,7 +306,7 @@ if ((host["ip"] ~= nil) and host['localhost']) then end end -if(ntop.exists(rrdname) and not is_historical) then +if(ntop.exists(rrdname)) then if(page == "historical") then print("\n
  • Historical
  • \n") else @@ -998,7 +993,7 @@ update_ndpi_table(); ]] -- Update interval ndpi table -if not is_historical then print("setInterval(update_ndpi_table, 5000);") end +print("setInterval(update_ndpi_table, 5000);") print [[ @@ -1236,7 +1231,6 @@ if(ifstats.iface_vlan) then show_vlan = true else show_vlan = false end -- Set the host table option if(show_sprobe) then print ('flow_rows_option["sprobe"] = true;\n') end if(show_vlan) then print ('flow_rows_option["vlan"] = true;\n') end -if(is_historical) then print ('clearInterval(flow_table_interval);\n') end if(show_sprobe) then print [[ @@ -1254,13 +1248,8 @@ if(preference ~= "") then print ('perPage: '..preference.. ",\n") end print ('sort: [ ["' .. getDefaultTableSort("flows") ..'","' .. getDefaultTableSortOrder("flows").. '"] ],\n') -if not is_historical then print [[ title: "Active Flows",]] -else - print [[ - title: "All Flows",]] -end ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/sflows_stats_top.inc") @@ -1279,13 +1268,8 @@ print [[ showPagination: true, ]] -if not is_historical then print [[ title: "Active Flows",]] -else - print [[ - title: "All Flows",]] -end -- Set the preference table preference = tablePreferences("rows_number",_GET["perPage"]) @@ -2473,7 +2457,4 @@ if (host ~= nil) then ]] end -if(is_historical) then print ('\n\n') end - - dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") diff --git a/scripts/lua/hosts_stats.lua b/scripts/lua/hosts_stats.lua index db5b05e551..33c23bdb49 100644 --- a/scripts/lua/hosts_stats.lua +++ b/scripts/lua/hosts_stats.lua @@ -103,7 +103,6 @@ if ((ifstats.iface_vlan)) then show_vlan = true else show_vlan = false end if(prefs.is_categorization_enabled) then print ('host_rows_option["categorization"] = true;\n') end if(prefs.is_httpbl_enabled) then print ('host_rows_option["httpbl"] = true;\n') end if(show_vlan) then print ('host_rows_option["vlan"] = true;\n') end -if(is_historical) then print ('clearInterval(host_table_interval);\n') end if(antenna_mac ~= nil) then am = "antenna_mac="..antenna_mac diff --git a/scripts/lua/if_stats.lua b/scripts/lua/if_stats.lua index ea0612b262..a2890bf367 100644 --- a/scripts/lua/if_stats.lua +++ b/scripts/lua/if_stats.lua @@ -21,7 +21,6 @@ max_num_shapers = 10 interface.select(if_name) ifid = interface.name2id(ifname) shaper_key = "ntopng.prefs."..ifid..".shaper_max_rate" -is_historical = interface.isHistoricalInterface(ifid) ifstats = interface.getStats() if(_GET["custom_name"] ~=nil) then @@ -57,7 +56,7 @@ if(_GET["dump_security_to_disk"] ~= nil and _GET["csrf"] ~= nil) then end if(_GET["sampling_rate"] ~= nil and _GET["csrf"] ~= nil) then - if (tonumber(_GET["sampling_rate"]) ~= nil) then + if(tonumber(_GET["sampling_rate"]) ~= nil) then page = "packetdump" val = ternary(_GET["sampling_rate"] ~= "0", _GET["sampling_rate"], "1") ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_sampling_rate', val) @@ -65,21 +64,21 @@ if(_GET["sampling_rate"] ~= nil and _GET["csrf"] ~= nil) then end end if(_GET["max_pkts_file"] ~= nil and _GET["csrf"] ~= nil) then - if (tonumber(_GET["max_pkts_file"]) ~= nil) then + if(tonumber(_GET["max_pkts_file"]) ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_pkts_file',_GET["max_pkts_file"]) interface.loadDumpPrefs() end end if(_GET["max_sec_file"] ~= nil and _GET["csrf"] ~= nil) then - if (tonumber(_GET["max_sec_file"]) ~= nil) then + if(tonumber(_GET["max_sec_file"]) ~= nil) then page = "packetdump" ntop.setCache('ntopng.prefs.'..ifstats.name..'.dump_max_sec_file',_GET["max_sec_file"]) interface.loadDumpPrefs() end end if(_GET["max_files"] ~= nil and _GET["csrf"] ~= nil) then - if (tonumber(_GET["max_files"]) ~= nil) then + if(tonumber(_GET["max_files"]) ~= nil) then page = "packetdump" local max_files_size = tonumber(_GET["max_files"]) max_files_size = max_files_size * 1000000 @@ -105,11 +104,7 @@ url= ntop.getHttpPrefix()..'/lua/if_stats.lua?if_name=' .. _ifname -- Added global javascript variable, in order to disable the refresh of pie chart in case -- of historical interface -if not is_historical then - print('\n\n') -else - print('\n\n') -end +print('\n\n') print [[ \n') @@ -185,22 +182,7 @@ print [[ --ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_top.inc") -- ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_bottom.inc") else - - if (interface.isHistoricalInterface(iface_id)) then - print [[ -
    -
    - - Welcome to the Historical Interface
    In order to use this interface you must specify, via the configuration page, the interface, for which you want to load the historical data, and the time interval to be loaded. -
    - - ]] - - else - print("
    No packet has been received yet on interface " .. getHumanReadableInterfaceName(ifname) .. ".

    Please wait seconds until this page reloads.

    ") - - end + print("
    No packet has been received yet on interface " .. getHumanReadableInterfaceName(ifname) .. ".

    Please wait seconds until this page reloads.

    ") end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") \ No newline at end of file diff --git a/scripts/lua/network_load.lua b/scripts/lua/network_load.lua index 58b9fcbb48..42cbde89e6 100644 --- a/scripts/lua/network_load.lua +++ b/scripts/lua/network_load.lua @@ -13,12 +13,8 @@ sendHTTPHeader('text/html; charset=iso-8859-1') function dumpInterfaceStats(interface_name) interface.select(interface_name) - ifstats = interface.getStats() - is_historical = interface.isHistoricalInterface(interface.name2id(interface_name)) - - if(not(is_historical)) then - stats = interface.getFlowsStats() - end + ifstats = interface.getStats() + stats = interface.getFlowsStats() if(ifstats ~= nil) then uptime = ntop.getUptime() @@ -45,46 +41,16 @@ function dumpInterfaceStats(interface_name) print(', "b_to_a_num_pkts_send_error": '.. ifstats["bridge.b_to_a.num_pkts_send_error"]) end - if(is_historical) then - historical_stats = interface.getHistorical(); - if (historical_stats.on_load) then - print(', "on_load": true') - else - print(', "on_load": false') + print(", \"breed\": { ") + num = 0 + for key, value in pairsByKeys(stats["breeds"], rev) do + if(num > 0) then + print(", ") end - - if((historical_stats.num_files ~= nil) and (historical_stats.num_files ~= 0))then - success_file = historical_stats.num_files - historical_stats.open_error - historical_stats.file_error - historical_stats.query_error - file_pctg = math.floor(1+((historical_stats.file_error*100)/historical_stats.num_files)) - open_pctg = math.floor(1+((historical_stats.open_error*100)/historical_stats.num_files)) - query_pctg = math.floor(1+((historical_stats.query_error*100)/historical_stats.num_files)) - success_pctg = math.floor(1+((success_file*100)/historical_stats.num_files)) - print(', "historical_if_name": "' .. historical_stats.interface_name ..'"') - print(', "historical_tot_files": "' .. historical_stats.num_files ..'"') - else - success_file = 0 - file_pctg = 0 - open_pctg = 0 - query_pctg = 0 - success_pctg = 0 - end - - print(', "success_file": ' .. success_file.. ', "open_error": ' .. historical_stats.open_error.. ', "file_error": '..historical_stats.file_error ..', "query_error": '..historical_stats.query_error) - print(', "success_pctg": ' .. success_pctg..', "open_pctg": ' .. open_pctg.. ', "file_pctg": '.. file_pctg ..', "query_pctg": '..query_pctg) - else - - print(", \"breed\": { ") - num = 0 - for key, value in pairsByKeys(stats["breeds"], rev) do - if(num > 0) then - print(", ") - end - print(' "'..key..'": '..value) - num = num + 1 - end - print(' }') + print(' "'..key..'": '..value) + num = num + 1 end - + print(' }') print(' }') else print('{ }') diff --git a/scripts/lua/top_generic.lua b/scripts/lua/top_generic.lua index 675db7ef73..4a7c747f33 100644 --- a/scripts/lua/top_generic.lua +++ b/scripts/lua/top_generic.lua @@ -24,11 +24,8 @@ else if (type(mod) == type(true)) then print("[ ]\n") else - if (epoch ~= nil) then - top = mod.getHistoricalTop(ifid, ifname, epoch, add_vlan) - else - top = mod.getTopClean(ifid, ifname, mode) - end + --top = mod.getTopClean(ifid, ifname, mode) + top = mod.getHistoricalTop(ifid, ifname, epoch, add_vlan) print(top) end end diff --git a/src/Flow.cpp b/src/Flow.cpp index d9e8d273a1..ecf8aa286d 100644 --- a/src/Flow.cpp +++ b/src/Flow.cpp @@ -616,8 +616,7 @@ char* Flow::print(char *buf, u_int buf_len) { /* *************************************** */ void Flow::dumpFlow(bool partial_dump) { - if(ntop->getPrefs()->do_dump_flows_on_sqlite() - || ntop->getPrefs()->do_dump_flows_on_mysql() + if(ntop->getPrefs()->do_dump_flows_on_mysql() || ntop->getPrefs()->do_dump_flows_on_es() || ntop->get_export_interface()) { @@ -628,12 +627,11 @@ void Flow::dumpFlow(bool partial_dump) { return; } - if(cli_host - && (ntop->getPrefs()->do_dump_flows_on_sqlite() - || ntop->getPrefs()->do_dump_flows_on_mysql())) { - cli_host->getInterface()->dumpDBFlow(last_seen, partial_dump, this); - } else if(cli_host && ntop->getPrefs()->do_dump_flows_on_es()) { - cli_host->getInterface()->dumpEsFlow(last_seen, partial_dump, this); + if(cli_host) { + if(ntop->getPrefs()->do_dump_flows_on_mysql()) + cli_host->getInterface()->dumpDBFlow(last_seen, partial_dump, this); + else if(ntop->getPrefs()->do_dump_flows_on_es()) + cli_host->getInterface()->dumpEsFlow(last_seen, partial_dump, this); } if(ntop->get_export_interface()) { diff --git a/src/HistoricalInterface.cpp b/src/HistoricalInterface.cpp deleted file mode 100755 index 86cc06244e..0000000000 --- a/src/HistoricalInterface.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * (C) 2013-15 - ntop.org - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include "ntop_includes.h" - -/* **************************************************** */ - -HistoricalInterface::HistoricalInterface(const char *_endpoint) - : ParserInterface(_endpoint) { - - if(ntop->getRedis()) - id = Utils::ifname2id(_endpoint); - else - id = -1; - - resetStats(); - purge_idle_flows_hosts = false; - - flowsManager = new FlowsManager(this); - if (!flowsManager) - ntop->getTrace()->traceEvent(TRACE_WARNING, "Could not allocate FlowsManager for Historical interface"); - - /* Create view for this interface so that it is visible in the GUI */ - view = new NetworkInterfaceView(this); - if (!view) - ntop->getTrace()->traceEvent(TRACE_WARNING, "Could not create view for interface %s", ifname); - else { - ntop->registerInterfaceView(view); - view->set_id(this->id); - } -} - -/* **************************************************** */ - -void HistoricalInterface::resetStats() { - num_historicals = 0, num_query_error = 0, num_open_error = 0, num_missing_file = 0, interface_id = 0; - from_epoch = 0, to_epoch = 0; - on_load = false; -} - -/* **************************************************** */ - -void HistoricalInterface::cleanup() { - if(!on_load) { - NetworkInterface::cleanup(); - resetStats(); - } -} - -/* **************************************************** */ - -int HistoricalInterface::sqlite_callback(void *data, int argc, - char **argv, char **azColName) { - for(int i=0; igetTrace()->traceEvent(TRACE_WARNING,"Missing file: %s",p_file_name); - num_missing_file++; - return CONST_HISTORICAL_FILE_ERROR; - } - - if(sqlite3_open(p_file_name, &db)) { - ntop->getTrace()->traceEvent(TRACE_WARNING, "Unable to open %s: %s", - p_file_name, sqlite3_errmsg(db)); - num_open_error++; - return CONST_HISTORICAL_OPEN_ERROR; - } else - ntop->getTrace()->traceEvent(TRACE_DEBUG, "Open db %s", p_file_name); - - char sql[256], sql_limit[20]; - snprintf(sql_limit, sizeof(sql_limit), "LIMIT %d", limit); - snprintf(sql, sizeof(sql), "SELECT * FROM flows ORDER BY first_seen, srv_ip, srv_port, cli_ip, cli_port ASC %s", - (limit == -1 ? "" : sql_limit)); - // Correctly open db, so now we can extract the contained flows via the sqlite_callback - if(sqlite3_exec(db, sql, sqlite_callback, this, &zErrMsg)) { - ntop->getTrace()->traceEvent(TRACE_WARNING, "SQL Error: %s from %s", zErrMsg, p_file_name); - sqlite3_free(zErrMsg); - num_query_error++; - goto close_db; - } - - ntop->getTrace()->traceEvent(TRACE_NORMAL, "Terminated flow polling from %s", p_file_name ); - - close_db: - sqlite3_close(db); - - } - return CONST_HISTORICAL_OK; -} - -/* **************************************************** */ - - -int HistoricalInterface::loadData() { - time_t actual_epoch, adjust_to_epoch; - int ret_state = CONST_HISTORICAL_OK; - NetworkInterface * iface = ntop->getInterfaceById(interface_id); - - if((iface != NULL) && (from_epoch != 0) && (to_epoch != 0)) { - int iface_dump_id; - - iface_dump_id = iface->get_id(); - actual_epoch = from_epoch; - adjust_to_epoch = to_epoch - 300; // Adjust to epoch each file contains 5 minute of data - int num_steps = (from_epoch - adjust_to_epoch) / 300; - if (num_steps < 1) num_steps = 1; /* avoid arithmetic exceptions */ - int limit = CONST_HISTORICAL_ROWS_LIMIT / num_steps; - if (limit < 1) limit = 1; - while (actual_epoch <= adjust_to_epoch && isRunning()) { - char path[MAX_PATH]; - char db_path[MAX_PATH]; - - memset(path, 0, sizeof(path)); - memset(db_path, 0, sizeof(db_path)); - - strftime(path, sizeof(path), "%Y/%m/%d/%H/%M", localtime(&actual_epoch)); - snprintf(db_path, sizeof(db_path), "%s/%d/flows/%s.sqlite", - ntop->get_working_dir(), iface_dump_id , path); - - loadData(db_path, limit); - - num_historicals++; - actual_epoch += 300; // 5 minute steps - } - } - - on_load = false; - - return ret_state; -} - -/* **************************************************** */ - -static void* packetPollLoop(void* ptr) { - HistoricalInterface *iface = (HistoricalInterface*)ptr; - - /* Wait until the initialization completes */ - while(!iface->isRunning() || !iface->is_on_load()) sleep(1); - - iface->loadData(); - return(NULL); -} - -/* **************************************************** */ - -void HistoricalInterface::startLoadData(time_t p_from_epoch, time_t p_to_epoch, int p_interface_id) { - if(!on_load) { - cleanup(); - on_load = true; - - from_epoch = p_from_epoch; - to_epoch = p_to_epoch; - interface_id = p_interface_id; - - pthread_create(&pollLoop, NULL, packetPollLoop, (void*)this); - pollLoopCreated = true; - NetworkInterface::startPacketPolling(); - } -} - -/* **************************************************** */ - -void HistoricalInterface::shutdown() { - void *res; - - if(running) { - NetworkInterface::shutdown(); - pthread_join(pollLoop, &res); - } -} - -/* **************************************************** */ - -bool HistoricalInterface::set_packet_filter(char *filter) { - ntop->getTrace()->traceEvent(TRACE_INFO, - "No filter can be set on a historical interface. Ignored %s", filter); - return(false); -} diff --git a/src/Host.cpp b/src/Host.cpp index 2ce1afa791..9b07d85fa7 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -961,12 +961,11 @@ bool Host::deserialize(char *json_str) { /* *************************************** */ void Host::updateSynFlags(time_t when, u_int8_t flags, Flow *f, bool syn_sent) { - if(!localHost || !triggerAlerts()) return; - bool historical = ntop->getHistoricalInterfaceId() == iface->get_id(); - AlertCounter *counter = syn_sent ? syn_flood_attacker_alert : syn_flood_victim_alert; - if(counter->incHits(when) && !historical) { + if(!localHost || !triggerAlerts()) return; + + if(counter->incHits(when)) { char ip_buf[48], flow_buf[256], msg[512], *h; const char *error_msg; @@ -1011,12 +1010,11 @@ void Host::updateSynFlags(time_t when, u_int8_t flags, Flow *f, bool syn_sent) { void Host::incNumFlows(bool as_client) { if(!localHost || !triggerAlerts()) return; - bool historical = ntop->getHistoricalInterfaceId() == iface->get_id(); if(as_client) { total_num_flows_as_client++, num_active_flows_as_client++; - if(!historical && num_active_flows_as_client == max_num_active_flows) { + if(num_active_flows_as_client == max_num_active_flows) { const char* error_msg = "Host %s is a possible scanner [%u active flows]"; char ip_buf[48], *h, msg[512]; @@ -1033,7 +1031,7 @@ void Host::incNumFlows(bool as_client) { } else { total_num_flows_as_server++, num_active_flows_as_server++; - if(!historical && num_active_flows_as_server == max_num_active_flows) { + if(num_active_flows_as_server == max_num_active_flows) { const char* error_msg = "Host %s is possibly under scan attack [%u active flows]"; char ip_buf[48], *h, msg[512]; @@ -1054,13 +1052,12 @@ void Host::incNumFlows(bool as_client) { void Host::decNumFlows(bool as_client) { if(!localHost || !triggerAlerts()) return; - bool historical = ntop->getHistoricalInterfaceId() == iface->get_id(); if(as_client) { if(num_active_flows_as_client) { num_active_flows_as_client--; - if(!historical && num_active_flows_as_client == max_num_active_flows) { + if(num_active_flows_as_client == max_num_active_flows) { const char* error_msg = "Host %s is no longer a possible scanner [%u active flows]"; char ip_buf[48], *h, msg[512]; @@ -1080,7 +1077,7 @@ void Host::decNumFlows(bool as_client) { if(num_active_flows_as_server) { num_active_flows_as_server--; - if(!historical && num_active_flows_as_server == max_num_active_flows) { + if(num_active_flows_as_server == max_num_active_flows) { const char* error_msg = "Host %s is no longer under scan attack [%u active flows]"; char ip_buf[48], *h, msg[512]; @@ -1123,14 +1120,12 @@ bool Host::isAboveQuota() { /* *************************************** */ void Host::updateStats(struct timeval *tv) { - bool historical = ntop->getHistoricalInterfaceId() == iface->get_id(); - ((GenericHost*)this)->updateStats(tv); if(http) http->updateStats(tv); if(!localHost || !triggerAlerts()) return; - if(!historical && isAboveQuota()) { + if(isAboveQuota()) { const char *error_msg = "Host %s is above quota [%u])"; char ip_buf[48], *h, msg[512]; h = ip->print(ip_buf, sizeof(ip_buf)); diff --git a/src/Lua.cpp b/src/Lua.cpp index f798044a20..76d5e79e49 100644 --- a/src/Lua.cpp +++ b/src/Lua.cpp @@ -4072,181 +4072,6 @@ static int ntop_lua_dofile(lua_State* L) /* ****************************************** */ -/** - * @brief Check if the interface is the historical interface - * @details Push into lua stack 1 if it is, 0 otherwise. - * - * @param vm The lua state. - * @param id Id of the interface. - * - * @return CONST_LUA_OK. - */ -static int ntop_is_historical_interface(lua_State* vm) { - ntop->getTrace()->traceEvent(TRACE_INFO, "%s() called", __FUNCTION__); - - if(ntop->getPrefs()->do_dump_flows_on_sqlite()) { - u_int32_t id, historical_id; - - historical_id = ntop->getHistoricalInterfaceId(); - - if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR); - id = (u_int32_t)lua_tonumber(vm, 1); - - lua_pushboolean(vm, (historical_id == id) ); - } else - lua_pushboolean(vm, false ); - - return(CONST_LUA_OK); -} - -/* ****************************************** */ -/** - * @brief Get Historical Interface configuration - * @details Push the main information of the interface into the lua stack. - * - * @param vm The lua state. - * @return @ref CONST_LUA_OK - */ -static int ntop_get_historical_info(lua_State* vm) { - HistoricalInterface *iface = NULL; - iface = (HistoricalInterface*) ntop->getHistoricalInterface(); - - ntop->getTrace()->traceEvent(TRACE_INFO, "%s() called", __FUNCTION__); - - if(iface != NULL) { - lua_newtable(vm); - lua_push_int_table_entry(vm, "id", iface->get_id()); - lua_push_str_table_entry(vm, "name", iface->get_name()); - lua_push_bool_table_entry(vm, "on_load", iface->is_on_load()); - lua_push_int_table_entry(vm, "interface_id", iface->getDataInterfaceId()); - lua_push_str_table_entry(vm, "interface_name", ntop->get_if_name(iface->getDataInterfaceId())); - lua_push_int_table_entry(vm, "from_epoch", iface->getFromEpoch()); - lua_push_int_table_entry(vm, "to_epoch", iface->getToEpoch()); - lua_push_int32_table_entry(vm, "num_files", iface->getNumFiles()); - lua_push_int32_table_entry(vm, "open_error", iface->getOpenError()); - lua_push_int32_table_entry(vm, "file_error", iface->getMissingFiles()); - lua_push_int32_table_entry(vm, "query_error", iface->getQueryError()); - } - - return(CONST_LUA_OK); -} - -/* ****************************************** */ -/** - * @brief Set Historical Interface configuration - * @details Require the following parameters: - * number from_epoch - * number to_epoch - * number interface id - * - * @param vm The lua state. - * @return @ref CONST_LUA_OK - */ -static int ntop_set_historical_info(lua_State* vm) { - u_int32_t from_epoch, to_epoch; - u_int8_t iface_id = 0; - HistoricalInterface *iface = NULL; - - ntop->getTrace()->traceEvent(TRACE_INFO, "%s() called", __FUNCTION__); - if(!Utils::isUserAdministrator(vm)) return(CONST_LUA_ERROR); - - iface = (HistoricalInterface*) ntop->getHistoricalInterface(); - - if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR); - from_epoch = (u_int32_t)lua_tonumber(vm, 1); - - if(ntop_lua_check(vm, __FUNCTION__, 2, LUA_TNUMBER)) return(CONST_LUA_ERROR); - to_epoch = (u_int32_t)lua_tonumber(vm, 2); - - if(ntop_lua_check(vm, __FUNCTION__, 3, LUA_TNUMBER)) return(CONST_LUA_ERROR); - iface_id = (u_int8_t)lua_tonumber(vm, 3); - - iface->setFromEpoch((time_t) from_epoch); - iface->setToEpoch((time_t) to_epoch); - iface->setDataIntrefaceId(iface_id); - - return(CONST_LUA_OK); -} - -/* ****************************************** */ - -/** - * @brief Start loading historical data process based on a time interval - * @details Require the following parameters: - * number from_epoch - * number to_epoch - * number interface id - * - * @param vm The lua state. - * @return @ref CONST_LUA_OK and push the return code into the Lua stack - */ -static int ntop_load_historical_interval(lua_State* vm) { - u_int32_t from_epoch, to_epoch; - int iface_id = 0; - HistoricalInterface *iface = NULL; - - ntop->getTrace()->traceEvent(TRACE_INFO, "%s() called", __FUNCTION__); - if(!Utils::isUserAdministrator(vm)) return(CONST_LUA_ERROR); - - iface = (HistoricalInterface*) ntop->getHistoricalInterface(); - - if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR); - from_epoch = (u_int32_t)lua_tonumber(vm, 1); - - if(ntop_lua_check(vm, __FUNCTION__, 2, LUA_TNUMBER)) return(CONST_LUA_ERROR); - to_epoch = (u_int32_t)lua_tonumber(vm, 2); - - if(ntop_lua_check(vm, __FUNCTION__, 3, LUA_TNUMBER)) return(CONST_LUA_ERROR); - iface_id = (int)lua_tonumber(vm, 3); - - if((iface == NULL) || iface->is_on_load()) - lua_pushboolean(vm,false); - else { - iface->startLoadData((time_t) from_epoch, (time_t) to_epoch, iface_id); - lua_pushboolean(vm,true); - } - - return(CONST_LUA_OK); -} - -/* ****************************************** */ - -/** - * @brief Load historical data from a single file - * @details Require the following parameters: - * string absolute file path - * boolean it true cleanup the interface, default value is false - * - * @param vm The lua state. - * @return @ref CONST_LUA_OK and push the return code into the Lua stack - */ -static int ntop_load_historical_file(lua_State* vm) { - char *file_name; - bool cleanup; - HistoricalInterface *iface = NULL; - - ntop->getTrace()->traceEvent(TRACE_INFO, "%s() called", __FUNCTION__); - if(!Utils::isUserAdministrator(vm)) return(CONST_LUA_ERROR); - - iface = (HistoricalInterface*)ntop->getHistoricalInterface(); - - if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING)) return(CONST_LUA_ERROR); - if((file_name = (char*)lua_tostring(vm, 1)) == NULL) return(CONST_LUA_PARAM_ERROR); - - /* Optional */ - if(lua_type(vm, 2) != LUA_TBOOLEAN) - cleanup = false; - else - cleanup = lua_toboolean(vm, 2) ? true : false; - - if(cleanup) iface->cleanup(); - lua_pushnumber(vm, iface->loadData(file_name, -1)); - - return(CONST_LUA_OK); -} - -/* ****************************************** */ - /** * @brief Return true if login has been disabled * @@ -4355,13 +4180,6 @@ static const luaL_Reg ntop_interface_reg[] = { { "loadDumpPrefs", ntop_load_dump_prefs }, { "loadHostAlertPrefs", ntop_interface_load_host_alert_prefs }, - /* Historical Interface */ - { "getHistorical", ntop_get_historical_info }, - { "setHistorical", ntop_set_historical_info }, - { "loadHistoricalInterval", ntop_load_historical_interval }, - { "loadHistoricalFile", ntop_load_historical_file}, - { "isHistoricalInterface", ntop_is_historical_interface }, - /* L7 */ { "reloadL7Rules", ntop_reload_l7_rules }, { "reloadShapers", ntop_reload_shapers }, diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index d7251213be..dad1d9ac48 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -70,14 +70,11 @@ NetworkInterface::NetworkInterface() { pcap_datalink_type = 0, cpu_affinity = -1, pkt_dumper = NULL, antenna_mac = NULL; - if(ntop->getPrefs()->do_dump_flows_on_sqlite()) - db = new SQLiteDB(this); + db = NULL; #ifdef HAVE_MYSQL - else if(ntop->getPrefs()->do_dump_flows_on_mysql()) + if(ntop->getPrefs()->do_dump_flows_on_mysql()) db = new MySQLDB(this); #endif - else - db = NULL; #ifdef NTOPNG_PRO policer = NULL; @@ -185,10 +182,9 @@ NetworkInterface::NetworkInterface(const char *name) { running = false, sprobe_interface = false, inline_interface = false; - if(ntop->getPrefs()->do_dump_flows_on_sqlite()) - db = new SQLiteDB(this); + db = NULL; #ifdef HAVE_MYSQL - else if(ntop->getPrefs()->do_dump_flows_on_mysql()) + if(ntop->getPrefs()->do_dump_flows_on_mysql()) db = new MySQLDB(this); #endif @@ -460,7 +456,7 @@ NetworkInterface::~NetworkInterface() { /* **************************************************** */ int NetworkInterface::dumpFlow(time_t when, bool partial_dump, Flow *f) { - if(ntop->getPrefs()->do_dump_flows_on_sqlite()) { + if(ntop->getPrefs()->do_dump_flows_on_mysql()) { return(dumpDBFlow(when, partial_dump, f)); } else if(ntop->getPrefs()->do_dump_flows_on_es()) return(dumpEsFlow(when, partial_dump, f)); diff --git a/src/Ntop.cpp b/src/Ntop.cpp index 5c737c6c97..3b5b265e14 100644 --- a/src/Ntop.cpp +++ b/src/Ntop.cpp @@ -59,7 +59,6 @@ Ntop::Ntop(char *appName) { num_defined_interfaces = num_defined_interface_views = 0; local_interface_addresses = New_Patricia(128); export_interface = NULL; - historical_interface_id = -1; start_time = 0; /* It will be initialized by start() */ memset(iface, 0, sizeof(iface)); httpd = NULL, runtimeprefs = NULL, geo = NULL; @@ -261,21 +260,6 @@ void Ntop::initRedis() { /* ******************************************* */ -void Ntop::createHistoricalInterface() { - HistoricalInterface *iface = new HistoricalInterface("Historical"); - prefs->add_network_interface((char *)"Historical", NULL); - ntop->registerInterface(iface); - historical_interface_id = iface->get_id(); -} - -/* ******************************************* */ - -NetworkInterface* Ntop::getHistoricalInterface() { - return (getInterface(get_if_name(historical_interface_id))); -}; - -/* ******************************************* */ - void Ntop::createExportInterface() { if(prefs->get_export_endpoint()) export_interface = new ExportInterface(prefs->get_export_endpoint()); diff --git a/src/ParserInterface.cpp b/src/ParserInterface.cpp index 9b6eeea6ff..b65312bee1 100755 --- a/src/ParserInterface.cpp +++ b/src/ParserInterface.cpp @@ -29,8 +29,8 @@ ParserInterface::ParserInterface(const char *endpoint) : NetworkInterface(endpoi u_int8_t ParserInterface::parse_flows(char *payload, int payload_size, u_int8_t source_id, void *data) { json_object *o; - ZMQ_Flow flow; - HistoricalInterface * iface = (HistoricalInterface*) data; + ZMQ_Flow flow; + NetworkInterface * iface = (NetworkInterface*)data; // payload[payload_size] = '\0'; diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 260ca5ce27..2a17aada43 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -59,7 +59,7 @@ Prefs::Prefs(Ntop *_ntop) { packet_filter = NULL; disable_host_persistency = false; num_interfaces = 0, num_interface_views = 0, enable_auto_logout = true; - dump_flows_on_sqlite = dump_flows_on_es = dump_flows_on_mysql = false; + dump_flows_on_es = dump_flows_on_mysql = false; enable_taps = false; memset(ifNames, 0, sizeof(ifNames)); memset(ifViewNames, 0, sizeof(ifViewNames)); @@ -228,7 +228,6 @@ void usage() { "[--disable-alerts|-H] | Disable alerts generation\n" "[--packet-filter|-B] | Ingress packet filter (BPF filter)\n" "[--dump-flows|-F] | Dump expired flows. Mode:\n" - " | sqlite Dump in SQLite DB\n" " | es Dump in ElasticSearch database\n" " | Format:\n" " | es;;;;\n" @@ -682,10 +681,8 @@ int Prefs::setOption(int optkey, char *optarg) { ntop->getTrace()->traceEvent(TRACE_WARNING, "Format: -F es;;;;:"); } - } else if(!strncmp(optarg, "sqlite", 6)) - dump_flows_on_sqlite = true; #ifdef HAVE_MYSQL - else if(!strncmp(optarg, "mysql", 5)) { + } else if(!strncmp(optarg, "mysql", 5)) { /* mysql;;;;; */ optarg = Utils::tokenizer(&optarg[6], ';', &mysql_host); optarg = Utils::tokenizer(optarg, ';', &mysql_dbname); @@ -1019,7 +1016,7 @@ void Prefs::lua(lua_State* vm) { lua_push_int_table_entry(vm, "flow_max_idle", flow_max_idle); lua_push_int_table_entry(vm, "max_num_hosts", max_num_hosts); lua_push_int_table_entry(vm, "max_num_flows", max_num_flows); - lua_push_bool_table_entry(vm, "is_dump_flows_enabled", dump_flows_on_sqlite); + lua_push_bool_table_entry(vm, "is_dump_flows_enabled", dump_flows_on_es || dump_flows_on_mysql); lua_push_int_table_entry(vm, "dump_hosts", dump_hosts_to_db); /* RRD prefs */ diff --git a/src/StatsManager.cpp b/src/StatsManager.cpp index 5c2735e114..8aa3cc5fa5 100644 --- a/src/StatsManager.cpp +++ b/src/StatsManager.cpp @@ -392,8 +392,7 @@ int StatsManager::insertSampling(char *sampling, const char *cache_name, if(openCache(cache_name)) return -1; - snprintf(query, sizeof(query), "INSERT INTO %s (TSTAMP, STATS) VALUES(?,?)", - cache_name); + snprintf(query, sizeof(query), "INSERT INTO %s (TSTAMP, STATS) VALUES(?,?)", cache_name); m.lock(__FILE__, __LINE__); diff --git a/src/main.cpp b/src/main.cpp index 72dd2ab16a..33548d6923 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,9 +212,6 @@ int main(int argc, char *argv[]) ntop->getRedis()->startFlowDump(); - if(prefs->do_dump_flows_on_sqlite()) - ntop->createHistoricalInterface(); - if(ntop->getInterfaceAtId(0) == NULL) { ntop->getTrace()->traceEvent(TRACE_ERROR, "Startup error: missing super-user privileges ?"); _exit(0);