mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
chore(ulimit): handle low ulimit value on shell session for POSIX if max open files is below 4096 (#3601)
This commit is contained in:
@@ -7,6 +7,7 @@ import shutil
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user