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/modules/ping.py

22 lines
747 B
Python
Raw Normal View History

2020-08-07 06:47:23 +00:00
import time
2020-08-12 16:01:34 +00:00
2020-09-19 10:35:13 +00:00
import psutil
2020-08-12 16:01:34 +00:00
2020-09-19 06:21:06 +00:00
async def main():
2020-08-12 16:01:34 +00:00
Boot_Start = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(psutil.boot_time()))
2020-08-07 06:47:23 +00:00
time.sleep(0.5)
Cpu_usage = psutil.cpu_percent()
2020-08-12 16:01:34 +00:00
RAM = int(psutil.virtual_memory().total / (1027 * 1024))
2020-08-07 06:47:23 +00:00
RAM_percent = psutil.virtual_memory().percent
2020-08-12 16:01:34 +00:00
Swap = int(psutil.swap_memory().total / (1027 * 1024))
2020-08-07 06:47:23 +00:00
Swap_percent = psutil.swap_memory().percent
BFH = r'%'
2020-08-12 16:01:34 +00:00
return ("Pong!\n" + "系统运行时间:%s" % Boot_Start \
+ "\n当前CPU使用率%s%s" % (Cpu_usage, BFH) \
+ "\n物理内存:%dM 使用率:%s%s" % (RAM, RAM_percent, BFH) \
+ "\nSwap内存%dM 使用率:%s%s" % (Swap, Swap_percent, BFH))
2020-09-19 06:21:06 +00:00
2020-09-19 10:35:13 +00:00
command = {'ping': 'ping'}