From 10e46b6fc3dcf7f36fc1320627735664433be862 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 22 Apr 2020 22:42:24 -0400 Subject: [PATCH] [fix] Calc log_size_limit more accurately + actually call function --- setup/so-common-functions | 22 ++++++++++++---------- setup/so-whiptail | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/setup/so-common-functions b/setup/so-common-functions index ab50105c0..682e53fa7 100644 --- a/setup/so-common-functions +++ b/setup/so-common-functions @@ -40,13 +40,14 @@ calculate_useable_cores() { } set_defaul_log_size() { + local percentage case $INSTALLTYPE in EVAL | HEAVYNODE) - PERCENTAGE=50 + percentage=50 ;; *) - PERCENTAGE=80 + percentage=80 ;; esac @@ -54,13 +55,14 @@ set_defaul_log_size() { if [ -d /nsm ]; then disk_dir="/nsm" fi - local disk_size_kb - disk_size_kb=$(df $disk_dir |grep -v "^Filesystem" | awk '{print $2}') - local percentage=85 - local disk_size - disk_size=$(( disk_size_kb * 1000 )) - local percentage_disk_space - percentage_disk_space=$(( disk_size * (percentage / 100) )) + local disk_size_1k + disk_size_1k=$(df $disk_dir | grep -v "^Filesystem" | awk '{print $2}') - export log_size_limit=$(( percentage_disk_space / 1000000000 )) + local ratio="4.7683715820313e-7" + + local disk_size_gb + disk_size_gb=$( echo "$disk_size_1k" "$ratio" | awk '{print($1*$2)}' ) + + log_size_limit=$( echo "$disk_size_gb" "$percentage" | awk '{printf("%.0f", $1 * ($2/100))}') + export log_size_limit } diff --git a/setup/so-whiptail b/setup/so-whiptail index 06b510096..6372ec375 100755 --- a/setup/so-whiptail +++ b/setup/so-whiptail @@ -399,6 +399,8 @@ whiptail_install_type() { whiptail_log_size_limit() { [ -n "$QUIET" ] && return + + set_defaul_log_size log_size_limit=$(whiptail --title "Security Onion Setup" --inputbox \ "Please specify the amount of disk space (in GB) you would like to allocate for Elasticsearch data storage. \