]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
profiling: add option to active rules profiling at start
authorEric Leblond <el@stamus-networks.com>
Wed, 8 Nov 2023 20:18:33 +0000 (21:18 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 21 Jun 2024 08:21:23 +0000 (10:21 +0200)
When replaying a pcap file, it is not possible to get rules
profiling because it has to be activated from the unix socket.
This patch adds a new option to be able to activate profiling
collection at start so a pcap run can get rules profiling
information.

(cherry picked from commit eecb3440e21c428e86bc60e1bbe5808ef4c27a6c)

src/util-profiling.c
suricata.yaml.in

index e1f19ad20c4113bf64daeb01d258b77eb70f518a..4473b57dbd065b23224383b60aa6faf1f4e3df50 100644 (file)
@@ -1430,6 +1430,7 @@ void SCProfilingInit(void)
     SC_ATOMIC_INIT(profiling_rules_active);
     SC_ATOMIC_INIT(samples);
     intmax_t rate_v = 0;
+    ConfNode *conf;
 
     (void)ConfGetInt("profiling.sample-rate", &rate_v);
     if (rate_v > 0 && rate_v < INT_MAX) {
@@ -1446,6 +1447,11 @@ void SCProfilingInit(void)
         else
             SCLogInfo("profiling runs for every packet");
     }
+
+    conf = ConfGetNode("profiling.rules");
+    if (ConfNodeChildValueIsTrue(conf, "active")) {
+        SC_ATOMIC_SET(profiling_rules_active, 1);
+    }
 }
 
 /* see if we want to profile rules for this packet */
index 052eef93fda90b6f41943d70804846ae4bab2369..458360b1e64f691fbc9b6e91a34d170d5ebfd7e9 100644 (file)
@@ -1812,6 +1812,10 @@ profiling:
     enabled: yes
     filename: rule_perf.log
     append: yes
+    # Set active to yes to enable rules profiling at start
+    # if set to no (default), the rules profiling will have to be started
+    # via unix socket commands.
+    #active:no
 
     # Sort options: ticks, avgticks, checks, matches, maxticks
     # If commented out all the sort options will be used.