Added checking of negated "totals" and "threads" config values for stats.

pull/1845/head
Maxtors 10 years ago committed by Victor Julien
parent 6f79137971
commit 4b8bd9dfc9

@ -245,6 +245,15 @@ OutputCtx *LogStatsLogInitCtx(ConfNode *conf)
const char *nulls = ConfNodeLookupChildValue(conf, "null-values");
SCLogDebug("totals %s threads %s", totals, threads);
if ((totals != NULL && ConfValIsFalse(totals)) &&
(threads != NULL && ConfValIsFalse(threads))) {
LogFileFreeCtx(file_ctx);
SCFree(statslog_ctx);
SCLogError(SC_ERR_STATS_LOG_NEGATED,
"Cannot disable both totals and threads in stats logging");
return NULL;
}
if (totals != NULL && ConfValIsFalse(totals)) {
statslog_ctx->flags &= ~LOG_STATS_TOTALS;
}

@ -327,6 +327,14 @@ OutputCtx *OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
const char *deltas = ConfNodeLookupChildValue(conf, "deltas");
SCLogDebug("totals %s threads %s deltas %s", totals, threads, deltas);
if ((totals != NULL && ConfValIsFalse(totals)) &&
(threads != NULL && ConfValIsFalse(threads))) {
SCFree(stats_ctx);
SCLogError(SC_ERR_JSON_STATS_LOG_NEGATED,
"Cannot disable both totals and threads in stats logging");
return NULL;
}
if (totals != NULL && ConfValIsFalse(totals)) {
stats_ctx->flags &= ~JSON_STATS_TOTALS;
}

@ -312,6 +312,8 @@ const char * SCErrorToString(SCError err)
CASE_CODE (SC_ERR_MT_NO_MAPPING);
CASE_CODE (SC_ERR_NO_JSON_SUPPORT);
CASE_CODE (SC_ERR_INVALID_RULE_ARGUMENT);
CASE_CODE (SC_ERR_STATS_LOG_NEGATED);
CASE_CODE (SC_ERR_JSON_STATS_LOG_NEGATED);
}
return "UNKNOWN_ERROR";

@ -302,6 +302,8 @@ typedef enum {
SC_ERR_INVALID_RULE_ARGUMENT, /**< Generic error code for invalid
* rule argument. */
SC_ERR_MT_NO_MAPPING,
SC_ERR_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/
SC_ERR_JSON_STATS_LOG_NEGATED, /** When totals and threads are both NO in yaml **/
} SCError;
const char *SCErrorToString(SCError);

Loading…
Cancel
Save