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