Code Monkey home page Code Monkey logo

discord-webhook-uptime-2022's Introduction

discord-webhook-uptime-2022

A simple NodeJS application that can monitor one or multiple domains to see if the service is down, and send a notification on Discord to let you know of the incident.

Config parameters

These are all the parameters that can be configured inside the config.json file. An example is also available, see config.json.example for a working example.

seconds_between_scans

  • Required: ✅
  • Example value: 60
  • Description: This determines how long we should wait between each scan in seconds of all the domains.

domains

  • Required: ✅
  • Example value: []
  • Description: The list of domains we need to monitor. Each domain is expected to be provided in a specific format, so please check all the domains[] parameters to see what data you need to provide.

domains[].name

  • Required: ✅
  • Example value: "Google"
  • Description: The name of the domain/service that you are monitoring, it's pretty much a label that you can use to indicate what this domain/service is exactly.

domains[].url

  • Required: ✅
  • Example value: "https://google.com/"
  • Description: The URL of the domain we need to ping, as long as we don't receive a 4XX or 5XX or any network error on that URL, we mark it as available.

domains[].discordWebhookUrl

  • Required: ✅
  • Example value: "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  • Description: The Discord webhook URL we need to trigger once a domain has been marked as unavailable.

domains[].failedScanCountUntilNotification

  • Required: ✅
  • Example value: 3
  • Description: The amount of times the check needs to fail in a row before we mark the domain as unavailable.

domains[].roleIdToMention

  • Required: ❌
  • Example value: "1033772800198070345"
  • Description: The ID of the role you want to mention inside the uptime notification for that domain. Can be left omitted or set to null if you do not need this.

Example service

discord-webhook-uptime-2022.service

[Unit]
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
Description="Service to launch the discord-webhook-uptime application to monitor specific URLs"

StartLimitIntervalSec=300
StartLimitBurst=5


[Service]
WorkingDirectory=/home/pi/projects/discord-webhook-uptime-2022/
ExecStartPre=/bin/bash -c 'until host discord.com; do sleep 1; done; sleep 10'
ExecStart=/home/pi/projects/discord-webhook-uptime-2022/start_service.sh
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=default.target

start_service.sh

#!/bin/bash
echo "Changing node version with NVM..."
. /home/pi/.nvm/nvm.sh;
nvm use
echo "Starting script..."
node main.js

discord-webhook-uptime-2022's People

Contributors

crazyvito11 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.