suricata
output-stats.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2013 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  * Stats Logger Output registration functions
24  */
25 
26 #ifndef __OUTPUT_STATS_H__
27 #define __OUTPUT_STATS_H__
28 
29 typedef struct StatsRecord_ {
30  const char *name;
31  const char *tm_name;
32  uint64_t value; /**< total value */
33  uint64_t pvalue; /**< prev value (may be higher for memuse counters) */
34 } StatsRecord;
35 
36 typedef struct StatsTable_ {
37  StatsRecord *stats; /**< array of global stats, indexed by counters gid */
38  StatsRecord *tstats; /**< array of arrays with per thread stats */
39  uint32_t nstats; /**< size in records of 'stats' */
40  uint32_t ntstats; /**< number of threads for which tstats stores stats */
41  time_t start_time;
42  struct timeval ts;
43 } StatsTable;
44 
45 TmEcode OutputStatsLog(ThreadVars *tv, void *thread_data, StatsTable *st);
46 
47 typedef int (*StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *);
48 
49 int OutputRegisterStatsLogger(const char *name, StatsLogger LogFunc,
50  OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
51  ThreadExitPrintStatsFunc ThreadExitPrintStats);
52 
53 void TmModuleStatsLoggerRegister (void);
54 
56 
57 void OutputStatsShutdown(void);
58 
59 #endif /* __OUTPUT_STATS_H__ */
int OutputRegisterStatsLogger(const char *name, StatsLogger LogFunc, OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output-stats.c:56
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
Definition: tm-modules.h:41
uint64_t pvalue
Definition: output-stats.h:33
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
Definition: output-stats.h:47
struct StatsTable_ StatsTable
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
StatsRecord * tstats
Definition: output-stats.h:38
const char * tm_name
Definition: output-stats.h:31
void TmModuleStatsLoggerRegister(void)
Definition: output-stats.c:198
TmEcode OutputStatsLog(ThreadVars *tv, void *thread_data, StatsTable *st)
Definition: output-stats.c:86
StatsRecord * stats
Definition: output-stats.h:37
uint64_t value
Definition: output-stats.h:32
int OutputStatsLoggersRegistered(void)
Definition: output-stats.c:207
uint64_t ts
time_t start_time
Definition: output-stats.h:41
Per thread variable structure.
Definition: threadvars.h:57
const char * name
Definition: output-stats.h:30
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
uint32_t ntstats
Definition: output-stats.h:40
uint32_t nstats
Definition: output-stats.h:39
void OutputStatsShutdown(void)
Definition: output-stats.c:214
struct StatsRecord_ StatsRecord