-
Notifications
You must be signed in to change notification settings - Fork 3
Checking if a Target Device is Up
When using the Remote Manager Gateway to set up tunnel connections for other devices in the local network, it may be good to see in the Remote Manager dashboard or device page if the target device is actually up and online (and not just the tunnel between the Gateway and the Remote Manager server).
This can be handled via custom properties that are sent periodically to the Remote Manager
server. Remote Manager Gateway can set custom properties based on the output of a shell
command. So what can be done in this case is having a little shell script that calls
ping and depending on the result returns true
or false
(or any other values, as desired).
In this case we'll use the custom property targetUp
, which we'll set to true
if the
target device is up, otherwise false
.
For that purpose we'll add the following lines to the rmgateway.properties
configuration file:
webtunnel.properties.targetUp = `if ping -c 1 -w 3 -q ${webtunnel.host} >/dev/null ; then echo true ; else echo false ; fi`
webtunnel.propertiesUpdateInterval = 30
What happens is that every 30 seconds (as defined in webtunnel.propertiesUpdateInterval
) a shell command will run that sends a single ping
to the target system (${webtunnel.host}
), waits up to 3 seconds for a response, and if a response was received, returns true
, otherwise false
.