defrag: add defrag.memuse counter

Gives a current snapshot of the memory in use by the defrag engine.
pull/11227/head
Victor Julien 2 years ago committed by Victor Julien
parent becc91c306
commit 75b78d7643

@ -5210,6 +5210,10 @@
"description":
"How many times a fragment wasn't stored due to max-frags limit being reached"
},
"memuse": {
"type": "integer",
"description": "Current memory use."
},
"memcap_exception_policy": {
"description":
"How many times defrag memcap exception policy was applied, and which one",

@ -49,6 +49,7 @@
#include "threads.h"
#include "host-timeout.h"
#include "defrag-hash.h"
#include "defrag-timeout.h"
#include "ippair-timeout.h"
#include "app-layer-htp-range.h"
@ -607,6 +608,7 @@ typedef struct FlowManagerThreadData_ {
FlowManagerTimeoutThread timeout;
uint16_t counter_defrag_timeout;
uint16_t counter_defrag_memuse;
} FlowManagerThreadData;
static void FlowCountersInit(ThreadVars *t, FlowCounters *fc)
@ -680,6 +682,7 @@ static TmEcode FlowManagerThreadInit(ThreadVars *t, const void *initdata, void *
FlowCountersInit(t, &ftd->cnt);
ftd->counter_defrag_timeout = StatsRegisterCounter("defrag.mgr.tracker_timeout", t);
ftd->counter_defrag_memuse = StatsRegisterCounter("defrag.memuse", t);
PacketPoolInit();
return TM_ECODE_OK;
@ -877,6 +880,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
}
if (other_last_sec == 0 || other_last_sec < (uint32_t)SCTIME_SECS(ts)) {
if (ftd->instance == 0) {
StatsSetUI64(th_v, ftd->counter_defrag_memuse, DefragTrackerGetMemcap());
uint32_t defrag_cnt = DefragTimeoutHash(ts);
if (defrag_cnt) {
StatsAddUI64(th_v, ftd->counter_defrag_timeout, defrag_cnt);

Loading…
Cancel
Save