diff --git a/prowler/lib/check/check.py b/prowler/lib/check/check.py index 7f29a73a..893ce0d2 100644 --- a/prowler/lib/check/check.py +++ b/prowler/lib/check/check.py @@ -356,14 +356,20 @@ def execute_checks( audit_progress=0, ) - if not sys.platform.startswith("win32") or not sys.platform.startswith("cygwin"): - from resource import RLIMIT_NOFILE, getrlimit + if os.name != "nt": + try: + from resource import RLIMIT_NOFILE, getrlimit - # Check ulimit for the maximum system open files - soft, _ = 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/" + # Check ulimit for the maximum system open files + soft, _ = 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/" + ) + except Exception as error: + logger.error("Unable to retrieve ulimit default settings") + logger.error( + f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) # Execution with the --only-logs flag