From: Russ Combs (rucombs) Date: Wed, 9 Mar 2016 23:36:26 +0000 (-0500) Subject: Merge pull request #327 in SNORT/snort3 from perf_procglobal2 to master X-Git-Tag: 3.0.0-233~544 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3d38787fc6527656e9456c4ee891a76a3ebeffc;p=thirdparty%2Fsnort3.git Merge pull request #327 in SNORT/snort3 from perf_procglobal2 to master Squashed commit of the following: commit 5de0642b9b9d24ae52d06126d00782f3032a7a4b Author: Carter Waxman Date: Wed Mar 9 17:36:14 2016 -0500 fixed formatting for clarity commit 479cd2f035f4fdabe48785e0834c92b25059d332 Author: Carter Waxman Date: Wed Mar 9 13:27:02 2016 -0500 fixed thread_local commit 4e25c463fbb5596f67afece29bd4e17651352122 Author: Carter Waxman Date: Wed Mar 9 12:49:18 2016 -0500 fixed whitespaceP commit aae8c40a9537144772e599e49eb14cd139e8a475 Author: Carter Waxman Date: Wed Mar 9 12:47:38 2016 -0500 fixed whitespaceP commit f717352f7e6ff79709a40bd3fab7aa0cf6c5ec4b Author: Carter Waxman Date: Wed Mar 9 12:44:31 2016 -0500 fixed reporting of process stats commit dc8e6974db9500c3ef5e887e099ef5bf7faba555 Author: Carter Waxman Date: Wed Mar 9 10:53:10 2016 -0500 fixed reporting of process stats --- diff --git a/src/framework/module.cc b/src/framework/module.cc index 076a0cdf4..510fbc7cd 100644 --- a/src/framework/module.cc +++ b/src/framework/module.cc @@ -71,10 +71,18 @@ void Module::sum_stats() if ( !p ) return; - for ( int i = 0; i < num_counts; i++ ) + if ( global_stats() ) + { + for ( int i = 0; i < num_counts; i++ ) + counts[i] = p[i]; + } + else { - counts[i] += p[i]; - p[i] = 0; + for ( int i = 0; i < num_counts; i++ ) + { + counts[i] += p[i]; + p[i] = 0; + } } } diff --git a/src/framework/module.h b/src/framework/module.h index 51a3aaae6..7733dd07a 100644 --- a/src/framework/module.h +++ b/src/framework/module.h @@ -141,6 +141,9 @@ public: virtual const char* get_defaults() const { return nullptr; } + virtual bool global_stats() const + { return false; } + virtual void sum_stats(); virtual void show_interval_stats(IndexVec&); virtual void show_stats(); diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 74cb71488..2f4613854 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -518,6 +518,7 @@ public: bool set(const char*, Value&, SnortConfig*) override; const PegInfo* get_pegs() const override { return proc_names; } PegCount* get_counts() const override { return (PegCount*) &proc_stats; } + bool global_stats() const override { return true; } }; bool SnortModule::set(const char*, Value& v, SnortConfig* sc)