Update status.inc

This commit is contained in:
2023-12-27 11:44:34 -06:00
parent 4e1df6c70f
commit 00f746e6e9

View File

@@ -825,45 +825,59 @@ STATUS_SCANTIMES(){
IFS=$'\n'
read -rd '' -a scantimes <<<"${scantimes}"
unset IFS
scantimes_total_norm=0; scansfound_norm=0
scantimes_total_repl=0; scansfound_repl=0
scantimes_total_xtr=0; scansfound_xtr=0
scantimes_norm=0; scansfound_norm=0
scantimes_norm_xtr=0; scansfound_norm_xtr=0
scantimes_repl=0; scansfound_repl=0
scantimes_repl_xtr=0; scansfound_repl_xtr=0
for scan in "${scantimes[@]}"; do
# [[ "${scantime}" = *"~"* ]] && scantime=${scantime#*~}
scantime=$(echo "${scan}" | cut -d '~' -f 2)
scanrun=$(echo "${scan}" | cut -d '~' -f 3)
[ ${scantime} -gt ${longest_scantime} ] && longest_scantime=${scantime}
if [ ${scantime} -lt 30 ]; then
scantimes_total_norm=$(bc <<< "scale=2; ${scantimes_total_norm}+${scantime}")
((scansfound_norm++))
elif [ ${scantime} -le 60 ]; then
scantimes_total_repl=$(bc <<< "scale=2; ${scantimes_total_repl}+${scantime}")
((scansfound_repl++))
if [ ${scanrun} -eq 1 ]; then
if [ ${scantime} -le 90 ]; then
scantimes_repl=$(bc <<< "scale=2; ${scantimes_repl}+${scantime}")
((scansfound_repl++))
else
scantimes_repl_xtr=$(bc <<< "scale=2; ${scantimes_repl_xtr}+${scantime}")
((scansfound_repl_xtr++))
fi
else
scantimes_total_xtr=$(bc <<< "scale=2; ${scantimes_total_xtr}+${scantime}")
((scansfound_xtr++))
if [ ${scantime} -le 90 ]; then
scantimes_norm=$(bc <<< "scale=2; ${scantimes_norm}+${scantime}")
((scansfound_norm++))
else
scantimes_norm_xtr=$(bc <<< "scale=2; ${scantimes_norm_xtr}+${scantime}")
((scansfound_norm_xtr++))
fi
fi
done
scantimes_total=`expr ${scantimes_total_norm} + ${scantimes_total_repl} + ${scantimes_total_xtr}`
scansfound=`expr ${scansfound_norm} + ${scansfound_repl} + ${scansfound_xtr}`
scantimes_total_norm=`expr ${scantimes_norm} + ${scantimes_norm_xtr}`
scantimes_total_repl=`expr ${scantimes_repl} + ${scantimes_repl_xtr}`
scantimes_total=`expr ${scantimes_total_norm} + ${scantimes_total_repl}`
scansfound_total_norm=`expr ${scansfound_norm} + ${scansfound_norm_xtr}`
scansfound_total_repl=`expr ${scansfound_repl} + ${scansfound_repl_xtr}`
scansfound_total=`expr ${scansfound_total_norm} + ${scansfound_total_rep}`
[ ${scansfound_norm} -eq 0 ] && average_norm=0 || average_norm=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total_norm}/${scansfound_norm}") 0)
[ ${scansfound_repl} -eq 0 ] && average_repl=0 || average_repl=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total_repl}/${scansfound_repl}") 0)
[ ${scansfound_xtr} -eq 0 ] && average_xtr=0 || average_xtr=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total_xtr}/${scansfound_xtr}") 0)
[ ${scansfound} -eq 0 ] && average=0 || average=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total}/${scansfound}") 0)
[ ${scansfound_norm} -eq 0 ] && average_norm=0 || average_norm=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_norm}/${scansfound_norm}") 0)
[ ${scansfound_norm_xtr} -eq 0 ] && average_norm_xtr=0 || average_norm_xtr=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_norm_xtr}/${scansfound_norm_xtr}") 0)
[ ${scansfound_total_norm} -eq 0 ] && average_total_norm=0 || average_total_norm=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total_norm}/${scansfound_total_norm}") 0)
[ ${scansfound_repl} -eq 0 ] && average_repl=0 || average_repl=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_repl}/${scansfound_repl}") 0)
[ ${scansfound_repl_xtr} -eq 0 ] && average_repl_xtr=0 || average_repl_xtr=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_repl_xtr}/${scansfound_repl_xtr}") 0)
[ ${scansfound_total_repl} -eq 0 ] && average_total_repl=0 || average_total_repl=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total_repl}/${scansfound_total_repl}") 0)
[ ${scansfound_total} -eq 0 ] && average_total=0 || average_total=$(ROUND_NUMBER $(bc <<< "scale=2; ${scantimes_total}/${scansfound_total}") 0)
cw=`expr $(echo "${#average_norm} ${#average_repl} ${#average_xtr} ${#average}" | grep -oE '[0-9]+' | sort -n | tail -n 1) + 1`
average_norm_disp=$(SHOW_TIME ${average_norm} s)
c=0; spca=''; spc1=`expr ${cw} - ${#average_norm}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr $c + 1`; done
average_repl_disp=$(SHOW_TIME ${average_repl} s)
c=0; spcr=''; spc1=`expr ${cw} - ${#average_repl}`; until [ $c = ${spc1} ]; do spcr="${spcr} "; c=`expr $c + 1`; done
average_xtr_disp=$(SHOW_TIME ${average_xtr} s)
c=0; spcx=''; spc1=`expr ${cw} - ${#average_xtr}`; until [ $c = ${spc1} ]; do spcx="${spcx} "; c=`expr $c + 1`; done
average_disp=$(SHOW_TIME ${average} s)
c=0; spcT=''; spc1=`expr ${cw} - ${#average}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr $c + 1`; done
cw=`expr $(echo "${#average_norm} ${#average_norm_xtr} ${#average_repl} ${#average_repl_xtr} ${#average_total_norm} ${#average_total_replt} ${#average_total}" | grep -oE '[0-9]+' | sort -n | tail -n 1) + 1`
average_norm_disp=$(SHOW_TIME ${average_norm} s); c=0; spcAND=''; spc1=`expr ${cw} - ${#average_norm}`; until [ $c = ${spc1} ]; do spcAND="${spcAND} "; c=`expr $c + 1`; done
average_norm_xtr_disp=$(SHOW_TIME ${average_norm_xtr} s); c=0; spcANXD=''; spc1=`expr ${cw} - ${#average_norm_xtr}`; until [ $c = ${spc1} ]; do spcANXD="${spcANXD} "; c=`expr $c + 1`; done
average_total_norm_disp=$(SHOW_TIME ${average_total_norm} s); c=0; spcATND=''; spc1=`expr ${cw} - ${#average_total_norm}`; until [ $c = ${spc1} ]; do spcATND="${spcATND} "; c=`expr $c + 1`; done
average_repl_disp=$(SHOW_TIME ${average_repl} s); c=0; spcARD=''; spc1=`expr ${cw} - ${#average_repl}`; until [ $c = ${spc1} ]; do spcARD="${spcARD} "; c=`expr $c + 1`; done
average_repl_xtr_disp=$(SHOW_TIME ${average_repl_xtr} s); c=0; spcARXD=''; spc1=`expr ${cw} - ${#average_repl_xtr}`; until [ $c = ${spc1} ]; do spcARXD="${spcARXD} "; c=`expr $c + 1`; done
average_total_repl_disp=$(SHOW_TIME ${average_total_repl} s); c=0; spcATRD=''; spc1=`expr ${cw} - ${#average_total_repl}`; until [ $c = ${spc1} ]; do spcATRD="${spcATRD} "; c=`expr $c + 1`; done
average_total_disp=$(SHOW_TIME ${average_total} s); c=0; spcATD=''; spc1=`expr ${cw} - ${#average_total}`; until [ $c = ${spc1} ]; do spcATD="${spcATD} "; c=`expr $c + 1`; done
lastscantime_disp=$(SHOW_TIME ${lastscantime} s)
longest_scantime_disp=$(SHOW_TIME ${longest_scantime} s)
@@ -874,11 +888,17 @@ STATUS_SCANTIMES(){
echo -en "\r\033[K"
echo -e "${idsCL[LightCyan]}Scan Type Scans Average Scantime${idsCL[Default]}"
DIVIDER . lightCyan 60
echo -e "${idsCL[Green]}Average for last `IDS_NUMBER_FORMAT ${scansfound}` ${idsCL[Green]}(${average}s)${spct}${idsCL[LightGreen]}${average_disp}${idsCL[Default]}"
echo -e "${idsCL[LightGreen]}Average for last `IDS_NUMBER_FORMAT ${scansfound_total}` ${idsCL[Green]}(${average_total}s)${spct}${idsCL[LightGreen]}${average_total_disp}${idsCL[Default]}"
DIVIDER . lightCyan 60
echo -e "${idsCL[Cyan]} - Normal runs `IDS_NUMBER_FORMAT ${scansfound_norm}` ${idsCL[Cyan]}(${average_norm}s)${spca}${idsCL[LightCyan]}${average_norm_disp}${idsCL[Default]}"
echo -e "${idsCL[Cyan]} - w/Replication `IDS_NUMBER_FORMAT ${scansfound_repl}` ${idsCL[Cyan]}(${average_repl}s)${spcr}${idsCL[LightCyan]}${average_repl_disp}${idsCL[Default]}"
echo -e "${idsCL[Cyan]} - Extreme runs `IDS_NUMBER_FORMAT ${scansfound_xtr}` ${idsCL[Cyan]}(${average_xtr}s)${spcx}${idsCL[LightCyan]}${average_xtr_disp}${idsCL[Default]}"
echo -e "${idsCL[Green]} Service Checks `IDS_NUMBER_FORMAT ${scansfound_total_norm}` ${idsCL[Green]}(${average_total_norm}s)${spct}${idsCL[LightGreen]}${average_total_norm_disp}${idsCL[Default]}"
DIVIDER . lightCyan 60
echo -e "${idsCL[Cyan]} - Normal `IDS_NUMBER_FORMAT ${scansfound_norm}` ${idsCL[Cyan]}(${average_norm}s)${spcr}${idsCL[LightCyan]}${average_norm_disp}${idsCL[Default]}"
echo -e "${idsCL[Cyan]} - Long `IDS_NUMBER_FORMAT ${scansfound_norm_xtr}` ${idsCL[Cyan]}(${average_norm_xtr}s)${spcx}${idsCL[LightCyan]}${average_norm_xtr_disp}${idsCL[Default]}"
DIVIDER . lightCyan 60
echo -e "${idsCL[Green]} w/Replication `IDS_NUMBER_FORMAT ${scansfound_total_repl}` ${idsCL[Green]}(${average_total_repl}s)${spct}${idsCL[LightGreen]}${average_total_repl_disp}${idsCL[Default]}"
DIVIDER . lightCyan 60
echo -e "${idsCL[Cyan]} - Normal `IDS_NUMBER_FORMAT ${scansfound_repl}` ${idsCL[Cyan]}(${average_repl}s)${spcr}${idsCL[LightCyan]}${average_repl_disp}${idsCL[Default]}"
echo -e "${idsCL[Cyan]} - Long `IDS_NUMBER_FORMAT ${scansfound_repl_xtr}` ${idsCL[Cyan]}(${average_repl_xtr}s)${spcx}${idsCL[LightCyan]}${average_repl_xtr_disp}${idsCL[Default]}"
echo
echo -e "${idsCL[LightCyan]}Longest scan from above : ${idsCL[Green]}(${longest_scantime}s) ${idsCL[LightGreen]}${longest_scantime_disp}${idsCL[Default]}"
echo