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");
101 "-----------------------------------------------------\n");
106 for (u = 0; u < st->
nstats; u++) {
114 size_t len = snprintf(line,
sizeof(line),
"%-60s | %-25s | %-" PRIu64
"\n",
131 for (x = 0; x < st->
ntstats; x++) {
143 size_t len = snprintf(line,
sizeof(line),
"%-45s | %-25s | %-" PRIi64
"\n",
160 MemBufferReset(aft->
buffer);
173 SCLogDebug(
"Error getting context for LogStats. \"initdata\" argument NULL");
179 if (aft->
buffer == NULL) {
214 if (file_ctx == NULL) {
225 if (
unlikely(statslog_ctx == NULL)) {
236 SCLogDebug(
"totals %s threads %s", totals, threads);
242 SCLogError(
"Cannot disable both totals and threads in stats logging");
267 output_ctx->
data = statslog_ctx;
268 output_ctx->
DeInit = LogStatsLogDeInitCtx;
272 result.
ctx = output_ctx;
277 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
void OutputRegisterStatsModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a stats data output module.
Per thread variable structure.
struct LogStatsFileCtx_ LogStatsFileCtx
struct tm * SCLocalTime(time_t timep, struct tm *result)
void LogStatsLogRegister(void)
#define DEFAULT_LOG_FILENAME
void(* DeInit)(struct OutputCtx_ *)
LogStatsFileCtx * statslog_ctx
void MemBufferFree(MemBuffer *buffer)
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.
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
#define LOG_STATS_THREADS
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
MemBuffer * MemBufferCreateNew(uint32_t size)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.