def info(ctx, message):
"""
Displays Rero information
:param ctx:
:param message:
:return:
"""
# TODO: this command needs to be fixed later
servs = len(ctx.servers)
ch = list(ctx.get_all_channels())
channels = len(ch)
mem = list(ctx.get_all_members())
members = len(mem)
current = datetime.datetime.now()
diff = current - ctx.startup_timestamp
days = diff.days
seconds = diff.seconds
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
# total_c = ctx.usage_track_admin['admin'] + ctx.usage_track['user']
# total_m = ctx.usage_track_admin['total_msg']
# r_min = (days * 24 * 60) + (h * 60) + m
# msg_rate = float(total_c / r_min)
# total_msg_rate = float(total_m / r_min)
try:
proc = psutil.Process(pid=os.getpid())
rss = float(proc.memory_info().rss) / 1000000
rss_per = float(proc.memory_percent())
cpu_per = float(proc.cpu_percent(interval=0.2))
sys_str = "RAM: {0:.2f} MB | CPU Usage: {1:.2f}% (*calculated for `2 ms` interval*)" \
.format(rss, rss_per, cpu_per)
except (psutil.NoSuchProcess, psutil.ZombieProcess, psutil.AccessDenied):
sys_str = ""
# ret_str = "`Connected to '{0}' Servers with '{1}' Channels and '{2}' Members`" \
# "\nCurrent uptime is {3} Days, {4} Hours, {5} Minutes, {6} Seconds" \
# "\n**{7}** commands were __used__ till now (**~{8:.2f}** per min)" \
# "\n**{9}** messages were __sent__ till now (**~{10:.2f}** per min)" \
# "\n**{11}** messages were __seen__ till now (**~{12:.2f}** per min)" \
# "\n{13}" \
# .format(str(servs), str(channels), str(members), str(days), str(h),
# str(m), str(s), str(total_c), msg_rate, ctx.rero_sent_message,
# float(ctx.rero_sent_message / r_min), str(total_m), total_msg_rate, sys_str)
ret_str = "`Connected to '{0}' Servers with '{1}' Channels and '{2}' Members`" \
"\nCurrent uptime is {3} Days, {4} Hours, {5} Minutes, {6} Seconds" \
"\n{7}\n**SHARD: {8} / 2**" \
.format(str(servs), str(channels), str(members), str(days), str(h),
str(m), str(s), sys_str, ctx.current_shard)
await ctx.send_message(message.channel, ret_str)
评论列表
文章目录