Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
52cb5b44
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看板
提交
52cb5b44
编写于
9月 23, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6452]<feature>: taoskeeper metrics collector phase 1 taosd implementation
上级
e9291a00
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
5 deletion
+33
-5
src/inc/monitor.h
src/inc/monitor.h
+4
-0
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+29
-5
未找到文件。
src/inc/monitor.h
浏览文件 @
52cb5b44
...
...
@@ -62,6 +62,10 @@ void monSaveDnodeLog(int32_t level, const char *const format, ...);
void
monExecuteSQL
(
char
*
sql
);
typedef
void
(
*
MonExecuteSQLCbFP
)(
void
*
param
,
TAOS_RES
*
,
int
code
);
void
monExecuteSQLWithResultCallback
(
char
*
sql
,
MonExecuteSQLCbFP
callback
,
void
*
param
);
void
monIncQueryReqCnt
();
void
monIncSubmitReqCnt
();
int32_t
monFetchQueryReqCnt
();
int32_t
monFetchSubmitReqCnt
();
#ifdef __cplusplus
}
#endif
...
...
src/plugins/monitor/src/monMain.c
浏览文件 @
52cb5b44
...
...
@@ -77,7 +77,9 @@ typedef struct {
}
SMonConn
;
static
SMonConn
tsMonitor
=
{
0
};
static
bool
monHasMnodeMaster
=
false
;
static
int32_t
monQueryReqNum
=
0
,
monSubmitReqNum
=
0
;
static
bool
monHasMnodeMaster
=
false
;
static
void
monSaveSystemInfo
();
static
void
monSaveClusterInfo
();
static
void
monSaveDnodesInfo
();
...
...
@@ -396,7 +398,8 @@ static int32_t monBuildBandSql(char *sql) {
}
static
int32_t
monBuildReqSql
(
char
*
sql
)
{
SStatisInfo
info
=
dnodeGetStatisInfo
();
//SStatisInfo info = dnodeGetStatisInfo();
SStatisInfo
info
=
{
0
};
return
sprintf
(
sql
,
", %d, %d, %d)"
,
info
.
httpReqNum
,
info
.
queryReqNum
,
info
.
submitReqNum
);
}
...
...
@@ -429,6 +432,7 @@ static void monSaveSystemInfo() {
if
(
code
!=
0
)
{
monError
(
"failed to save system info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save system info, sql:%s"
,
tsMonitor
.
sql
);
}
}
...
...
@@ -685,8 +689,8 @@ static int32_t monBuildReqRateSql(char *sql) {
float
queryReqRate
=
info
.
queryReqNum
/
interval
;
float
submitReqRate
=
info
.
submitReqNum
/
interval
;
return
sprintf
(
sql
,
", %d, %f, %d, %f, %d, %f"
,
info
.
httpReqNum
,
httpReqRate
,
info
.
queryReqNum
,
queryReqRate
,
info
.
submitReqNum
,
submitReqRate
);
info
.
queryReqNum
-
monFetchQueryReqCnt
()
,
queryReqRate
,
info
.
submitReqNum
-
monFetchSubmitReqCnt
()
,
submitReqRate
);
}
static
int32_t
monBuildDnodeErrorsSql
(
char
*
sql
)
{
...
...
@@ -782,6 +786,7 @@ static void monSaveClusterInfo() {
if
(
code
!=
0
)
{
monError
(
"failed to save cluster info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save cluster info, sql:%s"
,
tsMonitor
.
sql
);
}
}
...
...
@@ -811,6 +816,7 @@ static void monSaveDnodesInfo() {
if
(
code
!=
0
)
{
monError
(
"failed to save dnode_%d info, reason:%s, sql:%s"
,
dnodeGetDnodeId
(),
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save dnode_%d info, sql:%s"
,
dnodeGetDnodeId
(),
tsMonitor
.
sql
);
}
}
...
...
@@ -893,6 +899,7 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) {
if
(
code
!=
0
)
{
monError
(
"failed to save vgroup_%d info, reason:%s, sql:%s"
,
vgId
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save vgroup_%d info, sql:%s"
,
vgId
,
tsMonitor
.
sql
);
}
}
...
...
@@ -968,10 +975,10 @@ static void monSaveSlowQueryInfo() {
if
(
code
!=
0
)
{
monError
(
"failed to save slowquery info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
monIncSubmitReqCnt
();
monDebug
(
"successfully to save slowquery info, sql:%s"
,
tsMonitor
.
sql
);
}
}
static
void
monExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
...
...
@@ -979,6 +986,7 @@ static void monExecSqlCb(void *param, TAOS_RES *result, int32_t code) {
if
(
c
!=
TSDB_CODE_SUCCESS
)
{
monError
(
"save %s failed, reason:%s"
,
(
char
*
)
param
,
tstrerror
(
c
));
}
else
{
monIncSubmitReqCnt
();
int32_t
rows
=
taos_affected_rows
(
result
);
monDebug
(
"save %s succ, rows:%d"
,
(
char
*
)
param
,
rows
);
}
...
...
@@ -1078,3 +1086,19 @@ void monExecuteSQLWithResultCallback(char *sql, MonExecuteSQLCbFP callback, void
monDebug
(
"execute sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
callback
,
param
);
}
void
monIncQueryReqCnt
()
{
atomic_fetch_add_32
(
&
monQueryReqNum
,
1
);
}
void
monIncSubmitReqCnt
()
{
atomic_fetch_add_32
(
&
monSubmitReqNum
,
1
);
}
int32_t
monFetchQueryReqCnt
()
{
return
atomic_exchange_32
(
&
monQueryReqNum
,
0
);
}
int32_t
monFetchSubmitReqCnt
()
{
return
atomic_exchange_32
(
&
monSubmitReqNum
,
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录