Monitoring a Port help?

I have a device that locks up. Send pings to it and it still replies. Bring up its webserver… that works too.

So I need a script to look at a specific service port TCP 51510

I would like to make something like this…

:if ([/ping 172.16.16.16 count=5] > 3)  do={
  :log info "It's Up"
} else={
  :log info "It's Probably Down"
}

Just not sure how to adapt that to look at a specific port.

If there is a resource you could access, the “fetch” can help you
https://wiki.mikrotik.com/wiki/Manual:Tools/Fetch