diff --git a/prowler/lib/check/check.py b/prowler/lib/check/check.py index 901e1c57e0..f442400e30 100644 --- a/prowler/lib/check/check.py +++ b/prowler/lib/check/check.py @@ -7,6 +7,7 @@ import sys import traceback from pkgutil import walk_packages +from resource import setrlimit from types import ModuleType from typing import Any @@ -448,11 +449,13 @@ def execute_checks( from resource import RLIMIT_NOFILE, getrlimit # Check ulimit for the maximum system open files - soft, _ = getrlimit(RLIMIT_NOFILE) + soft, hard = getrlimit(RLIMIT_NOFILE) if soft < 4096: - logger.warning( - f"Your session file descriptors limit ({soft} open files) is below 4096. We recommend to increase it to avoid errors. Solve it running this command `ulimit -n 4096`. For more info visit https://docs.prowler.cloud/en/latest/troubleshooting/" + logger.info( + f"Your session file descriptors limit ({soft} open files) is below 4096. Updating file descriptors session limit to 4096 during execution only." ) + # Set the soft ulimit to 4096 + setrlimit(RLIMIT_NOFILE, (4096, hard)) except Exception as error: logger.error("Unable to retrieve ulimit default settings") logger.error(