Fixed incorrect truncation
This commit is contained in:
parent
fba28d7ee0
commit
64ac879faa
36
avail.sh
36
avail.sh
|
@ -65,10 +65,22 @@ if [[ $mode == "s" ]]; then
|
||||||
diagram="${diagram}[server]\n"
|
diagram="${diagram}[server]\n"
|
||||||
eq="${eq} * 100"
|
eq="${eq} * 100"
|
||||||
answer=$(echo "scale=9; $eq" | bc)
|
answer=$(echo "scale=9; $eq" | bc)
|
||||||
|
if [[ $answer == 99.* ]]; then
|
||||||
answershort=$(echo "$answer" | tr -dc '9.')
|
answershort=$(echo "$answer" | tr -dc '9.')
|
||||||
|
else
|
||||||
|
answershort=$answer
|
||||||
|
fi
|
||||||
|
if [[ $answershort == 99.* ]]; then
|
||||||
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
|
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
|
||||||
[[ $nines -eq 1 ]] && ess="" || ess="s"
|
[[ $nines -eq 1 ]] && ess="" || ess="s"
|
||||||
ninestext="${nines} nine${ess}"
|
if [[ -n $HAVE_BASHTOOLS ]]; then
|
||||||
|
ninestext=" (^b\"${nines} nine${ess}\"^p)"
|
||||||
|
else
|
||||||
|
ninestext=" (\"${nines} nine${ess}\")"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ninestext=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ -n $HAVE_BASHTOOLS ]]; then
|
if [[ -n $HAVE_BASHTOOLS ]]; then
|
||||||
|
@ -77,7 +89,7 @@ if [[ $mode == "s" ]]; then
|
||||||
echo
|
echo
|
||||||
csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n"
|
csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n"
|
||||||
inform "^bEquation:^p ${eq}"
|
inform "^bEquation:^p ${eq}"
|
||||||
inform "^bAvailability:^p ${answershort}% (^b\"$ninestext\"^p)"
|
inform "^bAvailability:^p ${answershort}% $ninestext"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo "Architecture"
|
echo "Architecture"
|
||||||
|
@ -88,7 +100,7 @@ if [[ $mode == "s" ]]; then
|
||||||
echo "Availability"
|
echo "Availability"
|
||||||
echo "------------"
|
echo "------------"
|
||||||
echo "* Equation: ${eq}"
|
echo "* Equation: ${eq}"
|
||||||
echo "* Availability: ${answershort}% (\"$ninestext\")"
|
echo "* Availability: ${answershort}% $ninestext"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
elif [[ $mode == "p" ]]; then
|
elif [[ $mode == "p" ]]; then
|
||||||
|
@ -178,10 +190,22 @@ elif [[ $mode == "p" ]]; then
|
||||||
|
|
||||||
eq="(1 - (1 - (${sysuptime}/100))^${nsites})*100"
|
eq="(1 - (1 - (${sysuptime}/100))^${nsites})*100"
|
||||||
answer=$(echo "scale=15; $eq" | bc)
|
answer=$(echo "scale=15; $eq" | bc)
|
||||||
|
if [[ $answer == 99.* ]]; then
|
||||||
answershort=$(echo "$answer" | tr -dc '9.')
|
answershort=$(echo "$answer" | tr -dc '9.')
|
||||||
|
else
|
||||||
|
answershort=$answer
|
||||||
|
fi
|
||||||
|
if [[ $answershort == 99.* ]]; then
|
||||||
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
|
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
|
||||||
[[ $nines -eq 1 ]] && ess="" || ess="s"
|
[[ $nines -eq 1 ]] && ess="" || ess="s"
|
||||||
ninestext="${nines} nine${ess}"
|
if [[ -n $HAVE_BASHTOOLS ]]; then
|
||||||
|
ninestext=" (^b\"${nines} nine${ess}\"^p)"
|
||||||
|
else
|
||||||
|
ninestext=" (\"${nines} nine${ess}\")"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ninestext=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ -n $HAVE_BASHTOOLS ]]; then
|
if [[ -n $HAVE_BASHTOOLS ]]; then
|
||||||
|
@ -190,7 +214,7 @@ elif [[ $mode == "p" ]]; then
|
||||||
echo
|
echo
|
||||||
csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n"
|
csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n"
|
||||||
inform "^bEquation:^p ${eq}"
|
inform "^bEquation:^p ${eq}"
|
||||||
inform "^bAvailability:^p ${answershort}% (^b\"$ninestext\"^p)"
|
inform "^bAvailability:^p ${answershort}% $ninestext)"
|
||||||
else
|
else
|
||||||
echo "Architecture"
|
echo "Architecture"
|
||||||
echo "------------"
|
echo "------------"
|
||||||
|
@ -200,7 +224,7 @@ elif [[ $mode == "p" ]]; then
|
||||||
echo "Availability"
|
echo "Availability"
|
||||||
echo "------------"
|
echo "------------"
|
||||||
echo "Equation: ${eq}"
|
echo "Equation: ${eq}"
|
||||||
echo "Availability: ${answershort}% (\"$ninestext\")"
|
echo "Availability: ${answershort}% $ninestext"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
elif [[ $mode == "i" ]]; then
|
elif [[ $mode == "i" ]]; then
|
||||||
|
|
Loading…
Reference in New Issue