Add system requirement cheks.

This commit is contained in:
Oliver Gwyther 2024-04-15 23:16:11 +01:00
parent 00061c256e
commit c7500358a0
2 changed files with 70 additions and 0 deletions

View File

@ -14,6 +14,40 @@ echo "Installing dependencies..."
# Install prerequisites for Graylog, OpenSearch, and MongoDB
apt install -y apt-transport-https openjdk-11-jre-headless uuid-runtime pwgen wget gnupg
# Function to check if the system meets the minimum requirements for Graylog
check_system_requirements() {
echo "Checking system requirements for Graylog..."
# Minimum required RAM (in MB)
minimum_ram=4096
# Minimum required disk space (in GB)
minimum_disk_space=50
# Get total RAM in the system
total_ram=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
# Get total disk space in the system
total_disk_space=$(df -BG --output=avail / | sed '1d' | awk '{print $1}' | sed 's/G//')
# Check if RAM meets the minimum requirements
if [ "$total_ram" -lt "$minimum_ram" ]; then
echo "Error: Insufficient RAM. Graylog requires a minimum of $minimum_ram MB of RAM."
exit 1
else
echo "RAM: $total_ram MB - meets minimum requirements."
fi
# Check if disk space meets the minimum requirements
if [ "$total_disk_space" -lt "$minimum_disk_space" ]; then
echo "Error: Insufficient disk space. Graylog requires a minimum of $minimum_disk_space GB of available disk space."
exit 1
else
echo "Disk space: $total_disk_space GB - meets minimum requirements."
fi
echo "System meets the minimum requirements for Graylog."
}
# Disable huge pages support
echo "Disabling huge pages support..."
echo never > /sys/kernel/mm/transparent_hugepage/enabled

View File

@ -25,6 +25,42 @@ if [[ $PYTHON_CONFIRM != "y" ]]; then
exit 1
fi
# Check other system requirements
echo "Checking other system requirements..."
RAM=$(free -m | awk '/Mem/ {print $2}')
CPU=$(grep -c ^processor /proc/cpuinfo)
DISK=$(df -h / | awk 'NR==2 {print $4}')
MIN_RAM=2048 # Minimum RAM in MB
MIN_CPU=2 # Minimum CPU cores
MIN_DISK=10 # Minimum free disk space in GB
# Check RAM
if [ "$RAM" -lt "$MIN_RAM" ]; then
echo "Error: Insufficient RAM. At least $MIN_RAM MB of RAM is required."
exit 1
fi
# Check CPU cores
if [ "$CPU" -lt "$MIN_CPU" ]; then
echo "Error: Insufficient CPU cores. At least $MIN_CPU CPU cores are required."
exit 1
fi
# Check disk space
DISK_NUM=$(echo "$DISK" | grep -o -E '[0-9]+')
DISK_UNIT=$(echo "$DISK" | grep -o -E '[A-Za-z]+')
if [ "$DISK_UNIT" == "G" ]; then
if [ "$DISK_NUM" -lt "$MIN_DISK" ]; then
echo "Error: Insufficient disk space. At least $MIN_DISK GB of free disk space is required."
exit 1
fi
else
echo "Error: Unsupported disk space unit. Please ensure disk space is in GB."
exit 1
fi
echo "System meets minimum requirements. Proceeding with installation..."
# Add Netbox repository
echo "Adding Netbox repository..."
echo "deb https://packagecloud.io/netbox-community/netbox/ubuntu/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/netbox-community.list