How To Use dissension Webhooks in order to get announcements for Your Website condition on Ubuntu 18.04

How To Use dissension Webhooks in order to get announcements for Your Website condition on Ubuntu 18.04

The writer selected the Apache pc software base to receive a donation included in the prepare for DOnations program.


When you have critical web sites you’ll would like to know when they’re having any problem so you can fix them before there’s a direct impact on your consumers. One way to get announcements would be to set up notifications through a text-based chat system.

Discord was a hosted talk system comparable to Slack. With Discord, you’ll setup a no cost messaging program that allows you to talk to sms, graphics, sound, and videos. While it supplies premiums attributes, possible join complimentary, and has now consumers readily available for Microsoft windows, macOS, Linux, Android os, and apple’s ios.

In this tutorial, you will definitely arrange yours Discord server, produce a dissension webhook, compose a Bash software that’ll check the updates of a summary of internet sites, and examination notifications from the machine your Discord route.


Before you start this article you’ll require the following:

An Ubuntu 18.04 server which will operated your own tracking software and speak with Discord (monitor-server). You’ll arranged this machine upwards following this first host create manual.

Should you decide don’t has a website you’d like to monitor yet, install the apache-server with Simple tips to Install the Apache Web machine on Ubuntu 18.04 and make certain to accomplish action 5 on installing an online variety.

a Discord profile. You can travel to the Discord enrollment webpage to join a free Discord membership.

Step One — Creating Their Discord Webhook

Once you have open your dissension account you are able to make your very own private dissension server.

1st, log in to the dissension accounts in your browser or release their Discord software and then click on the Make a servers switch.

After that pick a name for the machine and click about generate a host switch.

After that, you are going to arrange your Discord webhook. The webhooks were special URLs that you can use to link providers along. Discord’s webhooks enable you to speed up the emails and submit data updates your Discord text stations.

In this information, you will definitely submit an alerts to your webhook whenever a certain services on your host decreases, and Discord will ensure that you get those emails on the route.

Generate a webhook you need to very first select your own channel after which go through the Edit route button appropriate next to your channel’s label.

Then click on the Webhooks case and click the Make Webhook switch.

From then on, choose a name for your webhook, contained in this tutorial we’ll need Alerts as this is just what all of our Bash software will do—alert you in the event that one in our sites falls.

Replicate the webhook URL and save they for afterwards. Eventually, click on the salvage switch.

You now have your own Discord accounts, machine, and webhook. Anybody can move on to produce a test file for your own software to monitor.

Step 2 — generating a Test File (Optional)

In the event that you don’t get own internet site to test currently, total this action to incorporate a test document to evaluate how the spying software is guaranteed to work. Always manage these instructions on the apache-server.

1st, create the test file using the after order:

Then add content towards file, to search it’s working:

Save and leave the document.

Today navigate to http:// your_domain /test inside internet browser to ensure that you can get the book into the test document.

Within the next action, you’ll beginning to create your tracking software.

Step 3 — Generating Your Tracking Script

Now that you’ve designed the webhook, you’ll go on and make your Bash script that may look at the feedback rule of one’s web pages. In the event that all sites comes back a reputation distinctive from 200 okay , the script will be sending a request on the dissension webhook you will receive a notification within dissension channel.

Note: make use of every other program coding language to build a software similar to this.

Initial SSH directly into your monitor-server that you’re using to run your own monitoring software.

Start with creating a document in your house folder. We’ll label the document contained in this guide.

With your favored book editor open the file:

When it comes to plan loader to acknowledge this executable document as a Bash program, include these line to the top from the document:

All outlines starting with a # include a remark. The reviews is optional, but having feedback in your software is going to make it more convenient for other people to appreciate exactly what the script does:

Then, indicate your own Discord webhook as a changeable. Create the Address your duplicated earlier on to suit your webhook:

As you’ll perhaps use this software to evaluate the position of numerous web sites, making an adjustable called websites_list and store the names of domain or internet protocol address addresses from the websites you want to keep track of. If you’re utilising the elective examination file in this tutorial, be sure to create /test after your own domain name or internet protocol address:

In case that you’re overseeing one or more web site, you can include a lot more names of domain or internet protocol once app address address into websites_list adjustable and rehearse area as a separator:

Today you’ll wish to loop through range of web sites and look their particular reputation. To achieve this incorporate the next for cycle your document:

This for circle will go through each items during the websites_list variable and check the updates from the internet site making use of the curl demand.

The echo $status_code report will print out the reaction standing from the curl command. When the web site are running as you expected the curl order will come back a response rule 200 OK , which means the internet site are installed and operating. Normally you’ll obtain another impulse code.

Within the concerning loop, incorporate an if declaration to check on when the response signal try 200 or otherwise not. In the event that responses code are 200 next which means website are operating and you wouldn’t want a Discord notification. Include listed here conditional block your file:

If discover any problems with website next you’ll have a new reaction signal, contained in this occasion you’ll need get an alerts via your own dissension webhook.

To send the notice you should use the curl demand add AN ARTICLE consult toward Discord webhook Address.

Incorporate here curl demand as part of your if statement:

Today let’s study the many arguments: