├── screenshot1.jpg ├── config.json ├── requirements.txt ├── README.md └── main.py /screenshot1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BreadCatto/Server-Monitor/HEAD/screenshot1.jpg -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "PREFIX": ".", 3 | "TOKEN": "input your bot token", 4 | "SERVER_NAME": "Your Node Name Eg.(us1)", 5 | "SHOW IP": False 6 | } 7 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiofiles==0.7.0 2 | aiohttp==3.7.4.post0 3 | async-timeout==3.0.1 4 | asyncpg==0.25.0 5 | attrs==21.2.0 6 | certifi==2021.10.8 7 | chardet==4.0.0 8 | charset-normalizer==2.0.7 9 | psutil==5.9.0 10 | discord==1.7.3 11 | discord.py==1.7.3 12 | dnspython==2.1.0 13 | easy-pil==0.1.4 14 | idna==3.3 15 | multidict==5.2.0 16 | uptime==3.0.1 17 | Pillow==8.4.0 18 | py-cpuinfo==8.0.0 19 | requests==2.26.0 20 | typing_extensions==4.0.1 21 | urllib3==1.26.7 22 | yarl==1.7.2 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Server-Monitor 2 | A discord bot to monitor your server with easy installation. 3 | 4 | [Support Server](https://discord.gg/TFyj6jBDRD) | [Contact Email](mailto:contact@breadkitten.xyz?subject=Contact%20Bread) 5 | 6 | # Install Modules/ Dependancies 7 | ``` 8 | pip install -r requirements.txt 9 | ``` 10 | 11 | 12 | 13 | 14 | 15 | 16 | # Commands 17 | 18 | ``` 19 | * stats [To Show status of all servers] 20 | * (server_name) [To Show the status of a specific server] 21 | ``` 22 | 23 | # Configuration [In config.json] 24 | 25 | ``` 26 | * PREFIX 27 | * BOT_TOKEN 28 | * SERVER_NAME 29 | * SHOW_IP 30 | ``` 31 | 32 | # Done 33 | 34 | The Bot in now configured and you can run it. 35 | 36 | # Some Extra 37 | * Install the bot in the server you want status of. 38 | * To install it in multiple servers, just Install it in all the servers using same bot token and different server_name. 39 | 40 | # Screenshots 41 | 42 | ![Screenshot1](https://github.com/BreadCatto/Server-Monitor/raw/main/screenshot1.jpg) 43 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import datetime 3 | import json 4 | import requests 5 | import psutil 6 | from uptime import uptime 7 | import cpuinfo 8 | from discord.ext import commands 9 | 10 | 11 | with open('config.json') as json_file: 12 | data = json.load(json_file) 13 | 14 | BOT_TOKEN = data["TOKEN"] 15 | NODE_NAME = data["SERVER_NAME"] 16 | PREFIX = data["PREFIX"] 17 | SHOW_IP = data["SHOW_IP"] 18 | 19 | client = commands.Bot(command_prefix=PREFIX) 20 | 21 | client.remove_command("help") 22 | 23 | @client.event 24 | async def on_ready(): 25 | print(f"ready {client.user} !") 26 | 27 | start_time = datetime.datetime.utcnow() 28 | 29 | 30 | @client.command(aliases=[NODE_NAME]) 31 | async def stats(ctx): 32 | up = uptime() 33 | time = float(up) 34 | day = time // (24 * 3600) 35 | time = time % (24 * 3600) 36 | hour = time // 3600 37 | time %= 3600 38 | minutes = time // 60 39 | time %= 60 40 | seconds = time 41 | uptime_stamp = ("%dd %dh %dm %ds" % (day, hour, minutes, seconds)) 42 | cpu = cpuinfo.get_cpu_info()["brand_raw"] 43 | threads = cpuinfo.get_cpu_info()["count"] 44 | cpu_usage = f"CPU Usage: {psutil.cpu_percent(interval=1)}%" 45 | ram_usage = f"Ram Usage: {round(psutil.virtual_memory().used/1000000000, 2)}GB / {round(psutil.virtual_memory().total/1000000000, 2)}GB" 46 | swap_usage = f"SWAP Usage: {round(psutil.swap_memory().used/1000000000, 2)}GB / {round(psutil.swap_memory().total/1000000000, 2)}GB" 47 | disk_usage = f"Disk Usage: {round(psutil.disk_usage('/').used/1000000000, 2)}GB / {round(psutil.disk_usage('/').total/1000000000, 2)}GB" 48 | response = requests.get(f"http://ip-api.com/json/").json() 49 | if SHOW_IP == True: 50 | aip = response['query'] 51 | else: 52 | aip = "Disabled" 53 | physical_info = f"CPU: {threads} Threads | {cpu}\nIP: {aip}" 54 | 55 | 56 | embed = discord.Embed(title=f"{NODE_NAME} Stats", description=f"**----- Node Info ----**\n**```\n{cpu_usage} \n{ram_usage}\n{swap_usage}\n{disk_usage}```**\n**----- Physical Info -----**\n**```\n{physical_info}```**", color=discord.Color.blue()) 57 | embed.set_thumbnail(url=ctx.guild.icon_url) 58 | embed.set_footer(text=f"Uptime: {uptime_stamp}", icon_url=ctx.guild.icon_url) 59 | await ctx.send(embed=embed) 60 | 61 | 62 | client.run(BOT_TOKEN) 63 | --------------------------------------------------------------------------------