MikyStar / UpMonitor

Run CRON jobs to notify on Discord if an HTTP endpoint is down

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Up Monitor

Run CRON jobs to notify on Discord if an HTTP endoint is down

Setup

  1. Requirements
  1. Clone the project
git clone https://github.com/MikyStar/UpMonitor.git
  1. Create a configuration file
cp config/config.example.ts config/config.ts

Edit it according to the config file section

  1. Install dependencies
pnpm i
  1. Run server
pnpm start
# OR run with pm2, check npm scripts for more
pnpm daemon:start

WARNING: Discord connection at startup often fails, hence using PM2 for restarts

Config file

You should make your own configuration file at config/config.ts based on config/config.example.ts

import { IConfig } from './IConfig'; // Provides IntelliSense

export const config: IConfig = {
  discordToken: 'Token',
  errorsChannelID: 'Global Discord errors channel ID',
  logsChannelID: 'Global Discord logs channel ID',

  endpointsConfigs: [
    {
      name: 'Endpoint name',
      url: 'http://url.com',
      expectedStatusCode: 200,
      channelID: 'Discord Channel ID',
      cronJobSchedule: '15 14 1 * *', // At 14:15 on day-of-month 1

      // Optional, here are the default values
      retry: {
        times: 2,
        waitSeconds: 30,
      }
    },
  ],
};

Discord

Add bot to channel

  1. Go to Discord developper console
  2. Create an application
  3. Generate connexion token
  • Go to Bot section
  • Reset secret
  • Copy
  1. Invite to channel
  • Go to OAuth section
  • Go to URL Generator
  • Scope > Bot > Send Messages
  • Copy URL
  • Open URL and follow the invite process
  • Go to the channel's settings in Discord App
  • Add member and toggle it's permissions so that it can send messages

Tasks

Using CLI-Manager for task handling.

About

Run CRON jobs to notify on Discord if an HTTP endpoint is down


Languages

Language:TypeScript 100.0%