From 8b37e6378129ed554092f1f895667e3be69da574 Mon Sep 17 00:00:00 2001 From: Pavel Odintsov Date: Tue, 16 Jul 2024 13:16:10 +0300 Subject: [PATCH] Moved sFlow configuration options to main configuration --- src/fastnetmon.cpp | 7 +++---- src/fastnetmon_configuration_scheme.hpp | 6 ++++++ src/fastnetmon_logic.cpp | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fastnetmon.cpp b/src/fastnetmon.cpp index d352b81e..263ecc15 100644 --- a/src/fastnetmon.cpp +++ b/src/fastnetmon.cpp @@ -291,7 +291,6 @@ bool enable_afpacket_collection = false; bool enable_af_xdp_collection = false; bool enable_data_collection_from_mirror = false; bool enable_netmap_collection = false; -bool enable_sflow_collection = false; bool enable_netflow_collection = false; bool enable_pcap_collection = false; @@ -774,9 +773,9 @@ bool load_configuration_file() { if (configuration_map.count("sflow") != 0) { if (configuration_map["sflow"] == "on") { - enable_sflow_collection = true; + fastnetmon_global_configuration.sflow = true; } else { - enable_sflow_collection = false; + fastnetmon_global_configuration.sflow = false; } } @@ -2041,7 +2040,7 @@ int main(int argc, char** argv) { } #endif - if (enable_sflow_collection) { + if (fastnetmon_global_configuration.sflow) { packet_capture_plugin_thread_group.add_thread(new boost::thread(start_sflow_collection, process_packet)); } diff --git a/src/fastnetmon_configuration_scheme.hpp b/src/fastnetmon_configuration_scheme.hpp index 92dc2321..5f3f80ec 100644 --- a/src/fastnetmon_configuration_scheme.hpp +++ b/src/fastnetmon_configuration_scheme.hpp @@ -9,6 +9,12 @@ class fastnetmon_configuration_t { public: + // sFlow + bool sflow{ false }; + std::vector sflow_ports{}; + std::string sflow_host{ "0.0.0.0" }; + bool sflow_read_packet_length_from_ip_header{ false }; + // Clickhouse metrics bool clickhouse_metrics{ false }; std::string clickhouse_metrics_database{ "fastnetmon" }; diff --git a/src/fastnetmon_logic.cpp b/src/fastnetmon_logic.cpp index 79f5a240..7560f30d 100644 --- a/src/fastnetmon_logic.cpp +++ b/src/fastnetmon_logic.cpp @@ -110,7 +110,6 @@ extern bool enable_connection_tracking; extern bool enable_afpacket_collection; extern bool enable_data_collection_from_mirror; extern bool enable_netmap_collection; -extern bool enable_sflow_collection; extern bool enable_netflow_collection; extern bool enable_pcap_collection; extern uint64_t incoming_total_flows_speed; @@ -2951,7 +2950,7 @@ bool get_statistics(std::vector& system_counters) { system_counters.push_back(system_counter_t("influxdb_writes_failed", influxdb_writes_failed, metric_type_t::counter, influxdb_writes_failed_desc)); - if (enable_sflow_collection) { + if (fastnetmon_global_configuration.sflow) { auto sflow_stats = get_sflow_stats(); system_counters.insert(system_counters.end(), sflow_stats.begin(), sflow_stats.end()); }