Go to the documentation of this file.
47 #define DEFAULT_LOG_FILENAME "stats.log"
48 #define MODULE_NAME "LogStatsLog"
49 #define OUTPUT_BUFFER_SIZE 16384
51 #define LOG_STATS_TOTALS (1<<0)
52 #define LOG_STATS_THREADS (1<<1)
53 #define LOG_STATS_NULLS (1<<2)
57 static void LogStatsLogDeInitCtx(
OutputCtx *);
77 gettimeofday(&tval, NULL);
82 double up_time_d = difftime(tval.tv_sec, st->
start_time);
83 int up_time = (int)up_time_d;
84 int sec = up_time % 60;
85 int in_min = up_time / 60;
86 int min = in_min % 60;
87 int in_hours = in_min / 60;
88 int hours = in_hours % 24;
89 int days = in_hours / 24;
92 "--------------------------------------\n");
94 "%02d:%02d:%02d (uptime: %"PRId32
"d, %02dh %02dm %02ds)\n",
95 tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900, tms->tm_hour,
96 tms->tm_min, tms->tm_sec, days, hours, min, sec);
98 "--------------------------------------\n");
102 "--------------------------------------\n");
107 for (u = 0; u < st->
nstats; u++) {
115 size_t len = snprintf(line,
sizeof(line),
"%-45s | %-25s | %-" PRIu64
"\n",
132 for (x = 0; x < st->
ntstats; x++) {
144 size_t len = snprintf(line,
sizeof(line),
"%-45s | %-25s | %-" PRIi64
"\n",
175 SCLogDebug(
"Error getting context for LogStats. \"initdata\" argument NULL");
181 if (aft->
buffer == NULL) {
216 if (file_ctx == NULL) {
227 if (
unlikely(statslog_ctx == NULL)) {
239 SCLogDebug(
"totals %s threads %s", totals, threads);
245 SCLogError(
"Cannot disable both totals and threads in stats logging");
270 output_ctx->
data = statslog_ctx;
271 output_ctx->
DeInit = LogStatsLogDeInitCtx;
275 result.
ctx = output_ctx;
280 static void LogStatsLogDeInitCtx(
OutputCtx *output_ctx)
#define OUTPUT_BUFFER_SIZE
TmEcode LogStatsLogThreadDeinit(ThreadVars *, void *)
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
int MemBufferExpand(MemBuffer **buffer, uint32_t expand_by)
expand membuffer by size of 'expand_by'
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
struct LogStatsLogThread_ LogStatsLogThread
TmEcode LogStatsLogThreadInit(ThreadVars *, const void *, void **)
int ConfValIsTrue(const char *val)
Check if a value is true.
int SCConfLogOpenGeneric(ConfNode *conf, LogFileCtx *log_ctx, const char *default_filename, int rotate)
open a generic output "log file", which may be a regular file or a socket
Per thread variable structure.
struct LogStatsFileCtx_ LogStatsFileCtx
struct tm * SCLocalTime(time_t timep, struct tm *result)
void LogStatsLogRegister(void)
#define MemBufferReset(mem_buffer)
Reset the mem buffer.
#define DEFAULT_LOG_FILENAME
void(* DeInit)(struct OutputCtx_ *)
LogStatsFileCtx * statslog_ctx
void MemBufferFree(MemBuffer *buffer)
#define MemBufferWriteString(dst,...)
Write a string buffer to the Membuffer dst.
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
#define SCLogError(...)
Macro used to log ERROR messages.
#define MEMBUFFER_SIZE(mem_buffer)
Get the MemBuffers current size.
int ConfValIsFalse(const char *val)
Check if a value is false.
#define LOG_STATS_THREADS
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
void OutputRegisterStatsModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a stats data output module.
MemBuffer * MemBufferCreateNew(uint32_t size)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.