Opublikowano Dodaj komentarz

How To Use Discord Webhooks to have Notifications for Your internet site standing on Ubuntu 18.04

How To Use Discord Webhooks to have Notifications for Your internet site standing on Ubuntu 18.04

Mcdougal selected the Apache pc software Foundation to receive a donation as part of the Write for contributions regimen.


dating someone with an std

Once you have crucial sites youll want to know while they are experiencing any problems to help you correct them before theres a direct impact on your people. The easiest way to receive notifications is to install alerts through a text-based chat program.

Discord is actually a managed cam program much like Slack. With Discord, you can easily setup a no cost texting system that lets you talk to sms, imagery, audio, and video. Even though it supplies premiums services, you are able to sign up for cost-free, and possesses clients designed for windowpanes, macOS, Linux, Android, and apple’s ios.

In this information, you will configure your own personal dissension host, produce a dissension webhook, write a Bash software that may look into the updates of a listing of sites, and test notifications out of your servers to your Discord channel.


Before you begin this guide youll require the following:

An Ubuntu 18.04 server that will work their monitoring script and consult with dissension (monitor-server). Possible put this host right up by simply following this preliminary Server set-up manual.

In the event that you dont bring a web site you may like to monitor yet, created the apache-server with Ideas on how to Install the Apache online Server on Ubuntu 18.04 and make sure to complete Step 5 on starting an online host.

a Discord membership. You can travel to the dissension registration page to sign up for a free dissension levels.

1 Creating Your Discord Webhook

top 5 free dating sites

Once you have launched the Discord accounts possible create your very own exclusive dissension host.

First, log in to your own Discord levels in your browser or establish the dissension app and click regarding the generate a machine button.

Next choose a name to suit your machine and then click on build a servers switch.

Next, you will arrange the Discord webhook. The webhooks become distinctive URLs which you can use to link treatments along. Discords webhooks lets you speed up their emails and deliver information posts towards Discord text channel.

Inside information, you can expect to send an alerts to your webhook whenever a specific provider on your own host falls, and Discord will make sure that you will get those information on your route.

To produce a webhook you have to earliest visit your station right after which click the Edit station switch right next to the channels term.

After that click the Webhooks case and click the Create Webhook button.

From then on, choose a reputation for the webhook, within this tutorial well incorporate Alerts since this is exactly what our very own Bash software is going to doalert united states in case that one of your web pages falls.


Duplicate your own webhook URL and cut they for afterwards. Ultimately, click the rescue button.

You now have the dissension levels, server, and webhook. Now you can proceed to build a test apply for your own program to monitor.

Step two generating a Test document (Optional)

If you dont get own internet site to evaluate currently, complete this step to include a test file to test exactly how their tracking software will be able to work. Always run these commands in your apache-server.

Very first, create the examination file together with the soon after demand:

Add some information towards file, so you’re able to always check its functioning:

Rescue and leave the file.

Today navigate to http:// your_domain /test in your browser to ensure that you can get the text from inside the test file.

Within the next action, youll beginning to build your tracking script.

3 Creating Your Own Tracking Script

Now that youve designed your webhook, youll go right ahead and make your Bash program that’ll check the responses rule of your own web pages. When the websites returns a reputation distinctive from 200 OK , their program will be sending a request into the dissension webhook and that means you will get a notification in your Discord route.

Note: You could use various other programming language to construct a software similar to this.

Initial SSH in to your own monitor-server that youre using to perform the spying software.

Begin by generating a document in your house folder. Well telephone call the file check_status.sh in this guide.

Together with your favored text editor available the file:

For regimen loader to distinguish this executable document as a Bash software, put here range to the top of this file:

All contours beginning with a # become a remark. The remarks tend to be optional, but having comments within program can make it easier for others in order to comprehend what the program does:

Further, specify your own Discord webhook as an adjustable. Create the Address you copied earlier for your webhook:

As youll possibly use this program to check on the reputation of multiple web pages, making a changeable called websites_list and store the domain names or IP address contact information from the web sites you want to keep track of. If youre by using the optional test file inside guide, ensure that you add /test after their domain name or IP address:

In case your monitoring more than one website, you can add most domain names or internet protocol address tackles on the websites_list changeable and use room as a separator:

Today youll would you like to loop through a number of website and check their reputation. To accomplish this incorporate this amazing for cycle your file:

This for loop is certainly going through each product inside websites_list adjustable and look the reputation associated with the web site together with the curl command.

The echo $status_code report will print-out the reaction reputation in the curl command. In the event that web site are running needlessly to say the curl demand will return an answer code 200 OK , which means that the website is ready to go. Normally youll see another impulse laws.

Inside the for loop, add an if statement to check if the response code is 200 or not. In the event that reaction laws try 200 then which means that the website are working while wouldnt require a Discord notice. Incorporate this amazing conditional block towards document:

If there are any issues with website then youll have another reaction laws, inside show youll need to receive a notification via the dissension webhook.

To send the notification you need to use the curl order add A POST request for the Discord webhook Address.

Incorporate the subsequent curl request as part of your if report:

Now lets analyze different arguments:

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *