]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata: Use getconf to determine the number of processors
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Sep 2024 09:55:34 +0000 (11:55 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Sep 2024 08:41:59 +0000 (08:41 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/suricata

index 0c60c511989535e9934ba25b5739e5eb115dca16..06ad21afa4f6c97b36c27a3baff79efae3a95708 100644 (file)
@@ -51,24 +51,6 @@ enabled_ips_zones=()
 # PID file of suricata.
 PID_FILE="/var/run/suricata.pid"
 
-# Function to get the amount of CPU cores of the system.
-get_cpu_count() {
-       CPUCOUNT=0
-
-       # Loop through "/proc/cpuinfo" and count the amount of CPU cores.
-       while read line; do
-               [ "$line" ] && [ -z "${line%processor*}" ]  && ((CPUCOUNT++))
-       done </proc/cpuinfo
-
-       # Limit to a maximum of 16 cores, because suricata does not support more than
-       # 16 netfilter queues at the moment.
-       if [ $CPUCOUNT -gt "16" ]; then
-               echo "16"
-       else
-               echo $CPUCOUNT
-       fi
-}
-
 # Function to flush the firewall chains.
 flush_fw_chain() {
        iptables -w -t mangle -F IPS
@@ -79,7 +61,7 @@ generate_fw_rules() {
        # Assign NFQ_OPTS
        local NFQ_OPTIONS=( "${NFQ_OPTS[@]}" )
 
-       local cpu_count="$(get_cpu_count)"
+       local cpu_count="$(getconf _NPROCESSORS_ONLN)"
 
        # Check if there are multiple cpu cores available.
        if [ "$cpu_count" -gt "1" ]; then