json_object_set_new(server_msg, "message", js);
SCReturnInt(TM_ECODE_OK);
}
+
+static TmEcode UnixManagerRulesetProfileStartCommand(json_t *cmd, json_t *server_msg, void *data)
+{
+ SCEnter();
+
+ int ret = SCProfileRuleStartCollection();
+ if (ret != TM_ECODE_OK) {
+ json_object_set_new(server_msg, "message", json_string("NOK"));
+ SCReturnInt(TM_ECODE_FAILED);
+ }
+ json_object_set_new(server_msg, "message", json_string("OK"));
+ SCReturnInt(TM_ECODE_OK);
+}
+
+static TmEcode UnixManagerRulesetProfileStopCommand(json_t *cmd, json_t *server_msg, void *data)
+{
+ SCEnter();
+
+ int ret = SCProfileRuleStopCollection();
+ if (ret != TM_ECODE_OK) {
+ json_object_set_new(server_msg, "message", json_string("NOK"));
+ SCReturnInt(TM_ECODE_FAILED);
+ }
+ json_object_set_new(server_msg, "message", json_string("OK"));
+ SCReturnInt(TM_ECODE_OK);
+}
+
#endif
static TmEcode UnixManagerShowFailedRules(json_t *cmd,
UnixManagerRegisterCommand("ruleset-failed-rules", UnixManagerShowFailedRules, NULL, 0);
#ifdef PROFILE_RULES
UnixManagerRegisterCommand("ruleset-profile", UnixManagerRulesetProfileCommand, NULL, 0);
+ UnixManagerRegisterCommand(
+ "ruleset-profile-start", UnixManagerRulesetProfileStartCommand, NULL, 0);
+ UnixManagerRegisterCommand(
+ "ruleset-profile-stop", UnixManagerRulesetProfileStopCommand, NULL, 0);
#endif
UnixManagerRegisterCommand("register-tenant-handler", UnixSocketRegisterTenantHandler, &command, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("unregister-tenant-handler", UnixSocketUnregisterTenantHandler, &command, UNIX_CMD_TAKE_ARGS);
int profiling_output_to_file = 0;
static SC_ATOMIC_DECLARE(uint64_t, samples);
static uint64_t rate = 0;
+int profiling_rules_active = 0;
/**
* \brief Initialize profiling.
/* see if we want to profile rules for this packet */
int SCProfileRuleStart(Packet *p)
{
+ if (profiling_rules_active != 1) {
+ return 0;
+ }
uint64_t sample = SC_ATOMIC_ADD(samples, 1);
if ((sample & rate) == 0) {
p->flags |= PKT_PROFILE;
return 0;
}
+int SCProfileRuleStartCollection(void)
+{
+ profiling_rules_active = 1;
+ SCReturnInt(TM_ECODE_OK);
+}
+
+int SCProfileRuleStopCollection(void)
+{
+ profiling_rules_active = 0;
+ SCReturnInt(TM_ECODE_OK);
+}
+
#endif /* PROFILING */