Turn plug socket off then on IF no ping response

Hello everyone. Would welcome help please.

I have PC’s that do not always work with WOL. Instead I can set the BIOS to turn on if power is cut and then restored. I would like to use remote tp-link plug sockets which turn on and off.

The only problem is ensuring not to turn off the pc’s if they’re still online.

I wonder if it’s possible to check if a ping response is received or not. If one is not received then the plug socket is turned off and then back on. This would kick start the pcs.

Thanks all