Suppose that we have a remote server machine that always needs to be up and running. In case the connection fails, system administrators need to know that as soon as possible. This tutorial shows how to configure Automation Workshop to monitor connection to a remote machine.
Use Task Scheduler to periodically execute the Task which pings the server machine and, in case it is not responding, gathers different data and notifies the administrator either by sending email or playing audible warning by using the Play Audio File Action.
Let us see the necessary steps to design such a Task.
- 1 · The Task Scheduler Trigger is added and configured to execute the Task every 20 seconds (that will be a period of ping operations).
- 2 · The Run CMD Command Action is added and configured to run the
pingcommand to verify whether remote server is accessible. If the
pingcommand can not connect the remote server, the Action ends with error and tells the Task to skip Step 3 and proceed immediately with Step 4. Otherwise it just continues with Step 3 at which the Task is stopped.
- 3 · The Stop Task Action is configured to stop the very Task within which it is located. However, this Action will be performed only when the
pingcommand performed by Run CMD Command Action in Step 2 manages to successfully reach the server.
- 4 · Reaching this step implies the failure of the
pingcommand to reach the destination server in Step 2. Thus, from here on, Automation Workshop starts gathering additional data on connectivity problems and tries to deliver the notification on initial ping failure to the system administrator. Let us add Run CMD Command Action to ping domain name server (DNS) to check whether it is possible to resolve the IP address of the server.
- 5 · The Run CMD Command Action performs ping operation to check router & gateway connectivity.
- 6 · Another Run CMD Command Action performs tracert command to get info on mediating servers.
- 7 · In Step 7 we use Run CMD Command to make sure if the SMTP server for email error report is accessible. If ping to SMTP server fails, the Action will skip Step 8 which uses the SMTP server for sending email and go directly to Step 10 (using On Error settings).
- 8 · Send Email Action is added and configured using Variable Wizard to send data gathered by pings to domain name server (DNS) and gateway, as well as
- 9 · If SMTP server has been reached successfully in Step 7, the Task stops here using the Stop Task Action.
- 10 · This step is executed only if pinging SMTP server has failed in Step 7. Since it is not possible to send an email report when SMTP server is not reachable, we can still try to notify the administrator with audible alarm. We will configure Play Audio File Action to play the alarm.
Deploy the Task…
Let us see in detail how to create the Task and configure every Action according to the aforementioned design.
Alternatively, you can use CTRL+N keyboard shortcut or select New Task in context menu by pushing right mouse button in Task Pane. Whichever you choose, it will open Task Wizard which will lead us through the rest of configuration process.
How to add Task Scheduler trigger? After reading the info on Welcome tab in Task Wizard, click Next to get to the Triggers tab.
Click the Add button to open the window with all available Triggers. Select Task Scheduler from the list and click OK to open its properties. After configuring the Trigger, it will automatically be added to the Task.
How to configure Task Scheduler trigger for periodic Task execution? When added, Task Scheduler properties are opened on the Scheduler tab which contains most relevant parameters.
By default, Task Scheduler is set to execute daily. Since we need to ping the remote server much more often, let us change schedule type from daily to seconds. Set the recurrence interval to 20 seconds and the configuration is done. Click OK to save the settings.
If more advanced schedule is necessary, it is always possible to disable scheduling on particular days, weekdays, months or even time of the day. It is also possible to specify end date of the schedule as well as multiple other options which we leave at their defaults in this particular case · Advanced Task Scheduler explained
How to add Actions to the Task? After returning to the Triggers tab of Task Wizard, click Next to go to the Actions tab. Click the Add button to open the Add Action window that contains a list of all available Actions divided into broader categories. Select an Action and click OK to open its properties.
When finishing configuring an Action, click OK and it will be added to the Actions list in Task Wizard. We will need to do this over and over again to add multiple Actions to our Task. Let us see how to configure all necessary Actions one by one.
Ping the remote server. In order to verify whether the server is online we will use the ping command included in Microsoft Windows. We will need to use the Run CMD Command Action which can execute external commands from command line.
So, let us add the Run CMD Command Action and configure to ping the remote server. Write
ping -n 1 www.example.com into the Command line input in Command tab of the Run CMD Command Action properties.
-n 1 means that only one data packet per command execution will be sent to ensure server connectivity. You will have to substitute
www.example.com with the actual server URL or IP address. If connection is somewhat unstable, you might want to increase the number of data packets sent each time, for example,
ping command returns error level 0 if the round-trip of at least one data packet is successful. If no data packet is returned or on any other error, the
ping command returns error level 1.
Now, when the
ping command is set, we must configure alternative endings of the Task. If the
ping command has successfully reached the server, there is nothing more to be done and the Task has to finish. In case of failure, though, the Task must proceed with gathering more data and reporting the situation to system administrator.
However, before telling the Action with what other Actions to continue in case of successful or failed pinging the server, we have to create those very Actions at the first place and return to configuring this Action afterward. Click OK to return to Action tab of Task Wizard.
Stop the Task
Stop the Task upon successfully reaching the server. Let us first configure the Action which is to be performed if pinging the server has been successful.
In case the server has responded to ping, the Task has performed its function and can be stopped. Let us add the Stop Task Action. The default option to stop the very Task in which Action is located, namely, this Task is what we actually need.
Since this is also a planned stopping and not some error, there is no need to mark Warning and Error checkboxes. Click OK to return to Task Wizard.
Set default folder for troubleshooting data. Now, let us configure Actions that will gather some data in case the
ping command fails to reach the server. Since the external commands like
tracert will output returned data into text files, we need to specify a folder in which these files will be created.
While it is possible to specify that folder using command line parameter for each command, it might be easier to just specify one folder as default for them all. Add Change Current Folder Action and choose folder which will be considered as default for all subsequent Actions. In this example we will use the
Once set, click OK to return to Task Wizard. Note that
C:\PING\ folder has to created before running the Task. The good idea is to create it right at this point.
Ping the domain name server (DNS). Once default working folder has been specified, we can start with gathering various data from other machines possibly involved in inability of Automation Workshop to reach the remote server.
If the DNS server is not reachable, the domain names are not resolved causing the inability to reach the remote server machine. Let us ping domain name server (DNS) to verify whether domain name of the server (host name) can be resolved into IP address (and hence is not the cause of connectivity problems).
Add Run CMD Command Action and configure it to ping the domain name server (for example,
22.214.171.124). Additionally, we need to save the pinging result into a text file to add it later to email report. Thus, we have to use redirection operator bigger than
> character and file name to make the
ping command use file as it's output instead of screen.
ping 126.96.36.199 >dns.txt into the Command line input.
Ping the gateway & router. Another possible problem may lay in gateway. Let us add Run CMD Command Action and configure it exactly as in previous step. Except that IP address has to be substituted with that of your gateway.
ping 192.168.1.1 >gateway.txt into the Command line input.
Perform trace route to remote server. Finally, let us perform the
tracert command to verify whether some intermediate machine is not the cause of inability of Automation Workshop to reach the server. Add Run CMD Command Action.
tracert www.example.com >traceroute.txt into the Command line input.
After setting up these three Run CMD Command Actions to ping the domain name server (DNS) and gateway, as well as trace route to the remote server, we have configured the basis for gathering the necessary data into text files.
Now we have to finalize the choice between two distinct scenarios, that of successfully stopping the Task, and that of continuing with data gathering upon initial ping failure.
Choice between ending Task and continuing with error procedures. Before going further with configuring the error reporting, let us now return to the very first Action which pinged the remote server to verify the connection. Double click the first Action in the list to edit its properties.
The difference between configuring the Action for the first time and now is that we have added more Actions since then. Task design implies that if the ping procedure finishes normally, the Task is automatically stopped by the Stop Task Action which we added as second.
However, if the ping procedure fails to reach the remote server, we need to skip the Stop Task Action and continue the Task with other Actions to gather additional data.
Let us first go to the Advanced tab. Successful ping will return error level 0 as indication of its success. All other error level values that exceed 0 are treated as warnings by default. We need to change settings to treat error levels greater than 0 as error. The difference between warnings and errors is that warnings are merely reported in Automation Workshop logs, while errors allow user to specify additional Task management procedures in the On Error tab.
Go to the On Error tab, by enabling Advanced fallback options checkbox. To avoid the situation that random packet loss triggers the Task execution, let us enable the option to Retry this Action 3 more times. We can set up email reports directly here. However, we will deal with that later. Instead we need to tell the Action that in case of error, it should continue with the Change Current Folder Action.
Let us recall that the Change Current Folder Action is the one which starts the data gathering procedures in case of ping failure. Click Ok to return to Task Wizard.
Verify whether SMTP server is reachable. Now, when all Actions responsible for gathering necessary data are configured, let us think how to deliver the server connectivity failure report to system administrator. We will ping SMTP server first, to verify whether it will be possible to send the email report.
Due to possible DNS server inaccessibility (which is not explicitly verified in this tutorial) the numeric SMTP server address should be used. For example, let us assume that the IP address of SMTP is 192.168.1.44. Add Run CMD Command Action.
ping -n 1 192.168.1.44 into the Command line input.
Since the outcome of this ping will decide whether the Task will send an email report or play audible alarm, now we need to create those other Actions first, before finishing this one. Click OK to save the Action and return to Task Wizard.
Send email report to system administrator. Assuming that pinging SMTP server has finished successfully, the Task will send an email to administrator's email containing the data related to inability to connect the remote server. Let us add the Send Email Action first. Let us add From and To address first and write something relevant into the Subject field.
To format Email text we will use contents of three files created by three Actions, namely,
traceroute.txt that will be created in
C:\PING\ folder upon the first ping failure. Let us write a title for each file (e.g., PING DNS, PING GATEWAY and TRACERT SERVER) in the Email text field.
After each title, let us add respective text file. Click on Variable Wizard button, choose File category, select use file content variable and enter
C:\PING\dns.txt into the Local or Network file input field. Since the
dns.txt file does not exist prior to Task execution, we will have to enter file name manually (instead of using the Browse button).
Let us put the cursor after the next title PING GATEWAY and repeat the previous step, but enter
C:\PING\gateway.txt this time. And once again, under TRACERT SERVER title do the same with the
Stop the Task
Stop the Task if email is sent successfully. If we want the Task either to send an email or play an alarm, we need to add the Stop Task Action at this point. It will prevent the Automation Workshop from playing the alarm. Let us add the Stop Task Action and set it to stop this very Task. Click OK to return to Task Wizard.
Play audible alarm upon error. Now, let us add the Play Audio File Action. Specify the audio file to be played. Assuming that an audio file is already prepared, titled
alarm.wav and located in
C:\Sounds\, let us browse to the
C:\Sounds\alarm.wav file. Note that Windows volume has to be set appropriately to ensure the audibility of the alarm.
Choice between sending email report and playing audible alarm. Now, when all Actions have been configured, let us just finalize the setup of automated choice between email report and audible alarm.
Open the Run CMD Command Action (6th in the list) which pings the SMTP server. Go to Options tab and set to Treat error levels greater than 0 as error. As a consequence every SMTP server ping failure will produce error.
Let us now use this error to choose between sending email and playing alarm. Go to On Error tab. Since in case of error (failure to ping SMTP server) we need to play audible alarm instead of stopping the Task, let us change Stop Task option to Continue with and choose the Start App Action which we've configured to play
When ping to SMTP server is successful, the Action will complete successfully and the next Action will send an email error report using just pinged SMTP server and the Task will stop right afterward. On the other hand, if pinging SMTP server fails, the Task will perform the On Error procedure and continue with the Play Audio File Action.
Finalizing the Task. After finished with configuring the choice in the Action that pings SMTP server, click OK to return to Task Wizard. Click Next to proceed to Run As settings, then to Reports tab. Remove checkbox from Send email upon successful completion since, probably, we do not need to receive an email every time the ping is successful.
Give Task a name and description in the Task tab and click Next to go to Finish section. Due to complexity of the Task, let us click the Advanced button to open it's properties.
Let us start with Settings tab. The
tracert command used in one Action can take quite a long time to finish. Which in turn can lead to multiple simultaneously running instances of the same Task. Let us choose not to start the new instance of the task if an instance of already running (or queued) task is being executed.
Also, we can choose to stop already running instance of the Task if it runs longer than, say, 1 hour which is already way too long for performing the specified Actions.
Second, due to frequent and periodic execution of the Task, we might want the execution data from this Task not to clutter the whole log file which may also contain more valuable data from other processes.
Let us go to the Log tab and choose Disable log for this Task option. If, after disabling logging into main log file, we still want to gather some data, let us check Additionally create separate log file and specify the alternative log file path and name as well as the logging level.
Third, let us visit the On Error tab of Send Email Action. Since in the case of email failure we want to hear the alarm (even if email sending process itself is attempted), we have to change the Stop Task option to Continue with Play Audio File Action which we've configured to play
This way the alarm will be played not only when Send Email Action is skipped, but also when it fails.
Finally, if necessary, we can also revisit all Run CMD Command Actions, and change the CMD window startup state to Hidden (in the Advanced tab).
It will make CMD window (where
tracert commands are executed) invisible during execution.
We have created a Task that pings the remote server and, depending on the ping outcome it either stops or performs one of two possible error procedures. We have used On Error settings in conjunction with Stop Task Action to differentiate between successful ping execution and failure. The sequence of Task creation has been non-sequential and we had to return to finalize some Actions after creating farther ones.
If you have any questions, please do not hesitate to contact our support team.