This function counts the number of active system processes (threads) that match a given pattern and exceed a specified minimum CPU usage threshold. It works on Unix-like systems (e.g., Linux, macOS) and does not support Windows.
detectActiveCores(pattern = "", minCPU = 50)An integer representing the number of active threads matching the
pattern and exceeding the CPU usage threshold. Returns NULL with a
message if run on Windows.
This function uses the ps -ef system command and regular expressions
to parse CPU usage. It may not be portable across all Unix variants.
if (FALSE) { # \dontrun{
detectActiveCores(pattern = "R", minCPU = 30)
} # }