Detect perf counters

pull/1295/head
Victor Julien 11 years ago
parent ef6875d583
commit 30b7fdcb49

@ -1356,6 +1356,12 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
* rules haven't been loaded yet. */ * rules haven't been loaded yet. */
uint16_t counter_alerts = SCPerfTVRegisterCounter("detect.alert", tv, uint16_t counter_alerts = SCPerfTVRegisterCounter("detect.alert", tv,
SC_PERF_TYPE_UINT64, "NULL"); SC_PERF_TYPE_UINT64, "NULL");
uint16_t counter_mpm_list = SCPerfTVRegisterAvgCounter("detect.mpm_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
uint16_t counter_nonmpm_list = SCPerfTVRegisterAvgCounter("detect.nonmpm_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
uint16_t counter_match_list = SCPerfTVRegisterAvgCounter("detect.match_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
if (de_ctx->delayed_detect == 1 && de_ctx->delayed_detect_initialized == 0) { if (de_ctx->delayed_detect == 1 && de_ctx->delayed_detect_initialized == 0) {
*data = NULL; *data = NULL;
return TM_ECODE_OK; return TM_ECODE_OK;
@ -1374,6 +1380,9 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
/** alert counter setup */ /** alert counter setup */
det_ctx->counter_alerts = counter_alerts; det_ctx->counter_alerts = counter_alerts;
det_ctx->counter_mpm_list = counter_mpm_list;
det_ctx->counter_nonmpm_list = counter_nonmpm_list;
det_ctx->counter_match_list = counter_match_list;
/* pass thread data back to caller */ /* pass thread data back to caller */
*data = (void *)det_ctx; *data = (void *)det_ctx;

@ -1334,6 +1334,8 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM); PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM);
DetectMpmPrefilter(de_ctx, det_ctx, smsg, p, flags, alproto, has_state, &sms_runflags); DetectMpmPrefilter(de_ctx, det_ctx, smsg, p, flags, alproto, has_state, &sms_runflags);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM); PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM);
SCPerfCounterAddUI64(det_ctx->counter_mpm_list, th_v->sc_perf_pca, (uint64_t)det_ctx->pmq.rule_id_array_cnt);
SCPerfCounterAddUI64(det_ctx->counter_nonmpm_list, th_v->sc_perf_pca, (uint64_t)det_ctx->sgh->non_mpm_id_cnt);
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PREFILTER); PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PREFILTER);
DetectPrefilterMergeSort(de_ctx, det_ctx, det_ctx->sgh); DetectPrefilterMergeSort(de_ctx, det_ctx, det_ctx->sgh);
@ -1343,6 +1345,7 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh
/* inspect the sigs against the packet */ /* inspect the sigs against the packet */
/* Prefetch the next signature. */ /* Prefetch the next signature. */
SigIntId match_cnt = det_ctx->match_array_cnt; SigIntId match_cnt = det_ctx->match_array_cnt;
SCPerfCounterAddUI64(det_ctx->counter_match_list, th_v->sc_perf_pca, (uint64_t)match_cnt);
Signature **match_array = det_ctx->match_array; Signature **match_array = det_ctx->match_array;
uint32_t sflags, next_sflags = 0; uint32_t sflags, next_sflags = 0;

@ -791,6 +791,9 @@ typedef struct DetectionEngineThreadCtx_ {
/** id for alert counter */ /** id for alert counter */
uint16_t counter_alerts; uint16_t counter_alerts;
uint16_t counter_mpm_list;
uint16_t counter_nonmpm_list;
uint16_t counter_match_list;
/* used to discontinue any more matching */ /* used to discontinue any more matching */
uint16_t discontinue_matching; uint16_t discontinue_matching;

Loading…
Cancel
Save