Squashed commit of the following:
commit
df425d8fc335ca5891200064f2c03b9b6f7d6892
Author: Sunirmal Mukherjee <sunimukh@cisco.com>
Date: Tue Feb 23 17:28:05 2021 -0500
module: Introduced new api to clear global active module counters
params = p;
}
+void Module::clear_global_active_counters()
+{
+ PegCount* p = get_counts();
+
+ if ( !p )
+ return;
+
+ const PegInfo* q = get_pegs();
+
+ assert(q);
+
+ for ( int i = 0; i < num_counts; i++ )
+ {
+ if ( q[i].type == CountType::NOW )
+ counts[i] = 0;
+ }
+}
+
void Module::sum_stats(bool accumulate_now_stats)
{
if ( num_counts < 0 )
virtual void show_stats();
virtual void reset_stats();
virtual void show_dynamic_stats() {}
+ void clear_global_active_counters();
// Wrappers to check that lists are not tables
bool verified_begin(const char*, int, SnortConfig*);
// shell instead of the logs when initiated by a shell command
DropStats();
LogMessage("==================================================\n"); // Marking End of stats
+ ModuleManager::clear_global_active_counters();
}
bool ACResetStats::execute(Analyzer&, void**)
}
}
+void ModuleManager::clear_global_active_counters()
+{
+ auto mod_hooks = get_all_modhooks();
+
+ for ( auto* mh : mod_hooks )
+ {
+ lock_guard<mutex> lock(stats_mutex);
+ mh->mod->clear_global_active_counters();
+ }
+}
+
void ModuleManager::reset_stats(clear_counter_type_t type)
{
if ( type != TYPE_MODULE and type != TYPE_UNKNOWN )
static void reset_stats(SnortConfig*);
static void reset_stats(clear_counter_type_t);
+ static void clear_global_active_counters();
+
static std::set<uint32_t> gids;
SO_PUBLIC static std::mutex stats_mutex;
};