Topic: Diagnostic Monitoring of FST
In order to ensure that my automated MT4 instance is online, I use a monitoring platform that polls my systems regularly and alerts me (via email and SMS) if there are problems, so I can take action to correct the issue as soon as possible.
I use a number of FST instances on the same machine, all connected to multiple charts on a single MT4 instance. Monitoring MT4 is easy as I can just verify that there is an active process named 'terminal.exe', but monitoring FST is not so simple. The issue is that I can't simply monitor for a running copy of 'Forex Strategy Trader.exe' as I have a number of them running, and unless they all fail, I will never see an error from my monitoring system.
In order to be able to monitor a specific instance of FST, I have added some code into my FST fork (available at https://github.com/QANTau/Forex-Strategy-Trader) to include a means to remotely monitor a specific FST instance remotely, and have submitted a pull request for this work.
The added code includes a basic TCP server into the application that can be started from the command line, allowing for each running copy of FST to be monitored individually.
The TCP server needs a port to be set at the command line and works as follows:
If FST is started from anything other than the command line, the TCP Server is NOT started.
If FST is started using existing command line settings that specify the Connection ID, Strategy, and AutoStart value only (3 parameters provided), the TCP Server is NOT started.
If FST is started from the command line with 4 parameters listed, the fourth parameter is the TCP port and the TCP Server WILL start.
Existing documentation for the autostart process is available at http://forexsb.com/wiki/fst/manual/autostart, which will be updated with the necessary instructions if this change is accepted.
Where the existing command line would appear as something like:
start "" "Forex Strategy Trader.exe" 100 "yes" "Test Trade"
the TCP Server can be started from the command line by entering a 4th parameter, such as:
start "" "Forex Strategy Trader.exe" 100 "yes" "Test Trade" 1234
In the above example, this command line will autostart the TCP Server after FST is loaded, using port 1234 for incoming connections.
If the TCP Port must be less than 65536 and cannot be 0 (a value of 0 will work, but the TCP Server will not start).
If the TCP Server starts correctly, the journal will have a message listed such as "TCP Server Started on Port 1234".
The most common problem with the TCP Server will be trying to use a port that is already in use. As an example, attempting to use Port 3389 would result in an error being displayed in the journal "TCP Server Error (...) using Port 3389". Any errors will be displayed in the journal.
The service will only work from a remote system if the chosen port has been permitted through the firewall on the machine running FST.
A connection from a remote system on the chosen port will currently just display a message as follows:
After this response if provided, the incoming connection is disconnected immediately.
The message can be modified internally by adding code as needed such as:
if (_tcpServer != null) _tcpServer.Message = customMessageString
I am only just polling for the availability of the port (which I take to mean that FST is running) and then set an alarm if the port doesn't respond when polled, although it would be fairly simple to sent diagnostic data from FST back to the calling application if that we necessary.
Comments and feedback would be appreciated.