Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bdafe0ef
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
bdafe0ef
编写于
9月 23, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6452]<feature>: taoskeeper metrics collector phase 1 taosd implementation
上级
52cb5b44
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
1 deletion
+48
-1
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+48
-1
未找到文件。
src/plugins/monitor/src/monMain.c
浏览文件 @
bdafe0ef
...
...
@@ -54,6 +54,7 @@ typedef enum {
MON_CMD_CREATE_MT_DNODES
,
MON_CMD_CREATE_TB_DNODE
,
MON_CMD_CREATE_MT_DISKS
,
MON_CMD_CREATE_TB_DISKS
,
MON_CMD_CREATE_MT_VGROUPS
,
MON_CMD_CREATE_MT_LOGS
,
MON_CMD_CREATE_TB_DNODE_LOG
,
...
...
@@ -195,11 +196,12 @@ static void *monThreadFunc(void *param) {
monSaveSystemInfo
();
monSaveDnodesInfo
();
if
(
monHasMnodeMaster
)
{
//
taosd only has
mnode master will write cluster info
//
only
mnode master will write cluster info
monSaveClusterInfo
();
}
monSaveVgroupsInfo
();
monSaveSlowQueryInfo
();
monSaveDisksInfo
();
}
}
}
...
...
@@ -305,6 +307,9 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
", datadir_l2_used float, datadir_l2_total float"
") tags (dnode_id int, dnode_ep binary(%d))"
,
tsMonitorDbName
,
TSDB_EP_LEN
);
}
else
if
(
cmd
==
MON_CMD_CREATE_TB_DISKS
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.disks_%d using %s.disks_info tags(%d, '%s')"
,
tsMonitorDbName
,
dnodeGetDnodeId
(),
tsMonitorDbName
,
dnodeGetDnodeId
(),
tsLocalEp
);
}
else
if
(
cmd
==
MON_CMD_CREATE_MT_VGROUPS
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.vgroups_info(ts timestamp"
...
...
@@ -762,6 +767,27 @@ static int32_t monBuildDnodeDiskSql(char *sql) {
return
sprintf
(
sql
,
", %f, %f, %f"
,
taosdDataDirGB
,
tsUsedDataDirGB
,
tsTotalDataDirGB
);
}
static
int32_t
monBuildDiskTierSql
(
char
*
sql
)
{
const
int8_t
numTiers
=
3
;
SFSMeta
fsMeta
;
STierMeta
*
tierMetas
=
calloc
(
numTiers
,
sizeof
(
STierMeta
));
tfsUpdateInfo
(
&
fsMeta
,
tierMetas
,
numTiers
);
int32_t
pos
=
0
;
for
(
int
i
=
0
;
i
<
numTiers
;
++
i
)
{
pos
+=
sprintf
(
sql
+
pos
,
", datadir_l%d_used %f, %f, %f"
,
taosdDataDirGB
,
tsUsedDataDirGB
,
tsTotalDataDirGB
);
char
*
keyDataDirLevelUsed
=
"datadir_used"
;
char
*
keyDataDirLevelTotal
=
"datadir_total"
;
httpJsonPairInt64Val
(
jsonBuf
,
keyDataDirLevelUsed
,
(
int32_t
)
strlen
(
keyDataDirLevelUsed
),
tierMetas
[
i
].
used
);
httpJsonPairInt64Val
(
jsonBuf
,
keyDataDirLevelTotal
,
(
int32_t
)
strlen
(
keyDataDirLevelTotal
),
tierMetas
[
i
].
size
);
}
free
(
tierMetas
);
return
sprintf
(
sql
,
", %f, %f, %f"
,
taosdDataDirGB
,
tsUsedDataDirGB
,
tsTotalDataDirGB
);
}
static
void
monSaveClusterInfo
()
{
int64_t
ts
=
taosGetTimestampUs
();
char
*
sql
=
tsMonitor
.
sql
;
...
...
@@ -981,6 +1007,27 @@ static void monSaveSlowQueryInfo() {
}
static
void
monSaveDisksInfo
()
{
int64_t
ts
=
taosGetTimestampUs
();
char
*
sql
=
tsMonitor
.
sql
;
int32_t
pos
=
snprintf
(
sql
,
SQL_LENGTH
,
"insert into %s.disks_%d values(%"
PRId64
,
tsMonitorDbName
,
dnodeGetDnodeId
(),
ts
);
monBuildDiskTierSql
(
sql
+
pos
);
monError
(
"sql:%s"
,
sql
);
void
*
res
=
taos_query
(
tsMonitor
.
conn
,
tsMonitor
.
sql
);
int32_t
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
monError
(
"failed to save disks_%d info, reason:%s, sql:%s"
,
dnodeGetDnodeId
(),
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save disks_%d info, sql:%s"
,
dnodeGetDnodeId
(),
tsMonitor
.
sql
);
}
}
static
void
monExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
int32_t
c
=
taos_errno
(
result
);
if
(
c
!=
TSDB_CODE_SUCCESS
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录