Monitoring Network Resources with Automations

This article will show how to use Hypersocket'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 5 times in a row.

 

Pre-requisites

  • Outbound email settings must have been configured in Configuration -> Email.

 

Step 1: Create a Monitor TCP Port automation

As an admin, navigate to Automations and click create.

Give the automation a name. Here, as we'll be monitoring a web server, we will call it Webserver Status Check. For Task, start typing Monitor TCP Port and the task will appear in a list which you can select.

Enter the Host Address and Port - again as it's a web server we will be testing port 80.

Now set the Timeout for the monitor action using the slider, which in this example is set to 5 seconds.

 

 

We want this task to run all the time, so we will skip the Schedule tab. Click on the Repeat tab. Set Repeat to SECONDS and in the Every field enter 60.

Click Create to finish.

 

 

 

 

Step 2: Create an alert event

We only want to act on this event once we have 5 failed Monitor actions 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 blue and white plus icon to chain a new task off this one.

 

 

Name this event, here we have called it Webserver offline. As we have chained this task, the Event will already be filled in. Set Triggers On to Failure and set the Triggers Task to Generate Alert.

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.

 

 

Select the Key tab and add ${attr:host} and ${attr:port} as we want to use these in the email and event log.

Select the Warning tab. Here we set a suitable message which will be reported in the Audit Log. The attribute replacements for host and port can be used here.

Click Create to finish adding this event.

 

 

 

Step 3: 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. Click the plus icon in the Webserver offline task to chain a new task.

 

Name the event. Again the Event type will be automatically entered as we chained the event. This time, set the Triggers On to Warning, as the previous Generate Alert event results in a Warning type in the audit log.

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.

 

 

Click the Delivery tab and add the email address that you want to send the alert to. Click Create to finish adding the event.

 

 

We now have 3 items chained off each other and are ready to test.

 

 

Step 4: Testing the automation and alerts

On our test web site, we have told the firewall to block the Hypersocket 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.

 

Have more questions? Submit a request

Comments