I implemented ethernet link speed check

Just sharing my script which checks the link speed on my Archer A7v5 ethernet ports and sends a ping to my Uptime Kuma server every 15min if the link speed is "1000baseT full-duplex".

#!/bin/ash

swconfig dev switch0 show | grep -q 'port:1 link:up speed:1000baseT full-duplex' && swconfig dev switch0 show | grep -q 'port:2 link:up speed:1000baseT full-duplex'
if [ $? -eq 0 ]; then
	ping -c 1 uptimekuma.example.com | tail -1 | cut -d '/' -f 4 | while read ping; do curl -k -v -m 10 --retry 3 "https://uptimekuma.example.com/api/push/xxxxxxxxxx?status=up&msg=OK&ping=$ping"; done
else
	sleep 30s;
	swconfig dev switch0 show | grep -q 'port:1 link:up speed:1000baseT full-duplex' && swconfig dev switch0 show | grep -q 'port:2 link:up speed:1000baseT full-duplex'
	if [ $? -eq 0 ]; then
		ping -c 1 uptimekuma.example.com | tail -1 | cut -d '/' -f 4 | while read ping; do curl -k -v -m 10 --retry 3 "https://uptimekuma.example.com/api/push/xxxxxxxxxx?status=up&msg=OK&ping=$ping"; done
	else
		curl -k -v -m 10 --retry 3 "https://uptimekuma.example.com/api/badge/61/status" | grep 'Status: Up'
		if [ $? -eq 1 ]; then
			ping -c 1 uptimekuma.example.com | tail -1 | cut -d '/' -f 4 | while read ping; do curl -k -v -m 10 --retry 3 "https://uptimekuma.example.com/api/push/xxxxxxxxxx?status=down&msg=RebootingAP&ping=$ping"; done
		else
			ping -c 1 uptimekuma.example.com | tail -1 | cut -d '/' -f 4 | while read ping; do curl -k -v -m 10 --retry 3 "https://uptimekuma.example.com/api/push/xxxxxxxxxx?status=down&msg=RebootingAP&ping=$ping"; done
			sleep 240s && touch /etc/banner && reboot
		fi
	fi
fi

I run this script every 15min via cron.
It will restart your router in case the link speed is not optimal the first time. Then it will check uptime kuma if the link speed was optimal before the router was rebooted and wont restart it again. This so that the router don't get stuck in a reboot loop.

First you have to check your switch name by running swconfig list.
It should be "switch0" or something.
Then you can run swconfig dev switch0 show to check the status of all your ports.
Port0 should be your CPU. If you have multiple CPU cores, there could be multiple ports for those too.( I might be wrong here)
After that, Port1 and onwards should be your WAN port and so on.

I am running the above script on my Archer A7v5 acting as a router.
I have 3 other Archer A7v5 acting as dumb AP's and on those, i only check the Port1. (I am using their WAN port as LAN by modifying their VLan id)

Its very simple and highly unoptimized script. Feel free to share a better version.