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
2020-08-18 21:12:38 +08:00

17 lines
717 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
BFH = r'%'
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))