Skip to content

Commit 4f3c737

Browse files
committed
update install.sh
1 parent 7b7258e commit 4f3c737

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

install.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,22 @@ add_limit() {
273273
exit 1
274274
fi
275275

276+
total_usage(){
277+
interface=$(ip -o link show | awk -F': ' '{print $2}' | grep -v "lo" | head -n 1) > /dev/null 2>&1
278+
data=$(grep "$interface:" /proc/net/dev)
279+
download=$(echo "$data" | awk '{print $2}')
280+
upload=$(echo "$data" | awk '{print $10}')
281+
total_mb=$(echo "scale=2; ($download + $upload) / 1024 / 1024" | bc)
282+
echo -e "${cyan}T${yellow}o${cyan}t${yellow}a${cyan}l${yellow} U${cyan}s${yellow}a${cyan}g${yellow}e${cyan}: ${purple}[$total_mb] ${cyan}MB${rest}"
283+
}
284+
276285
echo -e "${yellow}×××××××××××××××××××××××${rest}"
277-
echo -e "${cyan}This option adds a traffic limit to monitor increases in traffic compared to the last 24 hours.${rest}"
278-
echo -e "${cyan}If the traffic exceeds this limit, the nginx service will be stopped.${rest}"
286+
echo -e "${yellow}* ${cyan}This option adds a traffic limit to monitor increases in traffic compared to the last 24 hours.${yellow}*${rest}"
287+
echo ""
288+
echo -e "${yellow}* ${cyan}If the traffic exceeds this limit, the nginx service will be stopped.${yellow}*${rest}"
289+
echo ""
290+
total_usage
291+
echo -e "${yellow}* ${cyan}[${yellow}Note${cyan}]: ${cyan}After restarting the server, the ${cyan}T${yellow}o${cyan}t${yellow}a${cyan}l${yellow} U${cyan}s${yellow}a${cyan}g${yellow}e${cyan} will also be reset.${yellow}*${rest}"
279292
echo -e "${yellow}×××××××××××××××××××××××${rest}"
280293
read -p "Enter the percentage limit [default: 50]: " percentage_limit
281294
percentage_limit=${percentage_limit:-50}

0 commit comments

Comments
 (0)