added uptime, but id does not work with hours. will fix later
This commit is contained in:
parent
1a436f87bf
commit
a49009c53c
3 changed files with 20 additions and 7 deletions
|
@ -1,9 +1,10 @@
|
|||
import os
|
||||
import re
|
||||
import time
|
||||
import psutil
|
||||
import platform
|
||||
from util import hook
|
||||
|
||||
|
||||
def replace(text, wordDic):
|
||||
rc = re.compile('|'.join(map(re.escape, wordDic)))
|
||||
|
||||
|
@ -24,9 +25,9 @@ def checkProc(checked_stats):
|
|||
def mem(inp):
|
||||
".mem -- Displays the bot's current memory usage."
|
||||
if os.name == 'posix':
|
||||
checked_stats = 'Threads VmRSS VmSize VmPeak VmStk'
|
||||
checked_stats = 'Threads VmRSS VmSize VmPeak VmStk VmData'
|
||||
stats = checkProc(checked_stats)
|
||||
pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'}
|
||||
pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'}
|
||||
stats = replace(stats, pretty_names)
|
||||
return stats
|
||||
|
||||
|
@ -40,6 +41,18 @@ def mem(inp):
|
|||
return 'error: operating system not currently supported'
|
||||
|
||||
|
||||
@hook.command("up", autohelp=False)
|
||||
@hook.command(autohelp=False)
|
||||
def uptime(inp):
|
||||
proc = psutil.Process(os.getpid())
|
||||
up_time = proc.create_time
|
||||
up_time = time.time() - up_time
|
||||
up_time = time.localtime(up_time)
|
||||
up_time = time.strftime("Uptime: %M:%S", up_time)
|
||||
return up_time
|
||||
|
||||
|
||||
|
||||
@hook.command("system", autohelp=False)
|
||||
@hook.command(autohelp=False)
|
||||
def sys(inp):
|
||||
|
|
Reference in a new issue