Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/ping.py
2020-08-07 14:47:23 +08:00

19 lines
No EOL
920 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import psutil
import time
async def ping():
Boot_Start = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(psutil.boot_time()))
time.sleep(0.5)
Cpu_usage = psutil.cpu_percent()
RAM = int(psutil.virtual_memory().total/(1027*1024))
RAM_percent = psutil.virtual_memory().percent
Swap = int(psutil.swap_memory().total/(1027*1024))
Swap_percent = psutil.swap_memory().percent
Net_sent = psutil.net_io_counters().bytes_sent
Net_recv = psutil.net_io_counters().bytes_recv
Net_spkg = psutil.net_io_counters().packets_sent
Net_rpkg = psutil.net_io_counters().packets_recv
BFH = r'%'
return("Pong!\n"+"系统运行时间:%s\033[1;m" % Boot_Start\
+"\n当前CPU使用率%s%s\033[1;m" % (Cpu_usage,BFH)\
+"\n物理内存:%dM 使用率:%s%s\033[1;m" % (RAM,RAM_percent,BFH)\
+"\nSwap内存%dM 使用率:%s%s\033[1;m" % (Swap,Swap_percent,BFH))