Ways to use dissension Webhooks to Get Notifications to suit your site Status on Ubuntu 18.04

The author picked the Apache computer software base to get a contribution included in the Write for contributions program.


When you yourself have vital website you’ll wish to know when they’re experiencing any problems to fix them before there’s a bearing on the users. One method to obtain announcements is set-up alerts through a text-based speak program.

Discord is actually a hosted cam program similar to Slack. With Discord, you are able to set up a no cost messaging system that lets you keep in touch with sms, graphics, sound, and video clip. Although it supplies advanced functions, you’ll be able to sign up for complimentary, and possesses people designed for Microsoft windows, macOS, Linux, Android os, and apple’s ios.

Inside guide, you may arrange your very own dissension servers, establish a Discord webhook, write a Bash script that may look into the reputation of a list of websites, and examination announcements from the host to your dissension station.


Before you begin this article you’ll require the next:

An Ubuntu 18.04 servers which will operate the monitoring script and speak to dissension (monitor-server). You can easily put this servers upwards through this original host build Tips Guide.

In the event that you don’t have a site you would like to watch yet, build the apache-server with Simple tips to apply the Apache online servers on Ubuntu 18.04 and make certain to complete Step 5 on setting up an online number.

a Discord levels. You can check out the Discord registration page to sign up for a totally free Discord accounts.

Step 1 — Creating Your Own Discord Webhook

Once you’ve open the Discord levels you’ll create your own private dissension machine.

Initial, log in to the Discord membership within internet browser or begin your own dissension application and then click on the generate a servers option.

After that pick a reputation to suit your host and click from the Create a machine switch.

Subsequent, you’ll configure their dissension webhook. The webhooks become unique URLs that can be used to connect treatments collectively. Discord’s webhooks allow you to speed up your own messages and submit facts news to your Discord book stations.

In this tutorial, you certainly will send a notification towards webhook when a particular solution on your own machine goes down, and dissension will ensure you will get those emails on your own station.

To generate a webhook you have to basic simply click your own route after which click the change route switch correct next to your channel’s identity.

After that go through the Webhooks tab and click the build Webhook option.

Next, select a name for your webhook, inside tutorial we’ll utilize notifications since this is exactly what our Bash software does—alert us in case any particular one your web sites decreases.

Copy the webhook Address and conserve they for later. Ultimately, click the salvage switch.

You’ve got their dissension accounts, machine, and webhook. You can now move on to develop a test apply for their software to monitor.

2 — promoting a Test File (Optional)

Should you don’t get own website to test already, total this step to incorporate a test file to check on how your own monitoring script is going to work. Ensure that you run these commands on the apache-server.

Very first, create the test document using the appropriate order:

Atart exercising . information to your file, so you’re able to scan it’s operating:

Save and exit the file.

Now navigate to http:// your_domain /test within browser to make sure you can receive the text within the examination document.

Within the next step, you’ll start to grow your tracking program.

Step Three — Promoting Their Tracking Script

Now that you’ve designed your webhook, you’ll go ahead and create your Bash program that may look into the reaction rule of one’s websites. In the event that any of the websites returns a reputation unlike 200 okay , your program will send a request into the dissension webhook so you will receive a notification in your Discord station.

Note: you could utilize every other programming language to create a script in this way.

Very first SSH into their monitor-server that you’re utilizing to run your spying software.

Start with creating a file at home folder. We’ll telephone call the document check_status.sh contained in this tutorial.

With your favorite book editor open the file:

Your regimen loader to distinguish this executable document as a Bash script, create listed here line to reach the top of document:

All outlines beginning with a # were an opinion. The feedback is recommended, but creating responses inside script will make it easier for others to appreciate what the software really does:

Subsequent, specify your Discord webhook as a changeable. Put the Address you duplicated previously to suit your webhook:

As you’ll perhaps utilize this software to check the standing of multiple escort in West Valley City sites, make a changeable known as websites_list and store the domain names or internet protocol address address associated with website you want to keep track of. If you’re by using the elective test file within this information, be sure to add /test after the domain or internet protocol address:

In the event that you’re keeping track of more than one website, you can include more domain names or IP address to your websites_list adjustable and rehearse area as a separator:

Now you’ll would you like to loop through range of web pages and look their reputation. To do so add this amazing for circle to your file:

This for circle goes through each object inside the websites_list varying and check the updates in the internet site using curl demand.

The echo $status_code report will print the impulse position from the curl command. If site are running as expected the curl command will come back a reply code 200 okay , meaning that the web site was up and running. Usually you’ll receive another responses signal.

Inside the for loop, add an if statement to check if the response code is 200 or not. If responses code is 200 subsequently this means the website try run and you wouldn’t need a Discord notice. Put these conditional block your document:

If there are any difficulties with the web site then you’ll have another type of response signal, within celebration you’ll wish see a notice via your own dissension webhook.

To transmit the alerts you can use the curl demand to submit A POST demand to your dissension webhook URL.

Include the subsequent curl demand as part of your if declaration:

Today let’s study the many arguments:


Comments are closed