From 355f237bfdd5c272911507fa6ba821d463735c99 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 17 Dec 2010 12:02:20 +0100 Subject: [PATCH] Fix compiler warnings, cleanup counters config code. --- src/alert-fastlog.c | 2 +- src/counters.c | 23 ++++++++++++++--------- suricata.yaml | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index fabfbca56b..12e8c65892 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -115,7 +115,7 @@ static void CreateTimeString (const struct timeval *ts, char *str, size_t size) struct tm *t = (struct tm *)localtime_r(&time, &local_tm); snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u", - t->tm_mon + 1, t->tm_mday, 1, t->tm_year + 1900, t->tm_hour, + t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour, t->tm_min, t->tm_sec, (uint32_t) ts->tv_usec); } diff --git a/src/counters.c b/src/counters.c index 6472d4e21b..343aa22a7d 100644 --- a/src/counters.c +++ b/src/counters.c @@ -43,8 +43,10 @@ static SCPerfOPIfaceContext *sc_perf_op_ctx = NULL; static time_t sc_start_time; -static uint32_t sc_counter_int = SC_PERF_MGMTT_TTS; -static const char *enabled = "yes"; +/** refresh interval in seconds */ +static uint32_t sc_counter_tts = SC_PERF_MGMTT_TTS; +/** is the stats counter enabled? */ +static char sc_counter_enabled = TRUE; /** * \brief Adds a value of type uint64_t to the local counter. @@ -319,14 +321,15 @@ static void SCPerfInitOPCtx(void) } /* Check if the stats module is enabled or not */ if (stats != NULL) { - enabled = ConfNodeLookupChildValue(stats, "enabled"); - if (strncmp(enabled, "no", 2) == 0) { + const char *enabled = ConfNodeLookupChildValue(stats, "enabled"); + if (strcasecmp(enabled, "no") == 0) { + sc_counter_enabled = FALSE; SCLogDebug("Stats module has been disabled"); SCReturn; } const char *interval = ConfNodeLookupChildValue(stats, "interval"); if (interval != NULL) - sc_counter_int = (uint32_t) atoi(interval); + sc_counter_tts = (uint32_t) atoi(interval); } /* Store the engine start time */ @@ -443,7 +446,7 @@ static void *SCPerfMgmtThread(void *arg) while (run) { TmThreadTestThreadUnPaused(tv_local); - cond_time.tv_sec = time(NULL) + sc_counter_int; + cond_time.tv_sec = time(NULL) + sc_counter_tts; cond_time.tv_nsec = 0; SCMutexLock(tv_local->m); @@ -1148,8 +1151,10 @@ void SCPerfInitCounterApi(void) */ void SCPerfSpawnThreads(void) { - if (strncmp(enabled, "no", 2) == 0) { - return; + SCEnter(); + + if (!sc_counter_enabled) { + SCReturn; } ThreadVars *tv_wakeup = NULL; @@ -1183,7 +1188,7 @@ void SCPerfSpawnThreads(void) exit(EXIT_FAILURE); } - return; + SCReturn; } /** diff --git a/suricata.yaml b/suricata.yaml index eb88d2e3ba..f033c63c6f 100644 --- a/suricata.yaml +++ b/suricata.yaml @@ -83,8 +83,8 @@ outputs: # on the log file. - stats: enabled: yes - filename: stats1.log - interval: 40 + filename: stats.log + interval: 8 defrag: max-frags: 65535