diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h index b6d10c81bffb230c5e8408d4773cd8ceccf25baa..1b41da33bbbcfa60567837c9a886533b42062b54 100644 --- a/include/libs/tfs/tfs.h +++ b/include/libs/tfs/tfs.h @@ -17,6 +17,7 @@ #define _TD_TFS_H_ #include "tdef.h" +#include "monitor.h" #ifdef __cplusplus extern "C" { @@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir); */ void tfsClosedir(STfsDir *pDir); +/** + * @brief Get disk info of tfs. + * + * @param pTfs The fs object. + * @param pInfo The info object. + */ +int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/impl/inc/dndEnv.h b/source/dnode/mgmt/impl/inc/dndEnv.h index 724ba3015586271a2ed74f5196a36da74d0c70dd..efe54ee1e592a0d4f7d582088b4b4a08086ff96d 100644 --- a/source/dnode/mgmt/impl/inc/dndEnv.h +++ b/source/dnode/mgmt/impl/inc/dndEnv.h @@ -31,7 +31,7 @@ typedef struct { SDnode *pDnode; STaosQueue *queue; union { - SQWorkerPool pool; + SQWorkerPool pool; SWWorkerPool mpool; }; } SDnodeWorker; @@ -137,8 +137,7 @@ typedef struct SDnode { SStartupReq startup; } SDnode; - -int32_t dndGetDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo); +int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index ae08d6387c1b2872b47d2296f6986dc46f7b97f5..1cbdf0c1dc8d58dd89983e45a2fccd2c0f839a76 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -324,4 +324,11 @@ void dndCleanup() { dInfo("dnode env is cleaned up"); } -int32_t dndGetDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) { return 0; } \ No newline at end of file +int32_t dndGetMonitorDiskInfo(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; + + return tfsGetMonitorInfo(pDnode->pTfs, pInfo); +} \ No newline at end of file diff --git a/source/dnode/mgmt/impl/src/dndMgmt.c b/source/dnode/mgmt/impl/src/dndMgmt.c index 268ed7e3624e59fe5b514e7b86b0f815fd42b06b..70f5060eadf4a9c84bab3562c231dc8f35d0a567 100644 --- a/source/dnode/mgmt/impl/src/dndMgmt.c +++ b/source/dnode/mgmt/impl/src/dndMgmt.c @@ -474,13 +474,13 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { rpcSendResponse(&rpcRsp); } -static int32_t dndGetBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { +static int32_t dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { pInfo->dnode_id = dndGetDnodeId(pDnode); tstrncpy(pInfo->dnode_ep, tsLocalEp, TSDB_EP_LEN); return 0; } -static int32_t dndGetDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { return 0; } +static int32_t dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { return 0; } static void dndSendMonitorReport(SDnode *pDnode) { if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; @@ -490,7 +490,7 @@ static void dndSendMonitorReport(SDnode *pDnode) { if (pMonitor == NULL) return; SMonBasicInfo basicInfo = {0}; - if (dndGetBasicInfo(pDnode, &basicInfo) == 0) { + if (dndGetMonitorBasicInfo(pDnode, &basicInfo) == 0) { monSetBasicInfo(pMonitor, &basicInfo); } @@ -504,15 +504,20 @@ static void dndSendMonitorReport(SDnode *pDnode) { } SMonDnodeInfo dnodeInfo = {0}; - if (dndGetDnodeInfo(pDnode, &dnodeInfo) == 0) { + if (dndGetMonitorDnodeInfo(pDnode, &dnodeInfo) == 0) { monSetDnodeInfo(pMonitor, &dnodeInfo); } SMonDiskInfo diskInfo = {0}; - if (dndGetDiskInfo(pDnode, &diskInfo) == 0) { + if (dndGetMonitorDiskInfo(pDnode, &diskInfo) == 0) { monSetDiskInfo(pMonitor, &diskInfo); } + taosArrayDestroy(clusterInfo.dnodes); + taosArrayDestroy(clusterInfo.mnodes); + taosArrayDestroy(vgroupInfo.vgroups); + taosArrayDestroy(diskInfo.datadirs); + monSendReport(pMonitor); monCleanupMonitorInfo(pMonitor); } diff --git a/source/libs/tfs/CMakeLists.txt b/source/libs/tfs/CMakeLists.txt index 607ccd4c48419fbd57133bf350c003fc240d7578..97e02fc8a9e2ae53aa3fb3bfd48f9a7789ba8dec 100644 --- a/source/libs/tfs/CMakeLists.txt +++ b/source/libs/tfs/CMakeLists.txt @@ -6,7 +6,7 @@ target_include_directories( PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) -target_link_libraries(tfs os util common) +target_link_libraries(tfs os util common monitor) if(${BUILD_TEST}) add_subdirectory(test) diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index f686703643d4ba0aa420b3d6ff7284c352c32970..944e67c8633f16a96af4ebe6986878c0ca5478b8 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -544,3 +544,24 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) { return pDisk; } + +int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) { + pInfo->datadirs = taosArrayInit(32, sizeof(SMonDiskDesc)); + if (pInfo->datadirs == NULL) return -1; + + tfsUpdateSize(pTfs); + + tfsLock(pTfs); + for (int32_t level = 0; level < pTfs->nlevel; level++) { + STfsTier *pTier = &pTfs->tiers[level]; + for (int32_t disk = 0; disk < pTier->ndisk; ++disk) { + STfsDisk *pDisk = pTier->disks[disk]; + SMonDiskDesc dinfo = {0}; + dinfo.size = pDisk->size; + dinfo.level = pDisk->level; + tstrncpy(dinfo.name, pDisk->path, sizeof(dinfo.name)); + taosArrayPush(pInfo->datadirs, &dinfo); + } + } + tfsUnLock(pTfs); +} \ No newline at end of file