Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1fe0c21f
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1fe0c21f
编写于
3月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
monitor
上级
7986a372
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
27 deletion
+97
-27
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+3
-3
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+94
-24
未找到文件。
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
1fe0c21f
...
...
@@ -483,12 +483,12 @@ static int32_t dndGetBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
static
int32_t
dndGetDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
return
0
;
}
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
)
return
;
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
dTrace
(
"pDnode:%p, send monitor report to %s:%u"
,
pDnode
,
tsMonitorFqdn
,
tsMonitorPort
);
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
dTrace
(
"pDnode:%p, send monitor report to %s:%u"
,
pDnode
,
tsMonitorFqdn
,
tsMonitorPort
);
SMonBasicInfo
basicInfo
=
{
0
};
if
(
dndGetBasicInfo
(
pDnode
,
&
basicInfo
)
==
0
)
{
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
1fe0c21f
...
...
@@ -54,7 +54,10 @@ void monAddLogItem(SMonLogItem *pItem) {
SMonInfo
*
monCreateMonitorInfo
()
{
SMonInfo
*
pMonitor
=
calloc
(
1
,
sizeof
(
SMonInfo
));
if
(
pMonitor
==
NULL
)
return
NULL
;
if
(
pMonitor
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
taosWLockLatch
(
&
tsMonitor
.
lock
);
pMonitor
->
logs
=
taosArrayDup
(
tsMonitor
.
logs
);
...
...
@@ -77,30 +80,24 @@ void monCleanupMonitorInfo(SMonInfo *pMonitor) {
free
(
pMonitor
);
}
void
monSendReport
(
SMonInfo
*
pMonitor
)
{
char
*
pCont
=
tjsonToString
(
pMonitor
->
pJson
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
));
free
(
pCont
);
}
}
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
SJson
*
pJson
=
pMonitor
->
pJson
;
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
tjsonAddStringToObject
(
pJson
,
"dnode_ep"
,
pInfo
->
dnode_ep
);
SJson
*
pJson
=
pMonitor
->
pJson
;
int64_t
ms
=
taosGetTimestampMs
();
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
ms
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pJson
,
"ts"
,
buf
);
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
tjsonAddStringToObject
(
pJson
,
"dnode_ep"
,
pInfo
->
dnode_ep
);
}
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
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"cluster_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddStringToObject
(
pJson
,
"first_ep"
,
pInfo
->
first_ep
);
tjsonAddDoubleToObject
(
pJson
,
"first_ep_dnode_id"
,
pInfo
->
first_ep_dnode_id
);
...
...
@@ -145,10 +142,12 @@ void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
}
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
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"vgroup_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddStringToObject
(
pJson
,
"database_name"
,
pInfo
->
database_name
);
tjsonAddDoubleToObject
(
pJson
,
"tables_num"
,
pInfo
->
tables_num
);
...
...
@@ -183,10 +182,12 @@ void monSetVgroupInfo(SMonInfo *pMonitor, SMonVgroupInfo *pInfo) {
}
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
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"grant_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddDoubleToObject
(
pJson
,
"expire_time"
,
pInfo
->
expire_time
);
tjsonAddDoubleToObject
(
pJson
,
"timeseries_used"
,
pInfo
->
timeseries_used
);
...
...
@@ -194,10 +195,12 @@ void monSetGrantInfo(SMonInfo *pMonitor, SMonGrantInfo *pInfo) {
}
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
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"dnode_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddDoubleToObject
(
pJson
,
"uptime"
,
pInfo
->
uptime
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_engine"
,
pInfo
->
cpu_engine
);
...
...
@@ -230,12 +233,14 @@ void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
}
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
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"disks_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
SJson
*
pDatadirsJson
=
tjsonAddArrayToObject
(
pJson
,
"datadir
s
"
);
SJson
*
pDatadirsJson
=
tjsonAddArrayToObject
(
pJson
,
"datadir"
);
if
(
pDatadirsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
datadirs
);
++
i
)
{
...
...
@@ -270,3 +275,68 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
tjsonAddDoubleToObject
(
pTempdirJson
,
"used"
,
pInfo
->
tempdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
}
static
void
monSetLogInfo
(
SMonInfo
*
pMonitor
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"log_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
SJson
*
pLogsJson
=
tjsonAddArrayToObject
(
pJson
,
"logs"
);
if
(
pLogsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pMonitor
->
logs
);
++
i
)
{
SJson
*
pLogJson
=
tjsonCreateObject
();
if
(
pLogJson
==
NULL
)
continue
;
SMonLogItem
*
pLogItem
=
taosArrayGet
(
pMonitor
->
logs
,
i
);
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
if
(
tjsonAddStringToObject
(
pLogItem
,
"ts"
,
buf
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddDoubleToObject
(
pLogItem
,
"level"
,
pLogItem
->
level
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddStringToObject
(
pLogItem
,
"content"
,
pLogItem
->
content
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
}
SJson
*
pSummaryJson
=
tjsonAddArrayToObject
(
pJson
,
"summary"
);
if
(
pSummaryJson
==
NULL
)
return
;
SJson
*
pLogError
=
tjsonCreateObject
();
if
(
pLogError
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogError
,
"level"
,
"error"
);
tjsonAddDoubleToObject
(
pLogError
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogError
)
!=
0
)
tjsonDelete
(
pLogError
);
SJson
*
pLogInfo
=
tjsonCreateObject
();
if
(
pLogInfo
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogInfo
,
"level"
,
"info"
);
tjsonAddDoubleToObject
(
pLogInfo
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogInfo
)
!=
0
)
tjsonDelete
(
pLogInfo
);
SJson
*
pLogDebug
=
tjsonCreateObject
();
if
(
pLogDebug
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogDebug
,
"level"
,
"debug"
);
tjsonAddDoubleToObject
(
pLogDebug
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogDebug
)
!=
0
)
tjsonDelete
(
pLogDebug
);
SJson
*
pLogTrace
=
tjsonCreateObject
();
if
(
pLogTrace
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogTrace
,
"level"
,
"trace"
);
tjsonAddDoubleToObject
(
pLogTrace
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogTrace
)
!=
0
)
tjsonDelete
(
pLogTrace
);
}
void
monSendReport
(
SMonInfo
*
pMonitor
)
{
monSetLogInfo
(
pMonitor
);
char
*
pCont
=
tjsonToString
(
pMonitor
->
pJson
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
));
free
(
pCont
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录