Ping via another network/server

Hi All
I’m sure there must be an easy way to do this but …
I’m using ping to check availability of a server. However, i dont have direct connectivity to that server, so i have to ssh via another server first.
I have a python script that does this already, but i’m trying to either convert the script to work under home assistant, or find another way to do this.
I was going to take the ping code and add ssh to my intermediate server to solve the problem.
Any suggestions on a better approach ?

I would run a script on the server that pings the other server and publish the state to mqtt.
Something like this.

Many Thanks VDRainer for this.
Seems a lot easier of an approach to what i was planning to do, plus it would be a good intro to MQTT.
I’ll give this a go
Thanks

Many thanks for this, i now have this running fine.

I have a follow up question if anyone can help.
With such a setup how do you secure the traffic?
I’m running duckdns and letsencrypt. Am i correct that i have to copy .pem files from letsencrypt to the remote pi ?