sysinfo.py upgraded
This commit is contained in:
1 parent
aa7a2eb855
commit
086f4ce912
2 files changed
+79
-1
No files matched your search
@@ -2,6 +2,7 @@ import subprocess
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import re
|
||||
import psutil
|
||||
|
||||
class SysInfo(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
@@ -9,6 +10,13 @@ class SysInfo(commands.Cog):
|
||||
|
||||
def strip_ansi(self, text):
|
||||
return re.sub(r'\x1b\[[0-9;]*[a-zA-Z]|\[[0-9]+[A-Z]', '', text)
|
||||
|
||||
#this command lists all the sysinfo commands, not an actualy sysinfo command##
|
||||
@commands.command()
|
||||
async def sysinfo(self, ctx):
|
||||
sys_commands = [f'!{cmd.name}' for cmd in self.get_commands()]
|
||||
await ctx.reply('\n'.join(sys_commands))
|
||||
######################################################################
|
||||
|
||||
@commands.command()
|
||||
async def fetch(self, ctx):
|
||||
@@ -16,5 +24,66 @@ class SysInfo(commands.Cog):
|
||||
clean = self.strip_ansi(result.stdout)
|
||||
await ctx.reply(f'```\n{clean}\n```')
|
||||
|
||||
@commands.command()
|
||||
async def uptime(self, ctx):
|
||||
result = subprocess.run(['uptime', '-p'], capture_output=True, text=True)
|
||||
await ctx.reply(f'⏱️ {result.stdout.strip()}')
|
||||
|
||||
@commands.command()
|
||||
async def temps(self, ctx):
|
||||
result = subprocess.run(['sensors'], capture_output=True, text=True)
|
||||
await ctx.reply(f'```\n{result.stdout}\n```')
|
||||
|
||||
@commands.command()
|
||||
async def gpu(self, ctx):
|
||||
result = subprocess.run(['envycontrol', '--query'], capture_output=True, text=True)
|
||||
await ctx.reply(f'I am on {result.stdout.strip()} mode esef!')
|
||||
|
||||
@commands.command()
|
||||
async def top(self, ctx):
|
||||
result = subprocess.run(['ps', 'aux', '--sort=-%cpu'], capture_output=True, text=True)
|
||||
lines = result.stdout.splitlines()
|
||||
top5 = '\n'.join(lines[:6]) # header + 5 processes
|
||||
await ctx.reply(f'```\n{top5}\n```')
|
||||
|
||||
@commands.command()
|
||||
async def mem(self, ctx):
|
||||
mem = psutil.virtual_memory()
|
||||
await ctx.reply(f'💾 Memory Usage: {mem.percent}% ({mem.used // (1024**2)}MB / {mem.total // (1024**2)}MB)')
|
||||
|
||||
@commands.command()
|
||||
async def cpu(self, ctx):
|
||||
cpu_percent = psutil.cpu_percent(interval=1)
|
||||
await ctx.reply(f'⚡ CPU Usage: {cpu_percent}%')
|
||||
|
||||
@commands.command()
|
||||
async def load(self, ctx):
|
||||
load1, load5, load15 = psutil.getloadavg()
|
||||
await ctx.reply(f'📊 Load Average: {load1:.2f}, {load5:.2f}, {load15:.2f}')
|
||||
|
||||
@commands.command()
|
||||
async def net(self, ctx):
|
||||
net = psutil.net_io_counters()
|
||||
await ctx.reply(f'📡 Network I/O: {net.bytes_sent} sent, {net.bytes_recv} received')
|
||||
|
||||
@commands.command()
|
||||
async def battery(self, ctx):
|
||||
battery = psutil.sensors_battery()
|
||||
if battery:
|
||||
await ctx.reply(f'Battery: {battery.percent}% {"Charging" if battery.power_plugged else "Not Charging"}')
|
||||
|
||||
@commands.command()
|
||||
async def processes(self, ctx):
|
||||
processes = psutil.pids()
|
||||
await ctx.reply(f'Processes: {len(processes)} running processes ')
|
||||
|
||||
@commands.command()
|
||||
async def stats(self, ctx):
|
||||
cpu = psutil.cpu_percent(interval=1)
|
||||
ram = psutil.virtual_memory().percent
|
||||
disk = psutil.disk_usage('/').percent
|
||||
reply = f'CPU: {cpu}% | RAM: {ram}% | Disk: {disk}%'
|
||||
await ctx.reply(reply)
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(SysInfo(bot))
|
||||
Reference in new issue
Block a user