[TD-91] refactor monitor module
This commit is contained in:
parent
7dc72d3f99
commit
1c3021cd43
|
@ -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
|
||||
|
|
|
@ -22,10 +22,38 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_MONITOR_SYSTEM_H
|
||||
#define TDENGINE_MONITOR_SYSTEM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue