diff --git a/src/dnode/inc/dnodeLog.h b/src/dnode/inc/dnodeLog.h index 380e93dd7b2abf728e392a3c22e322686bb9489d..18a5874e444ebd7be9dc998ab428100beeef8cef 100644 --- a/src/dnode/inc/dnodeLog.h +++ b/src/dnode/inc/dnodeLog.h @@ -39,10 +39,6 @@ extern int32_t ddebugFlag; #define dPrint(...) \ { taosPrintLog("DND ", 255, __VA_ARGS__); } -#define dLError(...) taosLogError(__VA_ARGS__) dError(__VA_ARGS__) -#define dLWarn(...) taosLogWarn(__VA_ARGS__) dWarn(__VA_ARGS__) -#define dLPrint(...) taosLogPrint(__VA_ARGS__) dPrint(__VA_ARGS__) - #ifdef __cplusplus } #endif diff --git a/src/inc/monitor.h b/src/inc/monitor.h index bb63bf63a45c9235278bbad76a941ec29a24fc74..b1229cca6b1fc18ac9bef4d6ea506c9a0ef59627 100644 --- a/src/inc/monitor.h +++ b/src/inc/monitor.h @@ -22,10 +22,38 @@ extern "C" { #include +typedef struct { + char * acctId; + int64_t currentPointsPerSecond; + int64_t maxPointsPerSecond; + int64_t totalTimeSeries; + int64_t maxTimeSeries; + int64_t totalStorage; + int64_t maxStorage; + int64_t totalQueryTime; + int64_t maxQueryTime; + int64_t totalInbound; + int64_t maxInbound; + int64_t totalOutbound; + int64_t maxOutbound; + int64_t totalDbs; + int64_t maxDbs; + int64_t totalUsers; + int64_t maxUsers; + int64_t totalStreams; + int64_t maxStreams; + int64_t totalConns; + int64_t maxConns; + int8_t accessState; +} SAcctMonitorObj; + int32_t monitorInitSystem(); int32_t monitorStartSystem(); -void monitorStopSystem(); -void monitorCleanUpSystem(); +void monitorStopSystem(); +void monitorCleanUpSystem(); +void monitorSaveAcctLog(SAcctMonitorObj *pMonObj); +void monitorSaveLog(int32_t level, const char *const format, ...); +void monitorExecuteSQL(char *sql); #ifdef __cplusplus } diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 7d9c343a85d33e0f93d6b3071329bdaf967d44d9..9f1d8033b1141825c36e08aa21415a9d439a6943 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -509,7 +509,6 @@ typedef struct { int64_t pointsWritten; uint8_t status; uint8_t role; - uint8_t accessState; uint8_t replica; uint8_t reserved[5]; } SVnodeLoad; diff --git a/src/mnode/inc/mgmtLog.h b/src/mnode/inc/mgmtLog.h index fb4bb398284c3e1af8886f6e1223357b4b35936f..a99fa225933b7935f463352a8ca58e92b44d1b97 100644 --- a/src/mnode/inc/mgmtLog.h +++ b/src/mnode/inc/mgmtLog.h @@ -21,6 +21,7 @@ extern "C" { #endif #include "tlog.h" +#include "monitor.h" extern int32_t mdebugFlag; extern int32_t sdbDebugFlag; @@ -41,9 +42,9 @@ extern int32_t sdbDebugFlag; #define mPrint(...) \ { taosPrintLog("MND ", 255, __VA_ARGS__); } -#define mLError(...) mError(__VA_ARGS__) -#define mLWarn(...) mWarn(__VA_ARGS__) -#define mLPrint(...) mPrint(__VA_ARGS__) +#define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) +#define mLWarn(...) monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) +#define mLPrint(...) monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) #define sdbError(...) \ if (sdbDebugFlag & DEBUG_ERROR) { \ @@ -60,9 +61,9 @@ extern int32_t sdbDebugFlag; #define sdbPrint(...) \ { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); } -#define sdbLError(...) sdbError(__VA_ARGS__) -#define sdbLWarn(...) sdbWarn(__VA_ARGS__) -#define sdbLPrint(...) sdbPrint(__VA_ARGS__) +#define sdbLError(...) monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) +#define sdbLWarn(...) monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) +#define sdbLPrint(...) monitorSaveLog(0, __VA_ARGS__); sdbPrint(__VA_ARGS__) #ifdef __cplusplus } diff --git a/src/plugins/http/inc/httpLog.h b/src/plugins/http/inc/httpLog.h index 1723c30ab9b6ae0e1333dd7c6d6a727752a640c6..19fa46bd238ef00d5752c3b7f010c28fcd92c1ca 100644 --- a/src/plugins/http/inc/httpLog.h +++ b/src/plugins/http/inc/httpLog.h @@ -39,9 +39,4 @@ extern int32_t httpDebugFlag; #define httpPrint(...) \ { taosPrintLog("HTP ", 255, __VA_ARGS__); } -#define httpLError(...) taosLogError(__VA_ARGS__) httpError(__VA_ARGS__) -#define httpLWarn(...) taosLogWarn(__VA_ARGS__) httpWarn(__VA_ARGS__) -#define httpLPrint(...) taosLogPrint(__VA_ARGS__) httpPrint(__VA_ARGS__) - - #endif diff --git a/src/plugins/monitor/inc/monitorSystem.h b/src/plugins/monitor/inc/monitorSystem.h deleted file mode 100644 index 91aa4d2ad65c33654dc15f3e083c6a4ab50e3a96..0000000000000000000000000000000000000000 --- a/src/plugins/monitor/inc/monitorSystem.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_MONITOR_SYSTEM_H -#define TDENGINE_MONITOR_SYSTEM_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct { - char * acctId; - int64_t currentPointsPerSecond; - int64_t maxPointsPerSecond; - int64_t totalTimeSeries; - int64_t maxTimeSeries; - int64_t totalStorage; - int64_t maxStorage; - int64_t totalQueryTime; - int64_t maxQueryTime; - int64_t totalInbound; - int64_t maxInbound; - int64_t totalOutbound; - int64_t maxOutbound; - int64_t totalDbs; - int64_t maxDbs; - int64_t totalUsers; - int64_t maxUsers; - int64_t totalStreams; - int64_t maxStreams; - int64_t totalConns; - int64_t maxConns; - int8_t accessState; -} SAcctMonitorObj; - -void monitorSaveAcctLog(SAcctMonitorObj *pMonObj); -void monitorSaveLog(int32_t level, const char *const format, ...); -void monitorExecuteSQL(char *sql); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/src/plugins/monitor/src/monitorSystem.c b/src/plugins/monitor/src/monitorMain.c similarity index 98% rename from src/plugins/monitor/src/monitorSystem.c rename to src/plugins/monitor/src/monitorMain.c index a2c73fbb588f4bba4e9baea9461dbdf744a6278d..dade813d9c600fe76decdd550d3cc97d28a63525 100644 --- a/src/plugins/monitor/src/monitorSystem.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -25,7 +25,7 @@ #include "tscUtil.h" #include "tsclient.h" #include "dnode.h" -#include "monitorSystem.h" +#include "monitor.h" #define monitorError(...) \ if (monitorDebugFlag & DEBUG_ERROR) { \ @@ -228,7 +228,6 @@ static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code) { void monitorStopSystem() { monitorPrint("monitor module is stopped"); tsMonitorConn.state = MONITOR_STATE_STOPPED; - // taosLogFp = NULL; if (tsMonitorConn.initTimer != NULL) { taosTmrStopA(&(tsMonitorConn.initTimer)); } @@ -399,6 +398,8 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) { } void monitorSaveLog(int32_t level, const char *const format, ...) { + if (tsMonitorConn.state != MONITOR_STATE_INITIALIZED) return; + va_list argpointer; char sql[SQL_LENGTH] = {0}; int32_t max_length = SQL_LENGTH - 30; @@ -421,6 +422,10 @@ void monitorSaveLog(int32_t level, const char *const format, ...) { } void monitorExecuteSQL(char *sql) { + if (tsMonitorConn.state != MONITOR_STATE_INITIALIZED) return; + monitorTrace("monitor:%p, execute sql: %s", tsMonitorConn.conn, sql); - taos_query_a(tsMonitorConn.conn, sql, NULL, NULL); + + // bug while insert binary + // taos_query_a(tsMonitorConn.conn, sql, NULL, NULL); } diff --git a/src/vnode/inc/vnodeLog.h b/src/vnode/inc/vnodeLog.h index 5650321fdb1869f8a7130117392c0a706f9ba128..450220e17f60e6e1c9e36cc3c301958fd146237b 100644 --- a/src/vnode/inc/vnodeLog.h +++ b/src/vnode/inc/vnodeLog.h @@ -39,10 +39,6 @@ extern int32_t ddebugFlag; #define dPrint(...) \ { taosPrintLog("DND ", 255, __VA_ARGS__); } -#define dLError(...) taosLogError(__VA_ARGS__) dError(__VA_ARGS__) -#define dLWarn(...) taosLogWarn(__VA_ARGS__) dWarn(__VA_ARGS__) -#define dLPrint(...) taosLogPrint(__VA_ARGS__) dPrint(__VA_ARGS__) - #ifdef __cplusplus } #endif diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 6936dc0345780e907497c4b970e60d7aba078638..26791ae77c34b41e56d9b695885bc2df61a644b1 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -332,6 +332,9 @@ static void vnodeBuildVloadMsg(char *pNode, void * param) { SVnodeLoad *pLoad = &pStatus->load[pStatus->openVnodes++]; pLoad->vgId = htonl(pVnode->vgId); + pLoad->totalStorage = htobe64(pLoad->totalStorage); + pLoad->compStorage = htobe64(pLoad->compStorage); + pLoad->pointsWritten = htobe64(pLoad->pointsWritten); pLoad->status = pVnode->status; pLoad->role = pVnode->role; pLoad->replica = pVnode->syncCfg.replica;