[fix] Calc log_size_limit more accurately + actually call function

This commit is contained in:
William Wernert
2020-04-22 22:42:24 -04:00
parent 09c22bbe43
commit 10e46b6fc3
2 changed files with 14 additions and 10 deletions

View File

@@ -40,13 +40,14 @@ calculate_useable_cores() {
} }
set_defaul_log_size() { set_defaul_log_size() {
local percentage
case $INSTALLTYPE in case $INSTALLTYPE in
EVAL | HEAVYNODE) EVAL | HEAVYNODE)
PERCENTAGE=50 percentage=50
;; ;;
*) *)
PERCENTAGE=80 percentage=80
;; ;;
esac esac
@@ -54,13 +55,14 @@ set_defaul_log_size() {
if [ -d /nsm ]; then if [ -d /nsm ]; then
disk_dir="/nsm" disk_dir="/nsm"
fi fi
local disk_size_kb local disk_size_1k
disk_size_kb=$(df $disk_dir |grep -v "^Filesystem" | awk '{print $2}') disk_size_1k=$(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) ))
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
} }

View File

@@ -400,6 +400,8 @@ whiptail_log_size_limit() {
[ -n "$QUIET" ] && return [ -n "$QUIET" ] && return
set_defaul_log_size
log_size_limit=$(whiptail --title "Security Onion Setup" --inputbox \ 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. \ "Please specify the amount of disk space (in GB) you would like to allocate for Elasticsearch data storage. \
By default, this is set to 80% of the disk space allotted for /nsm." 10 75 "$log_size_limit" 3>&1 1>&2 2>&3) By default, this is set to 80% of the disk space allotted for /nsm." 10 75 "$log_size_limit" 3>&1 1>&2 2>&3)