From 7316dbdddbd39aac03667836850c145480885f94 Mon Sep 17 00:00:00 2001 From: cppla <i@cpp.la> Date: Wed, 13 Jul 2022 16:55:38 +0800 Subject: [PATCH] update --- server/src/main.cpp | 21 +++++++++++++-------- server/src/main.h | 9 +++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/server/src/main.cpp b/server/src/main.cpp index bb56270..d0a1e22 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -310,15 +310,19 @@ void CMain::WatchdogMessage(int ClientNetID, double load_1, double load_5, doubl if (expression.value() > 0) { int ClientID = ClientNetToClient(ClientNetID); - printf("node info: %s\n", Client(ClientID)->m_aUsername); - printf("node info: %s\n", Client(ClientID)->m_aName); - printf("node info: %s\n", Client(ClientID)->m_aType); - printf("node info: %s\n", Client(ClientID)->m_aHost); - printf("node info: %s\n\n", Client(ClientID)->m_aLocation); - printf("watchdog name: %s\n", Watchdog(ID)->m_aName); - printf("watchdog rule: %s\n", Watchdog(ID)->m_aRule); + time_t currentStamp = (long long)time(/*ago*/0); + if ((currentStamp-Client(ClientID)->m_AlarmLastTime) > 1800) + { + Client(ClientID)->m_AlarmLastTime = currentStamp; + printf("node info: %s\n", Client(ClientID)->m_aUsername); + printf("node info: %s\n", Client(ClientID)->m_aName); + printf("node info: %s\n", Client(ClientID)->m_aType); + printf("node info: %s\n", Client(ClientID)->m_aHost); + printf("node info: %s\n\n", Client(ClientID)->m_aLocation); + printf("watchdog name: %s\n", Watchdog(ID)->m_aName); + printf("watchdog rule: %s\n", Watchdog(ID)->m_aRule); + } } - ID++; } } @@ -675,3 +679,4 @@ int main(int argc, const char *argv[]) return RetVal; } + diff --git a/server/src/main.h b/server/src/main.h index 258c10c..9055406 100644 --- a/server/src/main.h +++ b/server/src/main.h @@ -38,10 +38,11 @@ class CMain char m_aPassword[128]; int m_aMonthStart; //track month network traffic. by: https://cpp.la - int64_t m_LastNetworkIN; - int64_t m_LastNetworkOUT; - int64 m_TimeConnected; - int64 m_LastUpdate; + int64_t m_LastNetworkIN; //restore month traffic info. + int64_t m_LastNetworkOUT; //restore month traffic info. + int64_t m_TimeConnected; + int64_t m_LastUpdate; + int64_t m_AlarmLastTime; //record last alarm time. struct CStats {