From f98ceb04bec417a6f6e6a14cb6f7083524d96b7e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 8 Apr 2022 16:43:20 +0800 Subject: [PATCH] feat: send monitor information in multi-process mode --- include/libs/monitor/monitor.h | 12 +- source/dnode/mgmt/bm/bmHandle.c | 7 + source/dnode/mgmt/dm/dmHandle.c | 15 +- source/dnode/mgmt/dm/dmMonitor.c | 404 +++++++++++++++------ source/dnode/mgmt/dm/dmWorker.c | 21 +- source/dnode/mgmt/inc/dmInt.h | 17 +- source/dnode/mgmt/inc/dndInt.h | 24 +- source/dnode/mgmt/inc/vmInt.h | 1 + source/dnode/mgmt/main/dndTransport.c | 6 +- source/dnode/mgmt/mm/mmHandle.c | 10 +- source/dnode/mgmt/mm/mmInt.c | 5 - source/dnode/mgmt/qm/qmHandle.c | 7 + source/dnode/mgmt/sm/smHandle.c | 7 + source/dnode/mgmt/vm/vmHandle.c | 22 ++ source/dnode/mgmt/vm/vmInt.c | 45 +-- source/libs/monitor/src/monMsg.c | 499 +++++++++++++++++++++++++- 16 files changed, 912 insertions(+), 190 deletions(-) diff --git a/include/libs/monitor/monitor.h b/include/libs/monitor/monitor.h index 342796b070..3cecb139e1 100644 --- a/include/libs/monitor/monitor.h +++ b/include/libs/monitor/monitor.h @@ -162,7 +162,7 @@ typedef struct { } SMonVmInfo; int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo); -int32_t tDeserializeSMonVMmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo); +int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo); void tFreeSMonVmInfo(SMonVmInfo *pInfo); typedef struct { @@ -171,7 +171,7 @@ typedef struct { } SMonQmInfo; int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo); -int32_t tDeserializeSMonQMmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo); +int32_t tDeserializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo); void tFreeSMonQmInfo(SMonQmInfo *pInfo); typedef struct { @@ -191,6 +191,14 @@ int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo); int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo); void tFreeSMonBmInfo(SMonBmInfo *pInfo); +typedef struct { + SArray *pVloads; // SVnodeLoad +} SMonVloadInfo; + +int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo); +int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo); +void tFreeSMonVloadInfo(SMonVloadInfo *pInfo); + typedef struct { const char *server; uint16_t port; diff --git a/source/dnode/mgmt/bm/bmHandle.c b/source/dnode/mgmt/bm/bmHandle.c index 2ae9b3817f..8abfa8955c 100644 --- a/source/dnode/mgmt/bm/bmHandle.c +++ b/source/dnode/mgmt/bm/bmHandle.c @@ -16,6 +16,13 @@ #define _DEFAULT_SOURCE #include "bmInt.h" +void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo) { + if (pWrapper->procType == PROC_CHILD) { + dmGetMonitorSysInfo(&bmInfo->sys); + monGetLogs(&bmInfo->logs); + } +} + int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { SDnode *pDnode = pWrapper->pDnode; SRpcMsg *pReq = &pMsg->rpcMsg; diff --git a/source/dnode/mgmt/dm/dmHandle.c b/source/dnode/mgmt/dm/dmHandle.c index 40d85b2a9a..c0175fed10 100644 --- a/source/dnode/mgmt/dm/dmHandle.c +++ b/source/dnode/mgmt/dm/dmHandle.c @@ -42,8 +42,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES); if (pWrapper != NULL) { - req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad)); - vmMonitorVnodeLoads(pWrapper, req.pVloads); + SMonVloadInfo info = {0}; + dmGetVnodeLoads(pWrapper, &info); + req.pVloads = info.pVloads; dndReleaseWrapper(pWrapper); } @@ -117,7 +118,6 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { return TSDB_CODE_OPS_NOT_SUPPORT; } - static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndType ntype, SNodeMsg *pMsg) { SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, ntype); if (pWrapper != NULL) { @@ -209,10 +209,15 @@ void dmInitMsgHandle(SMgmtWrapper *pWrapper) { dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, dmProcessMgmtMsg, DEFAULT_HANDLE); // Requests handled by MNODE - dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, dmProcessStatusMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, dmProcessMonitorMsg, DEFAULT_HANDLE); dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); // Monitor info exchange between processes - dndSetMsgHandle(pWrapper, TDMT_MON_DISK_INFO, dmProcessStatusMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_MM_INFO, dmProcessMonitorMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_VM_INFO, dmProcessMonitorMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_QM_INFO, dmProcessMonitorMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_SM_INFO, dmProcessMonitorMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_BM_INFO, dmProcessMonitorMsg, DEFAULT_HANDLE); + dndSetMsgHandle(pWrapper, TDMT_MON_VM_LOAD, dmProcessMonitorMsg, DEFAULT_HANDLE); } diff --git a/source/dnode/mgmt/dm/dmMonitor.c b/source/dnode/mgmt/dm/dmMonitor.c index 7117bc5d12..b9199efac2 100644 --- a/source/dnode/mgmt/dm/dmMonitor.c +++ b/source/dnode/mgmt/dm/dmMonitor.c @@ -16,20 +16,6 @@ #define _DEFAULT_SOURCE #include "dmInt.h" -static int32_t dmGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) { - tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name)); - pInfo->logdir.size = tsLogSpace.size; - tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name)); - pInfo->tempdir.size = tsTempSpace.size; - - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES); - if (pWrapper != NULL) { - vmMonitorTfsInfo(pWrapper, pInfo); - dndReleaseWrapper(pWrapper); - } - return 0; -} - static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { pInfo->protocol = 1; pInfo->dnode_id = pDnode->dnodeId; @@ -39,6 +25,305 @@ static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { pInfo->uptime = (taosGetTimestampMs() - pDnode->rebootTime) / (86400000.0f); + SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE); + if (pWrapper != NULL) { + pInfo->has_mnode = pWrapper->required; + dndReleaseWrapper(pWrapper); + } + tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name)); + pInfo->logdir.size = tsLogSpace.size; + tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name)); + pInfo->tempdir.size = tsTempSpace.size; +} + +static void dmGetMonitorInfo(SDnode *pDnode, SMonDmInfo *pInfo) { + dmGetMonitorBasicInfo(pDnode, &pInfo->basic); + dmGetMonitorSysInfo(&pInfo->sys); + dmGetMonitorDnodeInfo(pDnode, &pInfo->dnode); +} + +void dmSendMonitorReport(SDnode *pDnode) { + if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; + dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort); + + SMonDmInfo dmInfo = {0}; + SMonMmInfo mmInfo = {0}; + SMonVmInfo vmInfo = {0}; + SMonQmInfo qmInfo = {0}; + SMonSmInfo smInfo = {0}; + SMonBmInfo bmInfo = {0}; + + SRpcMsg req = {0}; + SRpcMsg rsp; + SEpSet epset = {.inUse = 0, .numOfEps = 1}; + tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); + epset.eps[0].port = tsServerPort; + + dmGetMonitorInfo(pDnode, &dmInfo); + + SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE); + if (pWrapper != NULL) { + if (!tsMultiProcess) { + mmGetMonitorInfo(pWrapper, &mmInfo); + } else { + req.msgType = TDMT_MON_MM_INFO; + dndSendRecv(pDnode, &epset, &req, &rsp); + tDeserializeSMonMmInfo(rsp.pCont, rsp.contLen, &mmInfo); + rpcFreeCont(rsp.pCont); + } + dndReleaseWrapper(pWrapper); + } + + pWrapper = dndAcquireWrapper(pDnode, VNODES); + if (pWrapper != NULL) { + if (!tsMultiProcess) { + vmGetMonitorInfo(pWrapper, &vmInfo); + } else { + req.msgType = TDMT_MON_VM_INFO; + dndSendRecv(pDnode, &epset, &req, &rsp); + dndReleaseWrapper(pWrapper); + tDeserializeSMonVmInfo(rsp.pCont, rsp.contLen, &vmInfo); + rpcFreeCont(rsp.pCont); + } + } + + pWrapper = dndAcquireWrapper(pDnode, QNODE); + if (pWrapper != NULL) { + if (!tsMultiProcess) { + qmGetMonitorInfo(pWrapper, &qmInfo); + } else { + req.msgType = TDMT_MON_QM_INFO; + dndSendRecv(pDnode, &epset, &req, &rsp); + dndReleaseWrapper(pWrapper); + tDeserializeSMonQmInfo(rsp.pCont, rsp.contLen, &qmInfo); + rpcFreeCont(rsp.pCont); + } + dndReleaseWrapper(pWrapper); + } + + pWrapper = dndAcquireWrapper(pDnode, SNODE); + if (pWrapper != NULL) { + if (!tsMultiProcess) { + smGetMonitorInfo(pWrapper, &smInfo); + } else { + req.msgType = TDMT_MON_SM_INFO; + dndSendRecv(pDnode, &epset, &req, &rsp); + dndReleaseWrapper(pWrapper); + tDeserializeSMonSmInfo(rsp.pCont, rsp.contLen, &smInfo); + rpcFreeCont(rsp.pCont); + } + dndReleaseWrapper(pWrapper); + } + + pWrapper = dndAcquireWrapper(pDnode, BNODE); + if (pWrapper != NULL) { + if (!tsMultiProcess) { + bmGetMonitorInfo(pWrapper, &bmInfo); + } else { + req.msgType = TDMT_MON_BM_INFO; + dndSendRecv(pDnode, &epset, &req, &rsp); + dndReleaseWrapper(pWrapper); + tDeserializeSMonBmInfo(rsp.pCont, rsp.contLen, &bmInfo); + rpcFreeCont(rsp.pCont); + } + dndReleaseWrapper(pWrapper); + } + + monSetDmInfo(&dmInfo); + monSetMmInfo(&mmInfo); + monSetVmInfo(&vmInfo); + monSetQmInfo(&qmInfo); + monSetSmInfo(&smInfo); + monSetBmInfo(&bmInfo); + tFreeSMonMmInfo(&mmInfo); + tFreeSMonVmInfo(&vmInfo); + tFreeSMonQmInfo(&qmInfo); + tFreeSMonSmInfo(&smInfo); + tFreeSMonBmInfo(&bmInfo); + monSendReport(); +} + +int32_t dmProcessGetMonMmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, MNODE); + if (pWrapper == NULL) return -1; + + SMonMmInfo mmInfo = {0}; + mmGetMonitorInfo(pWrapper, &mmInfo); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonMmInfo(pRsp, rspLen, &mmInfo); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonMmInfo(&mmInfo); + return 0; +} + +int32_t dmProcessGetMonVmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, VNODES); + if (pWrapper == NULL) return -1; + + SMonVmInfo vmInfo = {0}; + vmGetMonitorInfo(pWrapper, &vmInfo); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonVmInfo(pRsp, rspLen, &vmInfo); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonVmInfo(&vmInfo); + return 0; +} + +int32_t dmProcessGetMonQmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, QNODE); + if (pWrapper == NULL) return -1; + + SMonQmInfo qmInfo = {0}; + qmGetMonitorInfo(pWrapper, &qmInfo); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonQmInfo(pRsp, rspLen, &qmInfo); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonQmInfo(&qmInfo); + return 0; +} + +int32_t dmProcessGetMonSmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, SNODE); + if (pWrapper == NULL) return -1; + + SMonSmInfo smInfo = {0}; + smGetMonitorInfo(pWrapper, &smInfo); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonSmInfo(pRsp, rspLen, &smInfo); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonSmInfo(&smInfo); + return 0; +} + +int32_t dmProcessGetMonBmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, BNODE); + if (pWrapper == NULL) return -1; + + SMonBmInfo bmInfo = {0}; + bmGetMonitorInfo(pWrapper, &bmInfo); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonBmInfo(NULL, 0, &bmInfo); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonBmInfo(pRsp, rspLen, &bmInfo); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonBmInfo(&bmInfo); + return 0; +} + +int32_t dmProcessGetVnodeLoadsReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq) { + SMgmtWrapper *pWrapper = dndAcquireWrapper(pMgmt->pDnode, VNODES); + if (pWrapper == NULL) return -1; + + SMonVloadInfo vloads = {0}; + vmGetVnodeLoads(pWrapper, &vloads); + dndReleaseWrapper(pWrapper); + + int32_t rspLen = tSerializeSMonVloadInfo(NULL, 0, &vloads); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + tSerializeSMonVloadInfo(pRsp, rspLen, &vloads); + pReq->pRsp = pRsp; + pReq->rspLen = rspLen; + tFreeSMonVloadInfo(&vloads); + return 0; +} + +void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) { + if (!tsMultiProcess) { + vmGetVnodeLoads(pWrapper, pInfo); + } else { + SRpcMsg req = {.msgType = TDMT_MON_VM_LOAD}; + SRpcMsg rsp = {0}; + SEpSet epset = {.inUse = 0, .numOfEps = 1}; + tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); + epset.eps[0].port = tsServerPort; + + dndSendRecv(pWrapper->pDnode, &epset, &req, &rsp); + if (rsp.code == 0) { + tDeserializeSMonVloadInfo(rsp.pCont, rsp.contLen, pInfo); + } + rpcFreeCont(rsp.pCont); + } +} + +void dmGetMonitorSysInfo(SMonSysInfo *pInfo) { taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system); taosGetCpuCores(&pInfo->cpu_cores); taosGetProcMemory(&pInfo->mem_engine); @@ -47,93 +332,6 @@ static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { pInfo->disk_engine = 0; pInfo->disk_used = tsDataSpace.size.used; pInfo->disk_total = tsDataSpace.size.total; - taosGetCardInfo(&pInfo->net_in, &pInfo->net_out); - taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk); - - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES); - if (pWrapper != NULL) { - vmMonitorVnodeReqs(pWrapper, pInfo); - dndReleaseWrapper(pWrapper); - } - - pWrapper = dndAcquireWrapper(pDnode, MNODE); - if (pWrapper != NULL) { - pInfo->has_mnode = pWrapper->required; - dndReleaseWrapper(pWrapper); - } + taosGetCardInfoDelta(&pInfo->net_in, &pInfo->net_out); + taosGetProcIODelta(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk); } - -void dmSendMonitorReport(SDnode *pDnode) { - if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; - dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort); - - SMonInfo *pMonitor = monCreateMonitorInfo(); - if (pMonitor == NULL) return; - - SMonBasicInfo basicInfo = {0}; - dmGetMonitorBasicInfo(pDnode, &basicInfo); - monSetBasicInfo(pMonitor, &basicInfo); - - SMonClusterInfo clusterInfo = {0}; - SMonVgroupInfo vgroupInfo = {0}; - SMonGrantInfo grantInfo = {0}; - - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE); - if (pWrapper != NULL) { - if (mmMonitorMnodeInfo(pWrapper, &clusterInfo, &vgroupInfo, &grantInfo) == 0) { - monSetClusterInfo(pMonitor, &clusterInfo); - monSetVgroupInfo(pMonitor, &vgroupInfo); - monSetGrantInfo(pMonitor, &grantInfo); - } - dndReleaseWrapper(pWrapper); - } - - SMonDnodeInfo dnodeInfo = {0}; - dmGetMonitorDnodeInfo(pDnode, &dnodeInfo); - monSetDnodeInfo(pMonitor, &dnodeInfo); - - SMonDiskInfo diskInfo = {0}; - if (dmGetMonitorDiskInfo(pDnode, &diskInfo) == 0) { - monSetDiskInfo(pMonitor, &diskInfo); - } - - taosArrayDestroy(clusterInfo.dnodes); - taosArrayDestroy(clusterInfo.mnodes); - taosArrayDestroy(vgroupInfo.vgroups); - taosArrayDestroy(diskInfo.datadirs); - - monSendReport(pMonitor); - monCleanupMonitorInfo(pMonitor); -} - -int32_t dmSetDiskInfo(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { - SDnode *pDnode = pMgmt->pDnode; - SMonDiskInfo info = {0}; - - if (tDeserializeSMonDiskInfo(pMsg->rpcMsg.pCont, pMsg->rpcMsg.contLen, &info) != 0) { - dError("failed to parse diskinfo since %s", terrstr()); - return 0; - } - - taosWLockLatch(&pMgmt->latch); - memcpy(&pMgmt->diskInfo, &info, sizeof(SMonDiskInfo)); - taosWUnLockLatch(&pMgmt->latch); - - return 0; -} - -int32_t dmSetVnodeStat(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { - SDnode *pDnode = pMgmt->pDnode; - SVnodesStat info = {0}; - - if (tDeserializeSMonDiskInfo(pMsg->rpcMsg.pCont, pMsg->rpcMsg.contLen, &info) != 0) { - dError("failed to parse diskinfo since %s", terrstr()); - return 0; - } - - taosWLockLatch(&pMgmt->latch); - memcpy(&pMgmt->diskInfo, &info, sizeof(SMonDiskInfo)); - taosWUnLockLatch(&pMgmt->latch); - - return 0; -} \ No newline at end of file diff --git a/source/dnode/mgmt/dm/dmWorker.c b/source/dnode/mgmt/dm/dmWorker.c index 1d11c4d25b..7b2a3c7015 100644 --- a/source/dnode/mgmt/dm/dmWorker.c +++ b/source/dnode/mgmt/dm/dmWorker.c @@ -78,8 +78,23 @@ static void dmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { case TDMT_MND_GRANT_RSP: code = dmProcessGrantRsp(pMgmt, pMsg); break; - case TDMT_MON_DISK_INFO_RSP: - code = dmSetDiskInfo(pMgmt, pMsg); + case TDMT_MON_MM_INFO: + code = dmProcessGetMonMmInfoReq(pMgmt, pMsg); + break; + case TDMT_MON_VM_INFO: + code = dmProcessGetMonVmInfoReq(pMgmt, pMsg); + break; + case TDMT_MON_QM_INFO: + code = dmProcessGetMonQmInfoReq(pMgmt, pMsg); + break; + case TDMT_MON_SM_INFO: + code = dmProcessGetMonSmInfoReq(pMgmt, pMsg); + break; + case TDMT_MON_BM_INFO: + code = dmProcessGetMonBmInfoReq(pMgmt, pMsg); + break; + case TDMT_MON_VM_LOAD: + code = dmProcessGetVnodeLoadsReq(pMgmt, pMsg); break; default: code = dmProcessCDnodeReq(pMgmt->pDnode, pMsg); @@ -134,7 +149,7 @@ int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { return 0; } -int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { +int32_t dmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { SDnodeMgmt *pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->statusWorker; diff --git a/source/dnode/mgmt/inc/dmInt.h b/source/dnode/mgmt/inc/dmInt.h index d7358d0ca4..eee529757e 100644 --- a/source/dnode/mgmt/inc/dmInt.h +++ b/source/dnode/mgmt/inc/dmInt.h @@ -37,11 +37,6 @@ typedef struct SDnodeMgmt { const char *path; SDnode *pDnode; SMgmtWrapper *pWrapper; - - // monitor infos - SMonDiskInfo diskInfo; - SMonVnodesStat vnodesStat; - SMonVnodesLoad vnodesLoad; } SDnodeMgmt; // dmFile.c @@ -59,9 +54,13 @@ int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); int32_t dmProcessCDnodeReq(SDnode *pDnode, SNodeMsg *pMsg); // dmMonitor.c -int32_t dmSetDiskInfo(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t dmSetVnodesStat(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); -int32_t dmSetVnodesLoad(SDnodeMgmt *pMgmt, SNodeMsg *pMsg); +int32_t dmProcessGetVnodeLoadsReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +int32_t dmProcessGetMonMmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +int32_t dmProcessGetMonVmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +int32_t dmProcessGetMonQmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +int32_t dmProcessGetMonSmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +int32_t dmProcessGetMonBmInfoReq(SDnodeMgmt *pMgmt, SNodeMsg *pReq); +void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo); void dmSendMonitorReport(SDnode *pDnode); // dmWorker.c @@ -69,7 +68,7 @@ int32_t dmStartThread(SDnodeMgmt *pMgmt); int32_t dmStartWorker(SDnodeMgmt *pMgmt); void dmStopWorker(SDnodeMgmt *pMgmt); int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); -int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +int32_t dmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/inc/dndInt.h b/source/dnode/mgmt/inc/dndInt.h index 5659becb20..7faf1e4276 100644 --- a/source/dnode/mgmt/inc/dndInt.h +++ b/source/dnode/mgmt/inc/dndInt.h @@ -169,6 +169,7 @@ void dndCleanupTrans(SDnode *pDnode); SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper); SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper); int32_t dndInitMsgHandle(SDnode *pDnode); +void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); // mgmt void dmSetMgmtFp(SMgmtWrapper *pWrapper); @@ -182,22 +183,13 @@ void dmGetMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet); void dmUpdateMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet); void dmSendRedirectRsp(SDnodeMgmt *pMgmt, const SRpcMsg *pMsg); -typedef struct { - int32_t openVnodes; - int32_t totalVnodes; - int32_t masterNum; - int64_t numOfSelectReqs; - int64_t numOfInsertReqs; - int64_t numOfInsertSuccessReqs; - int64_t numOfBatchInsertReqs; - int64_t numOfBatchInsertSuccessReqs; -} SVnodesStat; - -void vmMonitorVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads); -int32_t vmMonitorTfsInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo); -void vmMonitorVnodeReqs(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo); -int32_t mmMonitorMnodeInfo(SMgmtWrapper *pWrapper, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo, - SMonGrantInfo *pGrantInfo); +void dmGetMonitorSysInfo(SMonSysInfo *pInfo); +void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo); +void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo); +void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo); +void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo); +void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo); +void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/inc/vmInt.h b/source/dnode/mgmt/inc/vmInt.h index 889ad7c164..ca210d62c6 100644 --- a/source/dnode/mgmt/inc/vmInt.h +++ b/source/dnode/mgmt/inc/vmInt.h @@ -28,6 +28,7 @@ typedef struct SVnodesMgmt { SHashObj *hash; SRWLatch latch; SVnodesStat state; + SVnodesStat lastState; STfs *pTfs; SQWorkerPool queryPool; SQWorkerPool fetchPool; diff --git a/source/dnode/mgmt/main/dndTransport.c b/source/dnode/mgmt/main/dndTransport.c index e76633bb1f..3b0aca4b39 100644 --- a/source/dnode/mgmt/main/dndTransport.c +++ b/source/dnode/mgmt/main/dndTransport.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - + #define _DEFAULT_SOURCE #include "dndInt.h" @@ -482,4 +482,8 @@ SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) { .parent = pWrapper, .name = pWrapper->name}; return cfg; +} + +void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) { + rpcSendRecv(pDnode->trans.clientRpc, pEpSet, pReq, pRsp); } \ No newline at end of file diff --git a/source/dnode/mgmt/mm/mmHandle.c b/source/dnode/mgmt/mm/mmHandle.c index acf83d4ba8..a8d7590d59 100644 --- a/source/dnode/mgmt/mm/mmHandle.c +++ b/source/dnode/mgmt/mm/mmHandle.c @@ -16,6 +16,15 @@ #define _DEFAULT_SOURCE #include "mmInt.h" +void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo) { + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mndGetMonitorInfo(pMgmt->pMnode, &mmInfo->cluster, &mmInfo->vgroup, &mmInfo->grant); + if (pWrapper->procType == PROC_CHILD) { + dmGetMonitorSysInfo(&mmInfo->sys); + monGetLogs(&mmInfo->logs); + } +} + int32_t mmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { SDnode *pDnode = pWrapper->pDnode; SRpcMsg *pReq = &pMsg->rpcMsg; @@ -161,5 +170,4 @@ void mmInitMsgHandle(SMgmtWrapper *pWrapper) { dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MNODE_HANDLE); dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MNODE_HANDLE); dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MNODE_HANDLE); - } diff --git a/source/dnode/mgmt/mm/mmInt.c b/source/dnode/mgmt/mm/mmInt.c index cd6ea1499f..8d4ac80e72 100644 --- a/source/dnode/mgmt/mm/mmInt.c +++ b/source/dnode/mgmt/mm/mmInt.c @@ -241,8 +241,3 @@ void mmSetMgmtFp(SMgmtWrapper *pWrapper) { pWrapper->fp = mgmtFp; } -int32_t mmMonitorMnodeInfo(SMgmtWrapper *pWrapper, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo, - SMonGrantInfo *pGrantInfo) { - SMnodeMgmt *pMgmt = pWrapper->pMgmt; - return mndGetMonitorInfo(pMgmt->pMnode, pClusterInfo, pVgroupInfo, pGrantInfo); -} diff --git a/source/dnode/mgmt/qm/qmHandle.c b/source/dnode/mgmt/qm/qmHandle.c index 77a9db1175..7f1164bda8 100644 --- a/source/dnode/mgmt/qm/qmHandle.c +++ b/source/dnode/mgmt/qm/qmHandle.c @@ -16,6 +16,13 @@ #define _DEFAULT_SOURCE #include "qmInt.h" +void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo) { + if (pWrapper->procType == PROC_CHILD) { + dmGetMonitorSysInfo(&qmInfo->sys); + monGetLogs(&qmInfo->logs); + } +} + int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { SDnode *pDnode = pWrapper->pDnode; SRpcMsg *pReq = &pMsg->rpcMsg; diff --git a/source/dnode/mgmt/sm/smHandle.c b/source/dnode/mgmt/sm/smHandle.c index a1fa41a686..1e275d016b 100644 --- a/source/dnode/mgmt/sm/smHandle.c +++ b/source/dnode/mgmt/sm/smHandle.c @@ -16,6 +16,13 @@ #define _DEFAULT_SOURCE #include "smInt.h" +void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo) { + if (pWrapper->procType == PROC_CHILD) { + dmGetMonitorSysInfo(&smInfo->sys); + monGetLogs(&smInfo->logs); + } +} + int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { SDnode *pDnode = pWrapper->pDnode; SRpcMsg *pReq = &pMsg->rpcMsg; diff --git a/source/dnode/mgmt/vm/vmHandle.c b/source/dnode/mgmt/vm/vmHandle.c index bcb9ef9e5a..6391fe3570 100644 --- a/source/dnode/mgmt/vm/vmHandle.c +++ b/source/dnode/mgmt/vm/vmHandle.c @@ -16,6 +16,28 @@ #define _DEFAULT_SOURCE #include "vmInt.h" +void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo) { + SVnodesMgmt *pMgmt = pWrapper->pMgmt; + tfsGetMonitorInfo(pMgmt->pTfs, &vmInfo->tfs); + + taosWLockLatch(&pMgmt->latch); + vmInfo->vstat.totalVnodes = pMgmt->state.totalVnodes; + vmInfo->vstat.masterNum = pMgmt->state.masterNum; + vmInfo->vstat.numOfSelectReqs = pMgmt->state.numOfSelectReqs - pMgmt->lastState.numOfSelectReqs; + vmInfo->vstat.numOfInsertReqs = pMgmt->state.numOfInsertReqs - pMgmt->lastState.numOfInsertReqs; + vmInfo->vstat.numOfInsertSuccessReqs = pMgmt->state.numOfInsertSuccessReqs - pMgmt->lastState.numOfInsertSuccessReqs; + vmInfo->vstat.numOfBatchInsertReqs = pMgmt->state.numOfBatchInsertReqs - pMgmt->lastState.numOfBatchInsertReqs; + vmInfo->vstat.numOfBatchInsertSuccessReqs = + pMgmt->state.numOfBatchInsertSuccessReqs - pMgmt->lastState.numOfBatchInsertSuccessReqs; + pMgmt->lastState = pMgmt->state; + taosWUnLockLatch(&pMgmt->latch); + + if (pWrapper->procType == PROC_CHILD) { + dmGetMonitorSysInfo(&vmInfo->sys); + monGetLogs(&vmInfo->logs); + } +} + static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->vgId = pCreate->vgId; pCfg->wsize = pCreate->cacheBlockSize; diff --git a/source/dnode/mgmt/vm/vmInt.c b/source/dnode/mgmt/vm/vmInt.c index b3390ba31c..6a1a5c3987 100644 --- a/source/dnode/mgmt/vm/vmInt.c +++ b/source/dnode/mgmt/vm/vmInt.c @@ -344,38 +344,21 @@ void vmSetMgmtFp(SMgmtWrapper *pWrapper) { pWrapper->fp = mgmtFp; } -int32_t vmMonitorTfsInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo) { - SVnodesMgmt *pMgmt = pWrapper->pMgmt; - if (pMgmt == NULL) return -1; - - return tfsGetMonitorInfo(pMgmt->pTfs, pInfo); -} - -void vmMonitorVnodeReqs(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo) { - SVnodesMgmt *pMgmt = pWrapper->pMgmt; - if (pMgmt == NULL) return; - - SVnodesStat *pStat = &pMgmt->state; - pInfo->req_select = pStat->numOfSelectReqs; - pInfo->req_insert = pStat->numOfInsertReqs; - pInfo->req_insert_success = pStat->numOfInsertSuccessReqs; - pInfo->req_insert_batch = pStat->numOfBatchInsertReqs; - pInfo->req_insert_batch_success = pStat->numOfBatchInsertSuccessReqs; - pInfo->errors = tsNumOfErrorLogs; - pInfo->vnodes_num = pStat->totalVnodes; - pInfo->masters = pStat->masterNum; -} - -void vmMonitorVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads) { +void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) { SVnodesMgmt *pMgmt = pWrapper->pMgmt; SVnodesStat *pStat = &pMgmt->state; - int32_t totalVnodes = 0; - int32_t masterNum = 0; - int64_t numOfSelectReqs = 0; - int64_t numOfInsertReqs = 0; - int64_t numOfInsertSuccessReqs = 0; - int64_t numOfBatchInsertReqs = 0; - int64_t numOfBatchInsertSuccessReqs = 0; + SArray *pLoads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad)); + + int32_t totalVnodes = 0; + int32_t masterNum = 0; + int64_t numOfSelectReqs = 0; + int64_t numOfInsertReqs = 0; + int64_t numOfInsertSuccessReqs = 0; + int64_t numOfBatchInsertReqs = 0; + int64_t numOfBatchInsertSuccessReqs = 0; + + pInfo->pVloads = pLoads; + if (pLoads == NULL) return; taosRLockLatch(&pMgmt->latch); @@ -402,6 +385,7 @@ void vmMonitorVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads) { taosRUnLockLatch(&pMgmt->latch); + taosWLockLatch(&pMgmt->latch); pStat->totalVnodes = totalVnodes; pStat->masterNum = masterNum; pStat->numOfSelectReqs = numOfSelectReqs; @@ -409,4 +393,5 @@ void vmMonitorVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads) { pStat->numOfInsertSuccessReqs = numOfInsertSuccessReqs; pStat->numOfBatchInsertReqs = numOfBatchInsertReqs; pStat->numOfBatchInsertSuccessReqs = numOfBatchInsertSuccessReqs; + taosWUnLockLatch(&pMgmt->latch); } \ No newline at end of file diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c index 27d35d266d..e58179e394 100644 --- a/source/libs/monitor/src/monMsg.c +++ b/source/libs/monitor/src/monMsg.c @@ -18,37 +18,506 @@ #include "tcoding.h" #include "tencode.h" -int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo); -int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo); -void tFreeSMonMmInfo(SMonMmInfo *pInfo) { +static int32_t tEncodeSMonSysInfo(SCoder *encoder, const SMonSysInfo *pInfo) { + if (tEncodeDouble(encoder, pInfo->cpu_engine) < 0) return -1; + if (tEncodeDouble(encoder, pInfo->cpu_system) < 0) return -1; + if (tEncodeFloat(encoder, pInfo->cpu_cores) < 0) return -1; + if (tEncodeI64(encoder, pInfo->mem_engine) < 0) return -1; + if (tEncodeI64(encoder, pInfo->mem_system) < 0) return -1; + if (tEncodeI64(encoder, pInfo->mem_total) < 0) return -1; + if (tEncodeI64(encoder, pInfo->disk_engine) < 0) return -1; + if (tEncodeI64(encoder, pInfo->disk_used) < 0) return -1; + if (tEncodeI64(encoder, pInfo->disk_total) < 0) return -1; + if (tEncodeI64(encoder, pInfo->net_in) < 0) return -1; + if (tEncodeI64(encoder, pInfo->net_out) < 0) return -1; + if (tEncodeI64(encoder, pInfo->io_read) < 0) return -1; + if (tEncodeI64(encoder, pInfo->io_write) < 0) return -1; + if (tEncodeI64(encoder, pInfo->io_read_disk) < 0) return -1; + if (tEncodeI64(encoder, pInfo->io_write_disk) < 0) return -1; + return 0; +} + +static int32_t tDecodeSMonSysInfo(SCoder *decoder, SMonSysInfo *pInfo) { + if (tDecodeDouble(decoder, &pInfo->cpu_engine) < 0) return -1; + if (tDecodeDouble(decoder, &pInfo->cpu_system) < 0) return -1; + if (tDecodeFloat(decoder, &pInfo->cpu_cores) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->mem_engine) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->mem_system) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->mem_total) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->disk_engine) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->disk_used) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->disk_total) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->net_in) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->net_out) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->io_read) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->io_write) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->io_read_disk) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->io_write_disk) < 0) return -1; + return 0; +} + +int32_t tEncodeSMonLogs(SCoder *encoder, const SMonLogs *pInfo) { + if (tEncodeI32(encoder, pInfo->numOfErrorLogs) < 0) return -1; + if (tEncodeI32(encoder, pInfo->numOfInfoLogs) < 0) return -1; + if (tEncodeI32(encoder, pInfo->numOfDebugLogs) < 0) return -1; + if (tEncodeI32(encoder, pInfo->numOfTraceLogs) < 0) return -1; + if (tEncodeI32(encoder, taosArrayGetSize(pInfo->logs)) < 0) return -1; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->logs); ++i) { + SMonLogItem *pLog = taosArrayGet(pInfo->logs, i); + if (tEncodeI64(encoder, pLog->ts) < 0) return -1; + if (tEncodeI8(encoder, pLog->level) < 0) return -1; + if (tEncodeCStr(encoder, pLog->content) < 0) return -1; + } + return 0; +} + +static int32_t tDecodeSMonLogs(SCoder *decoder, SMonLogs *pInfo) { + if (tDecodeI32(decoder, &pInfo->numOfErrorLogs) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->numOfInfoLogs) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->numOfDebugLogs) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->numOfTraceLogs) < 0) return -1; + + int32_t arraySize = 0; + if (tDecodeI32(decoder, &arraySize) < 0) return -1; + + pInfo->logs = taosArrayInit(arraySize, sizeof(SMonLogItem)); + if (pInfo->logs != NULL) return -1; + + for (int32_t i = 0; i < arraySize; ++i) { + SMonLogItem desc = {0}; + if (tDecodeI64(decoder, &desc.ts) < 0) return -1; + int8_t level = 0; + if (tDecodeI8(decoder, &level) < 0) return -1; + desc.level = level; + if (tDecodeCStrTo(decoder, desc.content) < 0) return -1; + taosArrayPush(pInfo->logs, &desc); + } + + return 0; +} + +int32_t tEncodeSMonClusterInfo(SCoder *encoder, const SMonClusterInfo *pInfo) { + if (tEncodeCStr(encoder, pInfo->first_ep) < 0) return -1; + if (tEncodeI32(encoder, pInfo->first_ep_dnode_id) < 0) return -1; + if (tEncodeCStr(encoder, pInfo->version) < 0) return -1; + if (tEncodeFloat(encoder, pInfo->master_uptime) < 0) return -1; + if (tEncodeI32(encoder, pInfo->monitor_interval) < 0) return -1; + if (tEncodeI32(encoder, pInfo->vgroups_total) < 0) return -1; + if (tEncodeI32(encoder, pInfo->vgroups_alive) < 0) return -1; + if (tEncodeI32(encoder, pInfo->vnodes_total) < 0) return -1; + if (tEncodeI32(encoder, pInfo->vnodes_alive) < 0) return -1; + if (tEncodeI32(encoder, pInfo->connections_total) < 0) return -1; + if (tEncodeI32(encoder, taosArrayGetSize(pInfo->dnodes)) < 0) return -1; + if (tEncodeI32(encoder, taosArrayGetSize(pInfo->mnodes)) < 0) return -1; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->dnodes); ++i) { + SMonDnodeDesc *pDesc = taosArrayGet(pInfo->dnodes, i); + if (tEncodeI32(encoder, pDesc->dnode_id) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->dnode_ep) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->status) < 0) return -1; + } + for (int32_t i = 0; i < taosArrayGetSize(pInfo->mnodes); ++i) { + SMonMnodeDesc *pDesc = taosArrayGet(pInfo->mnodes, i); + if (tEncodeI32(encoder, pDesc->mnode_id) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->mnode_ep) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->role) < 0) return -1; + } + return 0; +} + +int32_t tDecodeSMonClusterInfo(SCoder *decoder, SMonClusterInfo *pInfo) { + if (tDecodeCStrTo(decoder, pInfo->first_ep) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->first_ep_dnode_id) < 0) return -1; + if (tDecodeCStrTo(decoder, pInfo->version) < 0) return -1; + if (tDecodeFloat(decoder, &pInfo->master_uptime) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->monitor_interval) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->vgroups_total) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->vgroups_alive) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->vnodes_total) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->vnodes_alive) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->connections_total) < 0) return -1; + + int32_t dnodesSize = 0; + int32_t mnodesSize = 0; + if (tDecodeI32(decoder, &dnodesSize) < 0) return -1; + if (tDecodeI32(decoder, &mnodesSize) < 0) return -1; + + pInfo->dnodes = taosArrayInit(dnodesSize, sizeof(SMonDnodeDesc)); + pInfo->mnodes = taosArrayInit(mnodesSize, sizeof(SMonMnodeDesc)); + if (pInfo->dnodes != NULL || pInfo->mnodes != NULL) return -1; + + for (int32_t i = 0; i < dnodesSize; ++i) { + SMonDnodeDesc desc = {0}; + if (tDecodeI32(decoder, &desc.dnode_id) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.dnode_ep) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.status) < 0) return -1; + taosArrayPush(pInfo->dnodes, &desc); + } + + for (int32_t i = 0; i < mnodesSize; ++i) { + SMonMnodeDesc desc = {0}; + if (tDecodeI32(decoder, &desc.mnode_id) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.mnode_ep) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.role) < 0) return -1; + taosArrayPush(pInfo->mnodes, &desc); + } + return 0; +} + +int32_t tEncodeSMonVgroupInfo(SCoder *encoder, const SMonVgroupInfo *pInfo) { + if (tEncodeI32(encoder, taosArrayGetSize(pInfo->vgroups)) < 0) return -1; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->vgroups); ++i) { + SMonVgroupDesc *pDesc = taosArrayGet(pInfo->vgroups, i); + if (tEncodeI32(encoder, pDesc->vgroup_id) < 0) return -1; + if (tEncodeI32(encoder, pDesc->tables_num) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->database_name) < 0) return -1; + if (tEncodeCStr(encoder, pDesc->status) < 0) return -1; + for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) { + SMonVnodeDesc *pVDesc = &pDesc->vnodes[j]; + if (tEncodeI32(encoder, pVDesc->dnode_id) < 0) return -1; + if (tEncodeCStr(encoder, pVDesc->vnode_role) < 0) return -1; + } + } + return 0; +} + +int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) { + int32_t arraySize = 0; + if (tDecodeI32(decoder, &arraySize) < 0) return -1; + + pInfo->vgroups = taosArrayInit(arraySize, sizeof(SMonVgroupDesc)); + if (pInfo->vgroups != NULL) return -1; + + for (int32_t i = 0; i < arraySize; ++i) { + SMonVgroupDesc desc = {0}; + if (tDecodeI32(decoder, &desc.vgroup_id) < 0) return -1; + if (tDecodeI32(decoder, &desc.tables_num) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.database_name) < 0) return -1; + if (tDecodeCStrTo(decoder, desc.status) < 0) return -1; + for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) { + SMonVnodeDesc vdesc = {0}; + if (tDecodeI32(decoder, &vdesc.dnode_id) < 0) return -1; + if (tDecodeCStrTo(decoder, vdesc.vnode_role) < 0) return -1; + } + taosArrayPush(pInfo->vgroups, &desc); + } + return 0; +} + +int32_t tEncodeSMonGrantInfo(SCoder *encoder, const SMonGrantInfo *pInfo) { + if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1; + if (tEncodeI32(encoder, pInfo->timeseries_used) < 0) return -1; + if (tEncodeI32(encoder, pInfo->timeseries_total) < 0) return -1; + return 0; +} + +int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) { + if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->timeseries_used) < 0) return -1; + if (tDecodeI32(decoder, &pInfo->timeseries_total) < 0) return -1; + return 0; +} + +int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSMonClusterInfo(&encoder, &pInfo->cluster) < 0) return -1; + if (tEncodeSMonVgroupInfo(&encoder, &pInfo->vgroup) < 0) return -1; + if (tEncodeSMonGrantInfo(&encoder, &pInfo->grant) < 0) return -1; + if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1; + if (tEncodeSMonLogs(&encoder, &pInfo->logs) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSMonClusterInfo(&decoder, &pInfo->cluster) < 0) return -1; + if (tDecodeSMonVgroupInfo(&decoder, &pInfo->vgroup) < 0) return -1; + if (tDecodeSMonGrantInfo(&decoder, &pInfo->grant) < 0) return -1; + if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1; + if (tDecodeSMonLogs(&decoder, &pInfo->logs) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonMmInfo(SMonMmInfo *pInfo) { taosArrayDestroy(pInfo->logs.logs); pInfo->logs.logs = NULL; } -int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo); -int32_t tDeserializeSMonVMmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo); -void tFreeSMonVmInfo(SMonVmInfo *pInfo) { +int32_t tEncodeSMonDiskDesc(SCoder *encoder, const SMonDiskDesc *pDesc) { + if (tEncodeCStr(encoder, pDesc->name) < 0) return -1; + if (tEncodeI8(encoder, pDesc->level) < 0) return -1; + if (tEncodeI64(encoder, pDesc->size.total) < 0) return -1; + if (tEncodeI64(encoder, pDesc->size.used) < 0) return -1; + if (tEncodeI64(encoder, pDesc->size.avail) < 0) return -1; +} + +static int32_t tDecodeSMonDiskDesc(SCoder *decoder, SMonDiskDesc *pDesc) { + if (tDecodeCStrTo(decoder, pDesc->name) < 0) return -1; + if (tDecodeI8(decoder, &pDesc->level) < 0) return -1; + if (tDecodeI64(decoder, &pDesc->size.total) < 0) return -1; + if (tDecodeI64(decoder, &pDesc->size.used) < 0) return -1; + if (tDecodeI64(decoder, &pDesc->size.avail) < 0) return -1; + return 0; +} + +int32_t tEncodeSMonDiskInfo(SCoder *encoder, const SMonDiskInfo *pInfo) { + if (tEncodeI32(encoder, taosArrayGetSize(pInfo->datadirs)) < 0) return -1; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->datadirs); ++i) { + SMonDiskDesc *pDesc = taosArrayGet(pInfo->datadirs, i); + if (tEncodeSMonDiskDesc(encoder, pDesc) < 0) return -1; + } + return 0; +} + +static int32_t tDecodeSMonDiskInfo(SCoder *decoder, SMonDiskInfo *pInfo) { + int32_t arraySize = 0; + if (tDecodeI32(decoder, &arraySize) < 0) return -1; + + pInfo->datadirs = taosArrayInit(arraySize, sizeof(SMonDiskDesc)); + if (pInfo->datadirs != NULL) return -1; + + for (int32_t i = 0; i < arraySize; ++i) { + SMonDiskDesc desc = {0}; + if (tDecodeSMonDiskDesc(decoder, &desc) < 0) return -1; + taosArrayPush(pInfo->datadirs, &desc); + } + + return 0; +} + +int32_t tEncodeSVnodesStat(SCoder *encoder, const SVnodesStat *pStat) { + if (tEncodeI32(encoder, pStat->openVnodes) < 0) return -1; + if (tEncodeI32(encoder, pStat->totalVnodes) < 0) return -1; + if (tEncodeI32(encoder, pStat->masterNum) < 0) return -1; + if (tEncodeI64(encoder, pStat->numOfSelectReqs) < 0) return -1; + if (tEncodeI64(encoder, pStat->numOfInsertReqs) < 0) return -1; + if (tEncodeI64(encoder, pStat->numOfInsertSuccessReqs) < 0) return -1; + if (tEncodeI64(encoder, pStat->numOfBatchInsertReqs) < 0) return -1; + if (tEncodeI64(encoder, pStat->numOfBatchInsertSuccessReqs) < 0) return -1; + if (tEncodeI64(encoder, pStat->errors) < 0) return -1; + return 0; +} + +static int32_t tDecodeSVnodesStat(SCoder *decoder, SVnodesStat *pStat) { + if (tDecodeI32(decoder, &pStat->openVnodes) < 0) return -1; + if (tDecodeI32(decoder, &pStat->totalVnodes) < 0) return -1; + if (tDecodeI32(decoder, &pStat->masterNum) < 0) return -1; + if (tDecodeI64(decoder, &pStat->numOfSelectReqs) < 0) return -1; + if (tDecodeI64(decoder, &pStat->numOfInsertReqs) < 0) return -1; + if (tDecodeI64(decoder, &pStat->numOfInsertSuccessReqs) < 0) return -1; + if (tDecodeI64(decoder, &pStat->numOfBatchInsertReqs) < 0) return -1; + if (tDecodeI64(decoder, &pStat->numOfBatchInsertSuccessReqs) < 0) return -1; + if (tDecodeI64(decoder, &pStat->errors) < 0) return -1; + return 0; +} + +int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSMonDiskInfo(&encoder, &pInfo->tfs) < 0) return -1; + if (tEncodeSVnodesStat(&encoder, &pInfo->vstat) < 0) return -1; + if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1; + if (tEncodeSMonLogs(&encoder, &pInfo->logs) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSMonDiskInfo(&decoder, &pInfo->tfs) < 0) return -1; + if (tDecodeSVnodesStat(&decoder, &pInfo->vstat) < 0) return -1; + if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1; + if (tDecodeSMonLogs(&decoder, &pInfo->logs) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonVmInfo(SMonVmInfo *pInfo) { taosArrayDestroy(pInfo->logs.logs); pInfo->logs.logs = NULL; } -int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo); -int32_t tDeserializeSMonQMmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo); -void tFreeSMonQmInfo(SMonQmInfo *pInfo) { +int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1; + if (tEncodeSMonLogs(&encoder, &pInfo->logs) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1; + if (tDecodeSMonLogs(&decoder, &pInfo->logs) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonQmInfo(SMonQmInfo *pInfo) { taosArrayDestroy(pInfo->logs.logs); pInfo->logs.logs = NULL; } -int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo); -int32_t tDeserializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo); -void tFreeSMonSmInfo(SMonSmInfo *pInfo) { +int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1; + if (tEncodeSMonLogs(&encoder, &pInfo->logs) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1; + if (tDecodeSMonLogs(&decoder, &pInfo->logs) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonSmInfo(SMonSmInfo *pInfo) { taosArrayDestroy(pInfo->logs.logs); pInfo->logs.logs = NULL; } -int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo); -int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo); -void tFreeSMonBmInfo(SMonBmInfo *pInfo) { +int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1; + if (tEncodeSMonLogs(&encoder, &pInfo->logs) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1; + if (tDecodeSMonLogs(&decoder, &pInfo->logs) < 0) return -1; + tEndDecode(&decoder); + + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonBmInfo(SMonBmInfo *pInfo) { taosArrayDestroy(pInfo->logs.logs); pInfo->logs.logs = NULL; +} + +int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, taosArrayGetSize(pInfo->pVloads)) < 0) return -1; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pVloads); ++i) { + SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i); + if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1; + if (tEncodeI8(&encoder, pLoad->role) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->totalStorage) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->compStorage) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->pointsWritten) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfSelectReqs) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfInsertReqs) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfInsertSuccessReqs) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfBatchInsertReqs) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->numOfBatchInsertSuccessReqs) < 0) return -1; + } + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + + if (tStartDecode(&decoder) < 0) return -1; + + int32_t arraySize = 0; + if (tDecodeI32(&decoder, &arraySize) < 0) return -1; + + pInfo->pVloads = taosArrayInit(arraySize, sizeof(SVnodeLoad)); + if (pInfo->pVloads != NULL) return -1; + + for (int32_t i = 0; i < arraySize; ++i) { + SVnodeLoad load = {0}; + if (tDecodeI32(&decoder, &load.vgId) < 0) return -1; + if (tDecodeI8(&decoder, &load.role) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1; + if (tDecodeI64(&decoder, &load.totalStorage) < 0) return -1; + if (tDecodeI64(&decoder, &load.compStorage) < 0) return -1; + if (tDecodeI64(&decoder, &load.pointsWritten) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfSelectReqs) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfInsertReqs) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfInsertSuccessReqs) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfBatchInsertReqs) < 0) return -1; + if (tDecodeI64(&decoder, &load.numOfBatchInsertSuccessReqs) < 0) return -1; + taosArrayPush(pInfo->pVloads, &load); + } + + tEndDecode(&decoder); + tCoderClear(&decoder); + return 0; +} + +void tFreeSMonVloadInfo(SMonVloadInfo *pInfo) { + taosArrayDestroy(pInfo->pVloads); + pInfo->pVloads = NULL; } \ No newline at end of file