GithubHelp home page GithubHelp logo

willitcode / serverstatus Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 22 KB

A tiny Python script to ICMP ping servers and send a Discord message if they're down.

License: GNU General Public License v3.0

Python 88.09% Dockerfile 6.17% Shell 5.74%
discord discord-bot discord-py server icmp ping

serverstatus's Introduction

Server Status

A tiny Python script to ICMP ping servers and send a Discord message if they're down.

Usage

Outside of Docker

Head over to the releases and download the file main.py from the latest stable release.

Run main.py (Make sure you're in the same directory with main.py and that it's a directory where you're okay with main.py living semi-permanately):

python3 main.py

It will error out. This is because you need to enter a valid bot token in config.ini. See configuration for more information on that.

After configuration, run main.py again to actually start the bot. It's recommended to use some way of autostarting the script and to run it on a machine that will have high uptime, like a server.

Configuration

First, make sure you've run main.py (or the Docker container) at least once to generate the config file.

Then, edit the configuration file with your text editor of choice. Outside of Docker, it'll be wherever main.py is (provided you ran main.py from the directory that contains main.py). With Docker, it'll be wherever you put it.

Values:

Value Description Required
token The bot token. Information about getting a bot token can be found in the discord.py documentation. Yes
status Discord will display this as what the bot is "playing". It comes set to "echo 'R'; while true; do echo 'E'; done" by default, you can set it to whatever you want. No
error_message What the bot will send in the specified channel(s) if a server goes down. {address} will be replaced with the address of the server that went down. See this for information about @mentioning people here. Yes
success_message What the bot will send in the specified channel(s) after a server comes back up. {address} will be replaced with the address of the server that went down. See this for information about @mentioning people here. Yes

Next, you need to specify a/some server(s) to monitor. This is a bit weird, so buckle up. Underneath the [servers] section, type something like this:

server1 = <server address here>

Technically, "server1" can be whatever you want. It has no effect on what the program does. Continue to add servers until all your servers are added. Just make sure you don't name two servers the same thing.

You also need to specifiy one or more channels to send message(s) to when the server goes down or comes back up. This is very similar to servers. Underneath the [channels] section, type something like this:

channel1 = <channel id here>

Again, what "channel1" is set to has no effect on what the program does. Just make sure you don't name two channels the same thing.

How to get a channel's ID:

  1. Make sure you have developer mode on in Discord. If you don't or you're unsure, you can enable it by going to user settings > appearance > developer mode
  2. Go to the server that has the channel you want the messages to be sent to in it
  3. Right click (or tap and hold) on the channel
  4. Click copy ID
  5. Paste the ID into config.ini in the appropriate place
  6. Repeat steps 2 through 5 until all the channels you'd like messages sent to have been added

Updating

Outside of Docker

Delete main.py (DO NOT delete config.ini), download the new main.py from the releases, put it where the old main.py was, and run it again/restart your service. Simple as that.

Contributing

Just open a pull request! That's what open source is all about.

If you don't know how to code but you found a bug or have an issue, open an issue.

FAQ

How do I @mention myself, others, @everyone, or @here in the message the bot sends if a server goes down or comes back up?

With @everyone and @here, it's easy. Just type @everyone or @here where you want the mention to be.

However, if you want to mention a specific person, it's a bit harder. First, you need to get your user ID:

  1. Make sure you have developer mode on in Discord. If you don't or you're unsure, you can enable it by going to user settings > appearance > developer mode
  2. Find the user you want to mention somewhere
  3. On desktop: right-click the user and click copy ID
  4. On mobile: tap on the user to bring up their profile, click the three dots in the top right, and click copy ID.

Then, open the config, and where you want the mention, put:

<@user ID here>

NOTE: The @ is VERY important.

serverstatus's People

Contributors

willitcode avatar

Watchers

 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.