How To Use Discord Webhooks to have announcements to suit your websites Status on Ubuntu 18.04

How To Use Discord Webhooks to have announcements to suit your websites Status on Ubuntu 18.04

Mcdougal selected the Apache pc software base to receive a contribution as part of the prepare for DOnations program.


When you yourself have crucial web sites you’ll wish to know when they’re having any dilemmas so you’re able to correct them before there’s an impression in your customers. One method to see notifications is developed notifications through a text-based cam program.

Discord are a managed chat program similar to Slack. With dissension, you’ll set-up a totally free messaging system that enables you to talk to text messages, images, sound, and movie. Whilst it provides advanced services, you can easily sign up for free of charge, and contains consumers available for Microsoft windows, macOS, Linux, Android os, and iOS.

Contained in this guide, you may arrange your Discord host, produce a dissension webhook, create a Bash script that will look at the updates of a list of web sites, and examination announcements from the host towards Discord channel.


Before you start this article you’ll have to have the utilizing:

An Ubuntu 18.04 machine that can manage your tracking program and talk to dissension (monitor-server). You’ll be able to ready this servers right up by using this original Server build manual.

Should you don’t need an internet site . you would like to monitor however, setup the apache-server with Simple tips to apply the Apache online servers on Ubuntu 18.04 and make sure to complete action 5 on installing an online number.

a dissension account. You can travel to the Discord enrollment webpage to join a free of charge dissension accounts.

1 — Creating Your Discord Webhook

Once you have launched your dissension membership you’ll be able to make your very own exclusive Discord servers.

Initially, log in to your dissension accounts within web browser or launch the dissension software and click on the build a host option.

After that pick a name for the host and then click regarding the generate a machine button.

Next, you certainly will configure their Discord webhook. The webhooks tend to be unique URLs that you can use to connect providers with each other. Discord’s webhooks allow you to speed up your own communications and deliver information revisions to your Discord book networks.

In this information, you will deliver a notice your webhook when a specific solution in your servers goes down, and dissension will ensure you will get those emails on the route.

To create a webhook you need to first click on their route and go through the Edit station button right alongside your channel’s name.

Then click the Webhooks loss and then click the generate Webhook option.

Next, select a name to suit your webhook, in this tutorial we’ll use notifications because this is exactly what our very own Bash program is going to do—alert all of us in the case that one of your web sites decreases.

Duplicate their webhook Address and help save they for later. Ultimately, click the rescue button.

You’ve got your Discord membership, server, and webhook. Anybody can proceed to create a test apply for your own program to monitor.

2 — producing a Test document (Optional)

If you don’t have your own internet site to check already, comprehensive this task to include a test file to evaluate how your monitoring script will work. Make sure to work these instructions on the apache-server.

Initial, create the test file together with the after command:

Add some material to your document, so you’re able to see it’s employed:

Protect and leave the file.

Today navigate to http:// your_domain /test inside internet browser to ensure that you can get the text from inside the examination document.

Within the next step, you’ll begin to create your tracking software.

Step 3 — Generating Your Own Tracking Program

Now you’ve set up your webhook, you’ll go on and create your Bash software that will check out the response rule of the website. When all sites comes back a reputation distinctive from 200 okay , their program will be sending a request to the dissension webhook so that you will get a notification within dissension route.

Note: make use of virtually any program writing language to build a program along these lines.

First SSH in to your own monitor-server that you’re making use of to perform your own monitoring software.

Start by promoting a document at home folder. We’ll label the document in this guide.

With your best book publisher available the document:

For regimen loader to identify this executable document as a Bash software, add these range to reach the top associated with the document:

All contours beginning with a # were a comment. The feedback is elective, but creating commentary within program can certainly make it more convenient for other people to appreciate just what script really does:

Further, indicate their Discord webhook as a variable. Add the Address your copied before to suit your webhook:

As you’ll probably use this software to evaluate the condition of numerous internet sites, create a varying labeled as websites_list and shop the domain names or IP address contact information of web sites you want to keep track of. If you’re utilizing the elective examination document in this tutorial, make sure to incorporate /test after your domain or ip:

In the event that you’re monitoring several websites, you could add additional domain names or internet protocol address details on websites_list changeable and employ room as a separator:

Today you’ll would you like to loop through set of web pages and look their unique position. To accomplish this put the subsequent for cycle your document:

This for loop is certainly going through each object from inside the websites_list adjustable and look the status for the internet site together with the curl command.

The echo $status_code statement will print out the feedback reputation associated with curl order. In the event the internet site try run not surprisingly the curl demand will come back a response code 200 okay , which means the internet site try working. If not you’ll see another reaction code.

Inside the as loop, create an if report to test when the responses code was 200 or perhaps not. In the event that responses signal is 200 subsequently which means website try working and also you wouldn’t need a Discord notice. Incorporate these conditional block towards file:

If discover any problems with the website after that you’ll have yet another reaction rule, inside show you’ll want to obtain an alerts via their dissension webhook.

To send the notice you need to use the curl demand add A POST demand into the Discord webhook Address.

Incorporate the next curl consult as part of your if declaration:

Today let’s examine the different arguments:

Leave a Reply

Your email address will not be published. Required fields are marked *