From f12ecefe1433c4a4a72c4e2885ee21654e82abc1 Mon Sep 17 00:00:00 2001 From: luocai Date: Mon, 11 Nov 2024 10:08:24 +0800 Subject: [PATCH] make report slow. --- Server/SystemUsage.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; }