added cpu info to stats
This commit is contained in:
parent
6acb1f68d3
commit
e8779f16df
4 changed files with 41 additions and 16 deletions
|
@ -9,6 +9,8 @@ from modules.permission import requires_admin
|
||||||
from modules.sentenceprocessing import send_message
|
from modules.sentenceprocessing import send_message
|
||||||
from modules.settings import instance as settings_manager
|
from modules.settings import instance as settings_manager
|
||||||
import requests
|
import requests
|
||||||
|
import psutil
|
||||||
|
import cpuinfo
|
||||||
|
|
||||||
settings = settings_manager.settings
|
settings = settings_manager.settings
|
||||||
|
|
||||||
|
@ -125,7 +127,9 @@ class BaseCommands(commands.Cog):
|
||||||
memory_info = psutil.virtual_memory() # type: ignore
|
memory_info = psutil.virtual_memory() # type: ignore
|
||||||
total_memory = memory_info.total / (1024**3)
|
total_memory = memory_info.total / (1024**3)
|
||||||
used_memory = memory_info.used / (1024**3)
|
used_memory = memory_info.used / (1024**3)
|
||||||
free_memory = memory_info.available / (1024**3)
|
|
||||||
|
|
||||||
|
cpu_name = cpuinfo.get_cpu_info()["brand"]
|
||||||
|
|
||||||
|
|
||||||
with open(memory_file, "r") as file:
|
with open(memory_file, "r") as file:
|
||||||
|
@ -143,8 +147,11 @@ class BaseCommands(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=k.memory_embed_field(),
|
name=k.system_info(),
|
||||||
value=k.memory_usage(used=used_memory, total=total_memory, percent=round(used_memory/total_memory * 100))
|
value=f"""
|
||||||
|
{k.memory_usage(used=used_memory, total=total_memory, percent=round(used_memory/total_memory * 100))}
|
||||||
|
{k.cpu_info(cpu_name)}
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(settings["splash_text_loc"], "r") as f:
|
with open(settings["splash_text_loc"], "r") as f:
|
||||||
|
|
|
@ -138,6 +138,7 @@
|
||||||
"blacklisted": "blacklisted",
|
"blacklisted": "blacklisted",
|
||||||
"blacklisted_user": "Blacklisted user",
|
"blacklisted_user": "Blacklisted user",
|
||||||
"edit_fail": "Failed to edit message",
|
"edit_fail": "Failed to edit message",
|
||||||
"memory_embed_field": "RAM details"
|
"system_info": "System information",
|
||||||
|
"cpu_info": "CPU: {cpu}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2306,19 +2306,35 @@ def edit_fail(lang:str|None=None):
|
||||||
if lang == 'fr': return "Failed to edit message"
|
if lang == 'fr': return "Failed to edit message"
|
||||||
if lang == 'it': return "Failed to edit message"
|
if lang == 'it': return "Failed to edit message"
|
||||||
else: raise ValueError(f'Invalid language {lang}')
|
else: raise ValueError(f'Invalid language {lang}')
|
||||||
def memory_embed_field(lang:str|None=None):
|
def system_info(lang:str|None=None):
|
||||||
"""
|
"""
|
||||||
### Locales
|
### Locales
|
||||||
- En: **RAM details**
|
- En: **System information**
|
||||||
- Es: **RAM details**
|
- Es: **System information**
|
||||||
- Fi: **RAM details**
|
- Fi: **System information**
|
||||||
- Fr: **RAM details**
|
- Fr: **System information**
|
||||||
- It: **RAM details**
|
- It: **System information**
|
||||||
"""
|
"""
|
||||||
if not lang: lang=default_lang
|
if not lang: lang=default_lang
|
||||||
if lang == 'en': return "RAM details"
|
if lang == 'en': return "System information"
|
||||||
if lang == 'es': return "RAM details"
|
if lang == 'es': return "System information"
|
||||||
if lang == 'fi': return "RAM details"
|
if lang == 'fi': return "System information"
|
||||||
if lang == 'fr': return "RAM details"
|
if lang == 'fr': return "System information"
|
||||||
if lang == 'it': return "RAM details"
|
if lang == 'it': return "System information"
|
||||||
|
else: raise ValueError(f'Invalid language {lang}')
|
||||||
|
def cpu_info(cpu,lang:str|None=None):
|
||||||
|
"""
|
||||||
|
### Locales
|
||||||
|
- En: **CPU: {cpu}**
|
||||||
|
- Es: **CPU: {cpu}**
|
||||||
|
- Fi: **CPU: {cpu}**
|
||||||
|
- Fr: **CPU: {cpu}**
|
||||||
|
- It: **CPU: {cpu}**
|
||||||
|
"""
|
||||||
|
if not lang: lang=default_lang
|
||||||
|
if lang == 'en': return "CPU: {cpu}".format_map({"cpu": cpu})
|
||||||
|
if lang == 'es': return "CPU: {cpu}".format_map({"cpu": cpu})
|
||||||
|
if lang == 'fi': return "CPU: {cpu}".format_map({"cpu": cpu})
|
||||||
|
if lang == 'fr': return "CPU: {cpu}".format_map({"cpu": cpu})
|
||||||
|
if lang == 'it': return "CPU: {cpu}".format_map({"cpu": cpu})
|
||||||
else: raise ValueError(f'Invalid language {lang}')
|
else: raise ValueError(f'Invalid language {lang}')
|
||||||
|
|
|
@ -9,3 +9,4 @@ python-dotenv
|
||||||
dotenv
|
dotenv
|
||||||
pillow
|
pillow
|
||||||
watchdog
|
watchdog
|
||||||
|
py-cpuinfo
|
Loading…
Add table
Add a link
Reference in a new issue