From: Victor Julien Date: Fri, 24 May 2024 16:27:11 +0000 (+0200) Subject: defrag: add defrag.memuse counter X-Git-Tag: suricata-8.0.0-beta1~1218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75b78d76433c0be0de3552da98adccbad490ac4e;p=thirdparty%2Fsuricata.git defrag: add defrag.memuse counter Gives a current snapshot of the memory in use by the defrag engine. --- diff --git a/etc/schema.json b/etc/schema.json index 7d3f92801e..f72fd050f8 100644 --- a/etc/schema.json +++ b/etc/schema.json @@ -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", diff --git a/src/flow-manager.c b/src/flow-manager.c index 5bbc2e88b7..b81b2dd9ff 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -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);