
python实现监控数据存储磁盘性能
python实现监控数据存储磁盘性能
·
import psutil
import time
def monitor_disk_performance(interval=1):
while True:
disk_usage = psutil.disk_usage('/')
print(f"磁盘总容量: {disk_usage.total / (1024 * 1024)} MB")
print(f"已用空间: {disk_usage.used / (1024 * 1024)} MB")
print(f"剩余空间: {disk_usage.free / (1024 * 1024)} MB")
print(f"使用率: {disk_usage.percent}%")
print("--------------------")
time.sleep(interval)
if __name__ == "__main__":
monitor_disk_performance()
更多推荐
所有评论(0)