diff --git a/Server/SystemUsage.cpp b/Server/SystemUsage.cpp index 8d38d13..b2a7d64 100644 --- a/Server/SystemUsage.cpp +++ b/Server/SystemUsage.cpp @@ -48,7 +48,9 @@ void SystemUsage::start() { auto transmitGigabyte = static_cast(back.transmitBytes - front.transmitBytes) / gigabyte; auto speed = (receiveGigabyte + transmitGigabyte) / duration.count() * SpeedInterval.count(); LOG(info) << "network speed: " << std::fixed << std::setprecision(2) << speed << "GB/h"; - if (speed >= 1.f) { // 一个小时1GB的流量 + static system_clock::time_point lastNotify; + auto now = system_clock::now(); + if ((speed >= 1.f) && (duration_cast(now - lastNotify) > minutes(10))) { // 一个小时1GB的流量 std::ostringstream oss; oss << "当前服务器流量存在异常, " << DateTime::toString(front.time) << " - " << DateTime::toString(back.time) << ": " << std::endl; @@ -58,6 +60,7 @@ void SystemUsage::start() { auto manager = Amass::Singleton::instance(); if (manager) manager->sendMessage(NotifyServerChan, oss.str()); LOG(warning) << oss.str(); + lastNotify = now; } break; }