{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
-static const Parameter profile_preproc_params[] =
+static const Parameter profile_module_params[] =
{
{ "count", Parameter::PT_INT, "-1:", "-1",
"print results to given level (-1 = all, 0 = off?)" },
{ "rules", Parameter::PT_TABLE, profile_rule_params, nullptr,
"" },
- { "preprocs", Parameter::PT_TABLE, profile_preproc_params, nullptr,
+ { "modules", Parameter::PT_TABLE, profile_module_params, nullptr,
"" },
{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
public:
ProfileModule() : Module("profile", profile_params) { };
bool set(const char*, Value&, SnortConfig*);
+ bool begin(const char*, int, SnortConfig*);
};
+bool ProfileModule::begin(const char* fqn, int, SnortConfig* sc)
+{
+ if ( !strcmp(fqn, "profile.rules") )
+ sc->profile_rules.num = -1;
+
+ else if ( !strcmp(fqn, "profile.modules") )
+ sc->profile_preprocs.num = -1;
+
+ return true;
+}
+
bool ProfileModule::set(const char* fqn, Value& v, SnortConfig* sc)
{
ProfileConfig* p;
const char* spr = "profile.rules";
- const char* spp = "profile.preprocs";
+ const char* spp = "profile.modules";
if ( !strncmp(fqn, spr, strlen(spr)) )
p = &sc->profile_rules;
static void register_profiles()
{
- RegisterProfile("detect", "total", get_profile);
+ RegisterProfile("detect", nullptr, get_profile);
RegisterProfile("mpse", "detect", get_profile);
RegisterProfile("rule eval", "detect", get_profile);
RegisterProfile("rtn eval", "rule eval", get_profile);
RegisterProfile("rule tree eval", "rule eval", get_profile);
- RegisterProfile("decode", "total", get_profile);
- RegisterProfile("eventq", "total", get_profile);
+ RegisterProfile("decode", nullptr, get_profile);
+ RegisterProfile("eventq", nullptr, get_profile);
RegisterProfile("total", nullptr, get_profile);
RegisterProfile("daq meta", nullptr, get_profile);
}
static ProfileStatsNode* get_node(const char*);
+#define TOTAL "total"
+
+static ProfileStatsNode* get_root(ProfileStatsNode* idx)
+{
+ while ( idx->parent )
+ idx = idx->parent;
+ return idx;
+}
+
static void set_node(ProfileStatsNode* idx)
{
idx->parent = get_node(idx->pname);
- if ( idx->parent )
+ if ( idx->pname && strcasecmp(idx->pname, TOTAL) )
idx->layer = idx->parent->layer + 1;
}
const char* keyword, const char* parent, get_profile_func get, Module* mod)
{
ProfileStatsNode *node;
-
node = (ProfileStatsNode *)SnortAlloc(sizeof(ProfileStatsNode));
if (gProfileStatsNodeList == NULL)
node->owner = mod;
node->parent = nullptr;
+ if ( !node->pname && strcasecmp(node->name, TOTAL) )
+ node->pname = TOTAL;
+
// FIXIT wtf?
//if ( !strcasecmp(node->name, "mpse") )
// mpsePerfStats = stats;
gProfileStatsNodeList = NULL;
}
-#if 0
-// FIXIT what was this for?
-// FIXIT profile stats is broken - need to accumulate across threads
-// as each thread shuts down into the main thread data
-// looks like this was supposed to help do that
-static ProfileStatsNode* accumulate(ProfileStatsNode* node)
-{
- ProfileStatsNode* last = NULL;
- ProfileStatsNode* p = gProfileStatsNodeList;
-
- while ( p && strcmp(p->name, node->name ) )
- {
- last = p;
- p = p->next;
- }
- if ( !p )
- {
- if ( last )
- last->next = node;
- else
- gProfileStatsNodeList = node;
- node->next = NULL;
- return NULL;
- }
- return node;
-}
-#endif
-
// from packet thread only
void ReleaseProfileStats(void)
{
idx= idx->next, num++)
{
/* Skip the total counter */
- if ( !strcasecmp(idx->node->name, "total") )
+ if ( !strcasecmp(idx->node->name, TOTAL) )
{
num--;
total = idx;
{
/* Find this idx's parent in the list */
parent = findPerfParent(idx, worstPreprocPerformers);
- if (parent && strcasecmp(parent->node->name, "total"))
+ if (parent && strcasecmp(parent->node->name, TOTAL))
{
listhead = parent->children;
}
parent = NULL;
}
pwp->pct_of_parent = (double)idx->stats.ticks/idx->parent->stats.ticks*100.0;
- pwp->pct_of_total = (double)idx->stats.ticks/totalPerfStats.ticks*100.0;
+ pwp->pct_of_total = (double)idx->stats.ticks/get_root(idx)->stats.ticks*100.0;
}
else
{