Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9f0d89d6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9f0d89d6
编写于
6月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add stbinfo to minotor
上级
44a3faaf
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
93 addition
and
4 deletion
+93
-4
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+3
-1
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+10
-0
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-1
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+25
-2
source/libs/monitor/src/monMain.c
source/libs/monitor/src/monMain.c
+22
-0
source/libs/monitor/src/monMsg.c
source/libs/monitor/src/monMsg.c
+30
-0
tests/script/tmp/monitor.sim
tests/script/tmp/monitor.sim
+2
-0
未找到文件。
include/dnode/mnode/mnode.h
浏览文件 @
9f0d89d6
...
...
@@ -73,10 +73,12 @@ void mndStop(SMnode *pMnode);
* @param pMnode The mnode object.
* @param pCluster
* @param pVgroup
* @param pStbInfo
* @param pGrant
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pCluster
,
SMonVgroupInfo
*
pVgroup
,
SMonGrantInfo
*
pGrant
);
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonStbInfo
*
pStbInfo
,
SMonGrantInfo
*
pGrantInfo
);
/**
* @brief Get mnode loads for status msg.
...
...
include/libs/monitor/monitor.h
浏览文件 @
9f0d89d6
...
...
@@ -138,6 +138,15 @@ typedef struct {
SArray
*
vgroups
;
// array of SMonVgroupDesc
}
SMonVgroupInfo
;
typedef
struct
{
char
stb_name
[
TSDB_TABLE_NAME_LEN
];
char
database_name
[
TSDB_DB_NAME_LEN
];
}
SMonStbDesc
;
typedef
struct
{
SArray
*
stbs
;
// array of SMonStbDesc
}
SMonStbInfo
;
typedef
struct
{
int32_t
expire_time
;
int64_t
timeseries_used
;
...
...
@@ -147,6 +156,7 @@ typedef struct {
typedef
struct
{
SMonClusterInfo
cluster
;
SMonVgroupInfo
vgroup
;
SMonStbInfo
stb
;
SMonGrantInfo
grant
;
SMonSysInfo
sys
;
SMonLogs
log
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
9f0d89d6
...
...
@@ -17,7 +17,7 @@
#include "mmInt.h"
void
mmGetMonitorInfo
(
SMnodeMgmt
*
pMgmt
,
SMonMmInfo
*
pInfo
)
{
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
grant
);
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
stb
,
&
pInfo
->
grant
);
}
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
9f0d89d6
...
...
@@ -614,7 +614,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
SMon
StbInfo
*
pStbInfo
,
SMon
GrantInfo
*
pGrantInfo
)
{
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -623,7 +623,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
mnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_MNODE
),
sizeof
(
SMonMnodeDesc
));
pVgroupInfo
->
vgroups
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_VGROUP
),
sizeof
(
SMonVgroupDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
)
{
pStbInfo
->
stbs
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_STB
),
sizeof
(
SMonStbDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
||
pStbInfo
->
stbs
==
NULL
)
{
mndReleaseRpcRef
(
pMnode
);
return
-
1
;
}
...
...
@@ -714,6 +716,27 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
sdbRelease
(
pSdb
,
pVgroup
);
}
// stb info
pIter
=
NULL
;
while
(
1
)
{
SStbObj
*
pStb
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pIter
,
(
void
**
)
&
pStb
);
if
(
pIter
==
NULL
)
break
;
SMonStbDesc
desc
=
{
0
};
SName
name1
=
{
0
};
tNameFromString
(
&
name1
,
pStb
->
db
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameGetDbName
(
&
name1
,
desc
.
database_name
);
SName
name2
=
{
0
};
tNameFromString
(
&
name2
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tstrncpy
(
desc
.
stb_name
,
tNameGetTableName
(
&
name2
),
TSDB_TABLE_NAME_LEN
);
taosArrayPush
(
pStbInfo
->
stbs
,
&
desc
);
sdbRelease
(
pSdb
,
pStb
);
}
// grant info
pGrantInfo
->
expire_time
=
(
pMnode
->
grant
.
expireTimeMS
-
ms
)
/
86400000
.
0
f
;
pGrantInfo
->
timeseries_total
=
pMnode
->
grant
.
timeseriesAllowed
;
...
...
source/libs/monitor/src/monMain.c
浏览文件 @
9f0d89d6
...
...
@@ -280,6 +280,27 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
}
}
static
void
monGenStbJson
(
SMonInfo
*
pMonitor
)
{
SMonStbInfo
*
pInfo
=
&
pMonitor
->
mmInfo
.
stb
;
if
(
pMonitor
->
mmInfo
.
cluster
.
first_ep_dnode_id
==
0
)
return
;
SJson
*
pJson
=
tjsonAddArrayToObject
(
pMonitor
->
pJson
,
"stb_infos"
);
if
(
pJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
stbs
);
++
i
)
{
SJson
*
pStbJson
=
tjsonCreateObject
();
if
(
pStbJson
==
NULL
)
continue
;
if
(
tjsonAddItemToArray
(
pJson
,
pStbJson
)
!=
0
)
{
tjsonDelete
(
pStbJson
);
continue
;
}
SMonStbDesc
*
pStbDesc
=
taosArrayGet
(
pInfo
->
stbs
,
i
);
tjsonAddStringToObject
(
pStbJson
,
"stb_name"
,
pStbDesc
->
stb_name
);
tjsonAddStringToObject
(
pStbJson
,
"database_name"
,
pStbDesc
->
database_name
);
}
}
static
void
monGenGrantJson
(
SMonInfo
*
pMonitor
)
{
SMonGrantInfo
*
pInfo
=
&
pMonitor
->
mmInfo
.
grant
;
if
(
pMonitor
->
mmInfo
.
cluster
.
first_ep_dnode_id
==
0
)
return
;
...
...
@@ -527,6 +548,7 @@ void monSendReport() {
monGenBasicJson
(
pMonitor
);
monGenClusterJson
(
pMonitor
);
monGenVgroupJson
(
pMonitor
);
monGenStbJson
(
pMonitor
);
monGenGrantJson
(
pMonitor
);
monGenDnodeJson
(
pMonitor
);
monGenDiskJson
(
pMonitor
);
...
...
source/libs/monitor/src/monMsg.c
浏览文件 @
9f0d89d6
...
...
@@ -209,6 +209,32 @@ int32_t tDecodeSMonVgroupInfo(SDecoder *decoder, SMonVgroupInfo *pInfo) {
return
0
;
}
int32_t
tEncodeSMonStbInfo
(
SEncoder
*
encoder
,
const
SMonStbInfo
*
pInfo
)
{
if
(
tEncodeI32
(
encoder
,
taosArrayGetSize
(
pInfo
->
stbs
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
stbs
);
++
i
)
{
SMonStbDesc
*
pDesc
=
taosArrayGet
(
pInfo
->
stbs
,
i
);
if
(
tEncodeCStr
(
encoder
,
pDesc
->
stb_name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
encoder
,
pDesc
->
database_name
)
<
0
)
return
-
1
;
}
return
0
;
}
int32_t
tDecodeSMonStbInfo
(
SDecoder
*
decoder
,
SMonStbInfo
*
pInfo
)
{
int32_t
arraySize
=
0
;
if
(
tDecodeI32
(
decoder
,
&
arraySize
)
<
0
)
return
-
1
;
pInfo
->
stbs
=
taosArrayInit
(
arraySize
,
sizeof
(
SMonStbDesc
));
if
(
pInfo
->
stbs
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
arraySize
;
++
i
)
{
SMonStbDesc
desc
=
{
0
};
if
(
tDecodeCStrTo
(
decoder
,
desc
.
stb_name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
decoder
,
desc
.
database_name
)
<
0
)
return
-
1
;
taosArrayPush
(
pInfo
->
stbs
,
&
desc
);
}
return
0
;
}
int32_t
tEncodeSMonGrantInfo
(
SEncoder
*
encoder
,
const
SMonGrantInfo
*
pInfo
)
{
if
(
tEncodeI32
(
encoder
,
pInfo
->
expire_time
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
...
...
@@ -230,6 +256,7 @@ int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeSMonClusterInfo
(
&
encoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tEncodeSMonVgroupInfo
(
&
encoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tEncodeSMonStbInfo
(
&
encoder
,
&
pInfo
->
stb
)
<
0
)
return
-
1
;
if
(
tEncodeSMonGrantInfo
(
&
encoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tEncodeSMonSysInfo
(
&
encoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tEncodeSMonLogs
(
&
encoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
...
...
@@ -247,6 +274,7 @@ int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeSMonClusterInfo
(
&
decoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tDecodeSMonVgroupInfo
(
&
decoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tDecodeSMonStbInfo
(
&
decoder
,
&
pInfo
->
stb
)
<
0
)
return
-
1
;
if
(
tDecodeSMonGrantInfo
(
&
decoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tDecodeSMonSysInfo
(
&
decoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tDecodeSMonLogs
(
&
decoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
...
...
@@ -261,9 +289,11 @@ void tFreeSMonMmInfo(SMonMmInfo *pInfo) {
taosArrayDestroy
(
pInfo
->
cluster
.
mnodes
);
taosArrayDestroy
(
pInfo
->
cluster
.
dnodes
);
taosArrayDestroy
(
pInfo
->
vgroup
.
vgroups
);
taosArrayDestroy
(
pInfo
->
stb
.
stbs
);
pInfo
->
cluster
.
mnodes
=
NULL
;
pInfo
->
cluster
.
dnodes
=
NULL
;
pInfo
->
vgroup
.
vgroups
=
NULL
;
pInfo
->
stb
.
stbs
=
NULL
;
pInfo
->
log
.
logs
=
NULL
;
}
...
...
tests/script/tmp/monitor.sim
浏览文件 @
9f0d89d6
...
...
@@ -12,6 +12,8 @@ sql connect
print =============== show dnodes
sleep 2000
sql create database db vgroups 2;
sql use db;
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd";
sleep 2000
print =============== create drop qnode 1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录