Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7986a372
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看板
提交
7986a372
编写于
3月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
monitor
上级
5dc2cfff
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
183 addition
and
8 deletion
+183
-8
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+5
-4
source/dnode/mgmt/impl/inc/dndEnv.h
source/dnode/mgmt/impl/inc/dndEnv.h
+3
-0
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+2
-0
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+17
-3
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+156
-1
未找到文件。
include/libs/monitor/monitor.h
浏览文件 @
7986a372
...
...
@@ -57,7 +57,6 @@ typedef struct {
typedef
struct
{
int32_t
dnode_id
;
int8_t
vnode_online
;
char
vnode_role
[
8
];
}
SMonVnodeDesc
;
...
...
@@ -69,7 +68,7 @@ typedef struct {
typedef
struct
{
char
database_name
[
TSDB_DB_NAME_LEN
];
int32_t
tables_num
;
int8_t
status
;
char
status
[
10
]
;
SArray
*
vgroups
;
// array of SMonVgroupDesc
}
SMonVgroupInfo
;
...
...
@@ -107,7 +106,7 @@ typedef struct {
int32_t
errors
;
int32_t
vnodes_num
;
int32_t
masters
;
int
32_t
has_mnode
;
int
8_t
has_mnode
;
}
SMonDnodeInfo
;
typedef
struct
{
...
...
@@ -117,7 +116,9 @@ typedef struct {
}
SMonDiskDesc
;
typedef
struct
{
SArray
*
disks
;
// array of SMonDiskDesc
SArray
*
datadirs
;
// array of SMonDiskDesc
SMonDiskDesc
logdir
;
SMonDiskDesc
tempdir
;
}
SMonDiskInfo
;
typedef
struct
{
...
...
source/dnode/mgmt/impl/inc/dndEnv.h
浏览文件 @
7986a372
...
...
@@ -137,6 +137,9 @@ typedef struct SDnode {
SStartupReq
startup
;
}
SDnode
;
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
7986a372
...
...
@@ -323,3 +323,5 @@ void dndCleanup() {
taosStopCacheRefreshWorker
();
dInfo
(
"dnode env is cleaned up"
);
}
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
return
0
;
}
\ No newline at end of file
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
7986a372
...
...
@@ -474,11 +474,14 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse
(
&
rpcRsp
);
}
void
dndGetBasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
static
int32_t
dndGetBasicInfo
(
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
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
)
return
;
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
...
...
@@ -487,8 +490,9 @@ static void dndSendMonitorReport(SDnode *pDnode) {
dTrace
(
"pDnode:%p, send monitor report to %s:%u"
,
pDnode
,
tsMonitorFqdn
,
tsMonitorPort
);
SMonBasicInfo
basicInfo
=
{
0
};
dndGetBasicInfo
(
pDnode
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
if
(
dndGetBasicInfo
(
pDnode
,
&
basicInfo
)
==
0
)
{
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
}
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
...
...
@@ -499,6 +503,16 @@ static void dndSendMonitorReport(SDnode *pDnode) {
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
}
SMonDnodeInfo
dnodeInfo
=
{
0
};
if
(
dndGetDnodeInfo
(
pDnode
,
&
dnodeInfo
)
==
0
)
{
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
}
SMonDiskInfo
diskInfo
=
{
0
};
if
(
dndGetDiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
}
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
}
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
7986a372
...
...
@@ -97,21 +97,176 @@ void monSetBasicInfo(SMonInfo *pMonitor, SMonBasicInfo *pInfo) {
}
void
monSetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
)
{
SJson
*
pParentJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pParentJson
,
"cluster_info"
,
pJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pJson
,
"first_ep"
,
pInfo
->
first_ep
);
tjsonAddDoubleToObject
(
pJson
,
"first_ep_dnode_id"
,
pInfo
->
first_ep_dnode_id
);
tjsonAddStringToObject
(
pJson
,
"version"
,
pInfo
->
version
);
tjsonAddDoubleToObject
(
pJson
,
"master_uptime"
,
pInfo
->
master_uptime
);
tjsonAddDoubleToObject
(
pJson
,
"monitor_interval"
,
pInfo
->
monitor_interval
);
tjsonAddDoubleToObject
(
pJson
,
"vgroups_total"
,
pInfo
->
vgroups_total
);
tjsonAddDoubleToObject
(
pJson
,
"vgroups_alive"
,
pInfo
->
vgroups_alive
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_total"
,
pInfo
->
vnodes_total
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_alive"
,
pInfo
->
vnodes_alive
);
tjsonAddDoubleToObject
(
pJson
,
"connections_total"
,
pInfo
->
connections_total
);
SJson
*
pDnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"dnodes"
);
if
(
pDnodesJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
dnodes
);
++
i
)
{
SJson
*
pDnodeJson
=
tjsonCreateObject
();
if
(
pDnodeJson
==
NULL
)
continue
;
SMonDnodeDesc
*
pDnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
if
(
tjsonAddDoubleToObject
(
pDnodesJson
,
"dnode_id"
,
pDnodeDesc
->
dnode_id
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
if
(
tjsonAddStringToObject
(
pDnodesJson
,
"dnode_ep"
,
pDnodeDesc
->
dnode_ep
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
if
(
tjsonAddStringToObject
(
pDnodesJson
,
"status"
,
pDnodeDesc
->
status
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
if
(
tjsonAddItemToArray
(
pDnodesJson
,
pDnodeJson
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
}
SJson
*
pMnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"mnodes"
);
if
(
pMnodesJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
dnodes
);
++
i
)
{
SJson
*
pMnodeJson
=
tjsonCreateObject
();
if
(
pMnodeJson
==
NULL
)
continue
;
SMonMnodeDesc
*
pMnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
if
(
tjsonAddDoubleToObject
(
pMnodesJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
if
(
tjsonAddStringToObject
(
pMnodesJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
if
(
tjsonAddStringToObject
(
pMnodesJson
,
"role"
,
pMnodeDesc
->
role
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
if
(
tjsonAddItemToArray
(
pMnodesJson
,
pMnodeJson
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
}
}
void
monSetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
SJson
*
pParentJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pParentJson
,
"vgroups_info"
,
pJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pJson
,
"database_name"
,
pInfo
->
database_name
);
tjsonAddDoubleToObject
(
pJson
,
"tables_num"
,
pInfo
->
tables_num
);
tjsonAddStringToObject
(
pJson
,
"status"
,
pInfo
->
status
);
SJson
*
pVgroupsJson
=
tjsonAddArrayToObject
(
pJson
,
"vgroups"
);
if
(
pVgroupsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
vgroups
);
++
i
)
{
SJson
*
pVgroupJson
=
tjsonCreateObject
();
if
(
pVgroupJson
==
NULL
)
continue
;
SMonVgroupDesc
*
pVgroupDesc
=
taosArrayGet
(
pInfo
->
vgroups
,
i
);
if
(
tjsonAddDoubleToObject
(
pVgroupJson
,
"vgroup_id"
,
pVgroupDesc
->
vgroup_id
)
!=
0
)
tjsonDelete
(
pVgroupJson
);
SJson
*
pVnodesJson
=
tjsonAddArrayToObject
(
pVgroupJson
,
"vnodes"
);
if
(
pVnodesJson
==
NULL
)
tjsonDelete
(
pVgroupJson
);
for
(
int32_t
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
SMonVnodeDesc
*
pVnodeDesc
=
&
pVgroupDesc
->
vnodes
[
j
];
if
(
pVnodeDesc
[
j
].
dnode_id
<=
0
)
continue
;
SJson
*
pVnodeJson
=
tjsonCreateObject
();
if
(
pVnodeJson
==
NULL
)
continue
;
if
(
tjsonAddDoubleToObject
(
pVnodeJson
,
"dnode_id"
,
pVnodeDesc
->
dnode_id
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
if
(
tjsonAddStringToObject
(
pVnodeJson
,
"vnode_role"
,
pVnodeDesc
->
vnode_role
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
if
(
tjsonAddItemToArray
(
pVnodesJson
,
pVnodeJson
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
}
}
}
void
monSetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
)
{
SJson
*
pParentJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pParentJson
,
"grant_info"
,
pJson
)
!=
0
)
return
;
tjsonAddDoubleToObject
(
pJson
,
"expire_time"
,
pInfo
->
expire_time
);
tjsonAddDoubleToObject
(
pJson
,
"timeseries_used"
,
pInfo
->
timeseries_used
);
tjsonAddDoubleToObject
(
pJson
,
"timeseries_total"
,
pInfo
->
timeseries_total
);
}
void
monSetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
)
{
SJson
*
pParentJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pParentJson
,
"dnode_info"
,
pJson
)
!=
0
)
return
;
tjsonAddDoubleToObject
(
pJson
,
"uptime"
,
pInfo
->
uptime
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_engine"
,
pInfo
->
cpu_engine
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_system"
,
pInfo
->
cpu_system
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_cores"
,
pInfo
->
cpu_cores
);
tjsonAddDoubleToObject
(
pJson
,
"mem_engine"
,
pInfo
->
mem_engine
);
tjsonAddDoubleToObject
(
pJson
,
"mem_system"
,
pInfo
->
mem_system
);
tjsonAddDoubleToObject
(
pJson
,
"mem_total"
,
pInfo
->
mem_total
);
tjsonAddDoubleToObject
(
pJson
,
"disk_engine"
,
pInfo
->
disk_engine
);
tjsonAddDoubleToObject
(
pJson
,
"disk_used"
,
pInfo
->
disk_used
);
tjsonAddDoubleToObject
(
pJson
,
"disk_total"
,
pInfo
->
disk_total
);
tjsonAddDoubleToObject
(
pJson
,
"net_in"
,
pInfo
->
net_in
);
tjsonAddDoubleToObject
(
pJson
,
"net_out"
,
pInfo
->
net_out
);
tjsonAddDoubleToObject
(
pJson
,
"io_read"
,
pInfo
->
io_read
);
tjsonAddDoubleToObject
(
pJson
,
"io_write"
,
pInfo
->
io_write
);
tjsonAddDoubleToObject
(
pJson
,
"io_read_disk"
,
pInfo
->
io_read_disk
);
tjsonAddDoubleToObject
(
pJson
,
"io_write_disk"
,
pInfo
->
io_write_disk
);
tjsonAddDoubleToObject
(
pJson
,
"req_select"
,
pInfo
->
req_select
);
tjsonAddDoubleToObject
(
pJson
,
"req_select_rate"
,
pInfo
->
req_select_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert"
,
pInfo
->
req_insert
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_success"
,
pInfo
->
req_insert_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_rate"
,
pInfo
->
req_insert_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch"
,
pInfo
->
req_insert_batch
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_success"
,
pInfo
->
req_insert_batch_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_rate"
,
pInfo
->
req_insert_batch_rate
);
tjsonAddDoubleToObject
(
pJson
,
"errors"
,
pInfo
->
errors
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_num"
,
pInfo
->
vnodes_num
);
tjsonAddDoubleToObject
(
pJson
,
"masters"
,
pInfo
->
masters
);
tjsonAddDoubleToObject
(
pJson
,
"has_mnode"
,
pInfo
->
has_mnode
);
}
void
monSetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
SJson
*
pParentJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pParentJson
,
"disks_info"
,
pJson
)
!=
0
)
return
;
SJson
*
pDatadirsJson
=
tjsonAddArrayToObject
(
pJson
,
"datadirs"
);
if
(
pDatadirsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
datadirs
);
++
i
)
{
SJson
*
pDatadirJson
=
tjsonCreateObject
();
if
(
pDatadirJson
==
NULL
)
continue
;
SMonDiskDesc
*
pDatadirDesc
=
taosArrayGet
(
pInfo
->
datadirs
,
i
);
if
(
tjsonAddStringToObject
(
pDatadirJson
,
"name"
,
pDatadirDesc
->
name
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"level"
,
pDatadirDesc
->
level
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"avail"
,
pDatadirDesc
->
size
.
avail
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"used"
,
pDatadirDesc
->
size
.
used
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"total"
,
pDatadirDesc
->
size
.
total
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddItemToArray
(
pDatadirsJson
,
pDatadirJson
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
}
SJson
*
pLogdirJson
=
tjsonCreateObject
();
if
(
pLogdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"logdir"
,
pLogdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pLogdirJson
,
"name"
,
pInfo
->
logdir
.
name
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"level"
,
pInfo
->
logdir
.
level
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"avail"
,
pInfo
->
logdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"used"
,
pInfo
->
logdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"total"
,
pInfo
->
logdir
.
size
.
total
);
SJson
*
pTempdirJson
=
tjsonCreateObject
();
if
(
pTempdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"tempdir"
,
pTempdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pTempdirJson
,
"name"
,
pInfo
->
tempdir
.
name
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"level"
,
pInfo
->
tempdir
.
level
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"avail"
,
pInfo
->
tempdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"used"
,
pInfo
->
tempdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录