Using the DataHub to monitor the availability of a remote process
This DataHub script monitors the availability of a remote (or local) process, by querying to see whether the process is listening on a specified port.
This can be any port on which the target process is reachable - this can be a configuration port, a communication port, an internal application port, etc. Just as long as it is accessible from the machine on which DataHub is running (I.e. if a firewall is blocking traffic to the port we will not be able to query the application state).
This script makes use of the Microsoft PortQuery tool (https://www.microsoft.com/en-us/download/confirmation.aspx?id=17148) to query whether there is anything listening on the specified port/host.
To load this script:
- Download it below and import it into your DataHub
- Update the
remoteIPvariable on line 22 to be the host name or IP address of the machine on which the process resides - Update the
remotePortvariable on line 28 to be the port on which the application is listening - Update the
storageFilevariable to point to a directory in which the script can store a small, temporary, file that is generated during runtime. This file is overwritten during each query so will not consume any disk space. - Update the
queryIntervalvariable for how often the script should run - it defaults to every 5 seconds.
By default the script prints the service state to the DataHub script log - custom reporting can be easily implemented by modifying lines 66 and 68 to handle the service query results however desired.