stats log: suppress 0 counters by default

pull/1784/head
Victor Julien 9 years ago
parent 86a3f06410
commit 36fde7df42

@ -51,6 +51,7 @@
#define LOG_STATS_TOTALS (1<<0)
#define LOG_STATS_THREADS (1<<1)
#define LOG_STATS_NULLS (1<<2)
TmEcode LogStatsLogThreadInit(ThreadVars *, void *, void **);
TmEcode LogStatsLogThreadDeinit(ThreadVars *, void *);
@ -108,6 +109,9 @@ int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *st)
if (st->stats[u].name == NULL)
continue;
if (!(aft->statslog_ctx->flags & LOG_STATS_NULLS) && st->stats[u].value == 0)
continue;
char line[1024];
size_t len = snprintf(line, sizeof(line), "%-25s | %-25s | %-" PRIu64 "\n",
st->stats[u].name, st->stats[u].tm_name, st->stats[u].value);
@ -238,6 +242,7 @@ OutputCtx *LogStatsLogInitCtx(ConfNode *conf)
if (conf != NULL) {
const char *totals = ConfNodeLookupChildValue(conf, "totals");
const char *threads = ConfNodeLookupChildValue(conf, "threads");
const char *nulls = ConfNodeLookupChildValue(conf, "null-values");
SCLogDebug("totals %s threads %s", totals, threads);
if (totals != NULL && ConfValIsFalse(totals)) {
@ -246,6 +251,9 @@ OutputCtx *LogStatsLogInitCtx(ConfNode *conf)
if (threads != NULL && ConfValIsTrue(threads)) {
statslog_ctx->flags |= LOG_STATS_THREADS;
}
if (nulls != NULL && ConfValIsTrue(nulls)) {
statslog_ctx->flags |= LOG_STATS_NULLS;
}
SCLogDebug("statslog_ctx->flags %08x", statslog_ctx->flags);
}

@ -315,6 +315,7 @@ outputs:
filename: stats.log
totals: yes # stats for all threads merged together
threads: no # per thread stats
#null-values: yes # print counters that have value 0
# a line based alerts log similar to fast.log into syslog
- syslog:

Loading…
Cancel
Save