48 #define DEFAULT_LOG_FILENAME "stats.log" 49 #define MODULE_NAME "LogStatsLog" 50 #define OUTPUT_BUFFER_SIZE 16384 52 #define LOG_STATS_TOTALS (1<<0) 53 #define LOG_STATS_THREADS (1<<1) 54 #define LOG_STATS_NULLS (1<<2) 58 static void LogStatsLogDeInitCtx(
OutputCtx *);
78 gettimeofday(&tval, NULL);
83 double up_time_d = difftime(tval.tv_sec, st->
start_time);
84 int up_time = (int)up_time_d;
85 int sec = up_time % 60;
86 int in_min = up_time / 60;
87 int min = in_min % 60;
88 int in_hours = in_min / 60;
89 int hours = in_hours % 24;
90 int days = in_hours / 24;
93 "--------------------------------------\n");
95 "%02d:%02d:%02d (uptime: %"PRId32
"d, %02dh %02dm %02ds)\n",
96 tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900, tms->tm_hour,
97 tms->tm_min, tms->tm_sec, days, hours, min, sec);
99 "--------------------------------------\n");
103 "--------------------------------------\n");
108 for (u = 0; u < st->
nstats; u++) {
116 size_t len = snprintf(line,
sizeof(line),
"%-45s | %-25s | %-" PRIu64
"\n",
133 for (x = 0; x < st->
ntstats; x++) {
137 for (u = offset; u < (offset + st->
nstats); u++) {
145 size_t len = snprintf(line,
sizeof(line),
"%-45s | %-25s | %-" PRIu64
"\n",
176 SCLogDebug(
"Error getting context for LogStats. \"initdata\" argument NULL");
182 if (aft->
buffer == NULL) {
217 if (file_ctx == NULL) {
228 if (
unlikely(statslog_ctx == NULL)) {
240 SCLogDebug(
"totals %s threads %s", totals, threads);
247 "Cannot disable both totals and threads in stats logging");
272 output_ctx->
data = statslog_ctx;
273 output_ctx->
DeInit = LogStatsLogDeInitCtx;
277 result.
ctx = output_ctx;
282 static void LogStatsLogDeInitCtx(
OutputCtx *output_ctx)
MemBuffer * MemBufferCreateNew(uint32_t size)
#define LOG_STATS_THREADS
#define MEMBUFFER_SIZE(mem_buffer)
Get the MemBuffers current size.
#define OUTPUT_BUFFER_SIZE
#define MemBufferWriteString(dst,...)
Write a string buffer to the Membuffer dst.
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.
#define MemBufferReset(mem_buffer)
Reset the mem buffer.
void(* DeInit)(struct OutputCtx_ *)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
struct tm * SCLocalTime(time_t timep, struct tm *result)
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
TmEcode LogStatsLogThreadDeinit(ThreadVars *, void *)
TmEcode LogStatsLogThreadInit(ThreadVars *, const void *, void **)
int ConfValIsFalse(const char *val)
Check if a value is false.
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
struct LogStatsLogThread_ LogStatsLogThread
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
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
int ConfValIsTrue(const char *val)
Check if a value is true.
struct LogStatsFileCtx_ LogStatsFileCtx
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
void LogStatsLogRegister(void)
Per thread variable structure.
int MemBufferExpand(MemBuffer **buffer, uint32_t expand_by)
expand membuffer by size of 'expand_by'
LogStatsFileCtx * statslog_ctx
void MemBufferFree(MemBuffer *buffer)
#define DEFAULT_LOG_FILENAME