Add cpu/memory usage to info command
This commit is contained in:
parent
62c9c764d6
commit
6199d867dc
|
@ -11,6 +11,7 @@ import re
|
|||
import calendar
|
||||
import pendulum
|
||||
import datetime
|
||||
import psutil
|
||||
|
||||
|
||||
class Core:
|
||||
|
@ -22,6 +23,8 @@ class Core:
|
|||
self.help_embeds = {}
|
||||
self.results_per_page = 10
|
||||
self.commands = None
|
||||
self.process = psutil.Process()
|
||||
self.process.cpu_percent()
|
||||
|
||||
@commands.command()
|
||||
@utils.custom_perms(send_messages=True)
|
||||
|
@ -204,6 +207,11 @@ class Core:
|
|||
|
||||
if hasattr(self.bot, 'uptime'):
|
||||
embed.add_field(name='Uptime', value=(pendulum.utcnow() - self.bot.uptime).in_words())
|
||||
|
||||
memory_usage = self.process.memory_full_info().uss / 1024**2
|
||||
cpu_usage = self.process.cpu_percent() / psutil.cpu_count()
|
||||
embed.add_field(name='Memory Usage', value='{:.2f} MiB'.format(memory_usage))
|
||||
emebd.add_field(name='CPU Usage', value='{}%'.format(cpu_usage))
|
||||
embed.set_footer(text=self.bot.description)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
|
Loading…
Reference in a new issue