代码如下:
[Python] 纯文本查看 复制代码import os
import time
import psutil
from datetime import datetime, timedelta
def check_network_traffic():
net_io = psutil.net_io_counters()
bytes_sent1 = net_io.bytes_sent
bytes_recv1 = net_io.bytes_recv
time.sleep(1)
net_io = psutil.net_io_counters()
bytes_sent2 = net_io.bytes_sent
bytes_recv2 = net_io.bytes_recv
sent_speed = (bytes_sent2 - bytes_sent1) / 1024
recv_speed = (bytes_recv2 - bytes_recv1) / 1024
return sent_speed + recv_speed
def schedule_shutdown():
for _ in range(10):#总共循环检测10次
network_traffic = check_network_traffic()
if network_traffic
放到服务器后,在控制面板——计划任务——执行自定义脚本中设置即可
微信图片_20240514170507.png (312.81 KB, 下载次数: 0)
下载附件
2024-5-14 17:05 上传