]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
counters: turn flow.memuse into a global counter
authorVictor Julien <victor@inliniac.net>
Tue, 26 May 2015 17:44:01 +0000 (19:44 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 27 May 2015 12:14:47 +0000 (14:14 +0200)
src/flow-manager.c

index 3739a2f874567f8e0c8bb40cfb9866b557936c6f..2d86b81c6a36cb0de92bc94749ea8545f5c30bbb 100644 (file)
@@ -489,7 +489,6 @@ typedef struct FlowManagerThreadData_ {
     uint16_t flow_mgr_cnt_clo;
     uint16_t flow_mgr_cnt_new;
     uint16_t flow_mgr_cnt_est;
-    uint16_t flow_mgr_memuse;
     uint16_t flow_mgr_spare;
     uint16_t flow_emerg_mode_enter;
     uint16_t flow_emerg_mode_over;
@@ -527,7 +526,6 @@ static TmEcode FlowManagerThreadInit(ThreadVars *t, void *initdata, void **data)
     ftd->flow_mgr_cnt_clo = StatsRegisterCounter("flow_mgr.closed_pruned", t);
     ftd->flow_mgr_cnt_new = StatsRegisterCounter("flow_mgr.new_pruned", t);
     ftd->flow_mgr_cnt_est = StatsRegisterCounter("flow_mgr.est_pruned", t);
-    ftd->flow_mgr_memuse = StatsRegisterCounter("flow.memuse", t);
     ftd->flow_mgr_spare = StatsRegisterCounter("flow.spare", t);
     ftd->flow_emerg_mode_enter = StatsRegisterCounter("flow.emerg_mode_entered", t);
     ftd->flow_emerg_mode_over = StatsRegisterCounter("flow.emerg_mode_over", t);
@@ -630,8 +628,6 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
         StatsAddUI64(th_v, ftd->flow_mgr_cnt_clo, (uint64_t)counters.clo);
         StatsAddUI64(th_v, ftd->flow_mgr_cnt_new, (uint64_t)counters.new);
         StatsAddUI64(th_v, ftd->flow_mgr_cnt_est, (uint64_t)counters.est);
-        long long unsigned int flow_memuse = SC_ATOMIC_GET(flow_memuse);
-        StatsSetUI64(th_v, ftd->flow_mgr_memuse, (uint64_t)flow_memuse);
         StatsAddUI64(th_v, ftd->flow_tcp_reuse, (uint64_t)counters.tcp_reuse);
 
         uint32_t len = 0;
@@ -695,6 +691,12 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
     return TM_ECODE_OK;
 }
 
+static uint64_t FlowGetMemuse(void)
+{
+    uint64_t flow_memuse = SC_ATOMIC_GET(flow_memuse);
+    return flow_memuse;
+}
+
 /** \brief spawn the flow manager thread */
 void FlowManagerThreadSpawn()
 {
@@ -712,6 +714,8 @@ void FlowManagerThreadSpawn()
     SCCtrlCondInit(&flow_manager_ctrl_cond, NULL);
     SCCtrlMutexInit(&flow_manager_ctrl_mutex, NULL);
 
+    StatsRegisterGlobalCounter("flow.memuse", FlowGetMemuse);
+
     uint32_t u;
     for (u = 0; u < flowmgr_number; u++) {
         ThreadVars *tv_flowmgr = NULL;