From: Carter Waxman Date: Wed, 13 Apr 2016 14:54:39 +0000 (-0400) Subject: added comments for perfmon APIs X-Git-Tag: 3.0.0-233~457^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=704eba6dcc3e11c97814763bbcd456efb0a21773;p=thirdparty%2Fsnort3.git added comments for perfmon APIs --- diff --git a/src/network_inspectors/perf_monitor/perf_formatter.h b/src/network_inspectors/perf_monitor/perf_formatter.h index dbb58a057..6dc53d2f2 100644 --- a/src/network_inspectors/perf_monitor/perf_formatter.h +++ b/src/network_inspectors/perf_monitor/perf_formatter.h @@ -18,6 +18,25 @@ // perf_formatter.h author Carter Waxman +// +// PerfFormatter provides an API for PerfTrackers to use for reporting data. +// The basic flow from the perspective of a PerfTracker is: +// +// 1. Call register_section to create a section of stats +// +// 2. Call register_field to insert a field into the most recently created +// section. Fields should always be pointers to stable locations in memory, +// as they cannot be updated. Data will be pulled from these pointers when +// writes occur. +// +// 3. Call finalize_fields to complete section and field registration. This is +// where any metadata needed will be sent to the provided output. +// +// 4. Set the values desired for fields. +// +// 5. Call write to output the current values in each field. +// + #ifndef PERF_FORMATTER_H #define PERF_FORMATTER_H diff --git a/src/network_inspectors/perf_monitor/perf_tracker.h b/src/network_inspectors/perf_monitor/perf_tracker.h index 442b82a24..81a65057a 100644 --- a/src/network_inspectors/perf_monitor/perf_tracker.h +++ b/src/network_inspectors/perf_monitor/perf_tracker.h @@ -18,6 +18,20 @@ // perf_tracker.h author Carter Waxman +// +// This class defines the data gathering layer of perfmon. PerfMonitor will +// create an instance of each configued class for each packet processing +// thread. Subclasses of PerfTrackers should implement or call the following +// methods, leaving the others for internal use by PerfMonitor: +// +// reset() - perform initialization after the output handle has been opened. +// +// update(Packet*) - update statistics basied on the current packet. +// +// process(bool) - summarize data and report. This is called after the +// reporting thresholds have been reached. +// + #ifndef PERF_TRACKER_H #define PERF_TRACKER_H @@ -29,14 +43,12 @@ class PerfTracker { public: - virtual void reset() { } - virtual void show() { } // FIXIT-L would it be better to let perfmon do this if it knows - // the names of fields? + virtual void reset() {} - virtual void update(Packet*) { } - virtual void update_time(time_t time) { cur_time = time; } - virtual void process(bool /*summary*/) { } //FIXIT-M get rid of this step. + virtual void update(Packet*) {}; + virtual void process(bool /*summary*/) {}; //FIXIT-M get rid of this step. + virtual void update_time(time_t time) final { cur_time = time; }; virtual void open(bool append) final; virtual void close() final; virtual void rotate() final; @@ -52,6 +64,9 @@ protected: PerfFormatter* formatter; PerfTracker(PerfConfig*, const char* tracker_fname); + +private: + }; #endif