This article will show how to use LogonBox's Automations feature to monitor a remote server and inform the administrator when it becomes unavailable.
We shall set up the server to only email the administrator after the target server fails a Monitor automation five times in a row.
Pre-requisites
- Email settings must have been configured to use either the Default Email Provider or an SMTP server.
Create a Monitor TCP Port automation
1. As an admin user, navigate to Business Rules->Automations and select Create.
2. Give the automation a name. In this case, as we'll be monitoring a web server, we will call it Webserver Status Check. For the Task option, start typing Monitor TCP Port and the task will appear in a list which you can select.
3. Enter the Host Address and Port of the web server that will be monitored, again as it's a web server we will be testing port 80.
4. Now set the Timeout for the monitor action using the slider, which in this example is set to 5 seconds.
5. We want this task to run all the time, so select the the Repeat tab and set the Repeat option to SECONDS and the Every field to 60.
6. Click Create to finish the creation process.
Create an alert event
1. We only want to act on this event once we have 5 failed checks in a row, so that we can rule out a spurious response resulting from a temporary network glitch. To do this, we can create a Generate Alert event which will be triggered off the Monitor automation.
Select the previously created Monitor automation, a graphic representing this task appears below the list. Click the plus icon (+) to chain a new task off this one.
2. Another Create Automation window will be opened. Name this event, here we have called it Webserver Offline. As this task is chained the Event will already be filled in.
3. Set the Triggers On option to Failure and set the Triggers Task to Generate Alert.
4. Go to the Threshold tab and set the Alert Threshold to 5. As we are doing a monitor automation every minute, this means we will only get an alert after the webserver is offline for 5 minutes. Here the Threshold Timeout and Reset Delay were set to 30 minutes and 60 seconds respectively.
5. Go to the Key tab and add Host and Port as we want to use these in the email and event log.
6. So to the Warning tab and set a suitable message which will be reported in the Audit Log. The attribute replacements for host and port can be used here.
7. Click Create to finish adding this event.
Emailing the admin
The event chain should now show as below. So far, the warning will only be generated in the Audit Log, but we want the server to email an admin when this event occurs.
1. Click the plus icon (+) in the Webserver Offline task to chain a new task.
2. Once again a new Create Automation window is opened. Name the event.
3. Again the Event type will be automatically entered as we chained the event. This time set Triggers On to Warning, as the previous Generate Alert event results in a Warning type in the audit log.
4. For Triggers Task, enter Send Email. We will choose to just send a plain text email here, so click on the Plain Message tab and type in your subject and heading. Note that you can still use the replacement attributes for host and port so that your admin knows which server is having problems.
5. Click the Delivery tab and add the email address that you want to send the alert to.
6. Click Create to finish adding the event.
We now have 3 items chained off each other and are ready to test.
Testing the automation and alerts
On our test web site, we have told the firewall to block the LogonBox server, to simulate the web server being offline.
After waiting 5 minutes, we see events in the Audit Log.
The image below shows the Failed Monitor TCP Port events every minute. After 5 of these, we see the Warning for the Generate Alert and immediately after that, the Send Email event triggers.
And looking at the admin's inbox, there is the email.