55static int profiling_prefilter_output_to_file = 0;
58static char profiling_file_name[PATH_MAX];
59static const char *profiling_file_mode =
"a";
70 if (filename != NULL) {
72 strlcpy(profiling_file_name, filename,
sizeof(profiling_file_name));
75 snprintf(profiling_file_name,
sizeof(profiling_file_name),
"%s/%s", log_dir,
81 profiling_file_mode =
"a";
83 profiling_file_mode =
"w";
86 profiling_prefilter_output_to_file = 1;
95 fprintf(fp,
" ----------------------------------------------"
96 "------------------------------------------------------"
97 "----------------------------\n");
98 fprintf(fp,
" Stats for: %s\n",
name);
99 fprintf(fp,
" ----------------------------------------------"
100 "------------------------------------------------------"
101 "----------------------------\n");
102 fprintf(fp,
" %-32s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Prefilter",
103 "Ticks",
"Called",
"Max Ticks",
"Avg",
"Bytes",
"Called",
"Max Bytes",
"Avg Bytes",
105 fprintf(fp,
" -------------------------------- "
116 for (i = 0; i < (int)rules_ctx->
size; i++) {
118 if (d == NULL || d->
called== 0)
121 uint64_t ticks = d->
total;
124 avgticks = (double)(ticks / d->
called);
130 double ticks_per_byte = 0;
136 " %-32s %-15" PRIu64
" %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15" PRIu64
137 " %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15.2f\n",
154 gettimeofday(&tval, NULL);
157 if (profiling_prefilter_output_to_file == 1) {
158 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
160 fp = fopen(profiling_file_name, profiling_file_mode);
163 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
170 fprintf(fp,
" ----------------------------------------------"
171 "------------------------------------------------------"
172 "----------------------------\n");
173 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
174 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
175 tms->tm_hour,tms->tm_min, tms->tm_sec);
184 SCLogPerf(
"Done dumping prefilter profiling data.");
195 uint64_t bytes, uint64_t bytes_called)
218 if (pthread_mutex_init(&
ctx->data_m, NULL) != 0) {
219 FatalError(
"Failed to initialize hash table mutex.");
229 if (
ctx->data != NULL)
231 pthread_mutex_destroy(&
ctx->data_m);
239 SCProfilingPrefilterDump(
de_ctx);
287 SCProfilingPrefilterThreadMerge(det_ctx->
de_ctx, det_ctx);
324 SCLogPerf(
"Registered %"PRIu32
" prefilter profiling counters.", size);
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
Test if a configuration node has a true value.
int SCConfValIsTrue(const char *val)
Check if a value is true.
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
main detection engine ctx
HashListTable * prefilter_hash_table
struct SCProfilePrefilterDetectCtx_ * profile_prefilter_ctx
struct SCProfilePrefilterData_ * prefilter_perf_data
SCProfilePrefilterData * data
size_t strlcpy(char *dst, const char *src, size_t siz)
const char * SCConfigGetLogDirectory(void)
#define SCLogError(...)
Macro used to log ERROR messages.
HashListTableBucket * HashListTableGetListHead(HashListTable *ht)
#define HashListTableGetListData(hb)
#define HashListTableGetListNext(hb)
int PathIsAbsolute(const char *path)
Check if a path is absolute.
void SCProfilingPrefilterInitCounters(DetectEngineCtx *de_ctx)
Register the prefilter profiling counters.
void SCProfilingPrefilterUpdateCounter(DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, uint64_t bytes, uint64_t bytes_called)
Update a rule counter.
struct SCProfilePrefilterDetectCtx_ SCProfilePrefilterDetectCtx
int profiling_prefilter_enabled
void SCProfilingPrefilterThreadCleanup(DetectEngineThreadCtx *det_ctx)
void SCProfilingPrefilterThreadSetup(SCProfilePrefilterDetectCtx *ctx, DetectEngineThreadCtx *det_ctx)
thread_local int profiling_prefilter_entered
struct SCProfilePrefilterData_ SCProfilePrefilterData
void SCProfilingPrefilterGlobalInit(void)
void SCProfilingPrefilterDestroyCtx(DetectEngineCtx *de_ctx)
struct tm * SCLocalTime(time_t timep, struct tm *result)