Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fdb2a099
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看板
提交
fdb2a099
编写于
11月 02, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6452]<feature>: taoskeeper modified grants_info
上级
72fb4c61
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
32 deletion
+66
-32
src/os/inc/osSysinfo.h
src/os/inc/osSysinfo.h
+2
-2
src/os/src/darwin/dwSysInfo.c
src/os/src/darwin/dwSysInfo.c
+3
-1
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+36
-22
src/plugins/http/src/httpMetricsHandle.c
src/plugins/http/src/httpMetricsHandle.c
+3
-3
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+22
-4
未找到文件。
src/os/inc/osSysinfo.h
浏览文件 @
fdb2a099
...
...
@@ -30,8 +30,8 @@ int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize);
int32_t
taosGetCpuCores
();
void
taosGetSystemInfo
();
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
bool
taosGetProcIO
(
float
*
r
eadKB
,
float
*
wri
teKB
);
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
rbytes
,
int64_t
*
wbytes
);
bool
taosGetProcIO
(
float
*
r
charKB
,
float
*
wcharKB
,
float
*
rbyteKB
,
float
*
wby
teKB
);
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
);
bool
taosGetNetworkIO
(
float
*
netInKb
,
float
*
netOutKb
);
...
...
src/os/src/darwin/dwSysInfo.c
浏览文件 @
fdb2a099
...
...
@@ -191,9 +191,11 @@ void taosGetSystemInfo() {
taosGetSystemLocale
();
}
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
rbytes
,
int64_t
*
wbytes
)
{
if
(
rchars
)
*
rchars
=
0
;
if
(
wchars
)
*
wchars
=
0
;
if
(
rbytes
)
*
rbytes
=
0
;
if
(
wbytes
)
*
wbytes
=
0
;
return
true
;
}
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
fdb2a099
...
...
@@ -465,7 +465,7 @@ bool taosGetNetworkIO(float *netInKb, float *netOutKb) {
return
true
;
}
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
rbytes
,
int64_t
*
wbytes
)
{
FILE
*
fp
=
fopen
(
tsProcIOFile
,
"r"
);
if
(
fp
==
NULL
)
{
uError
(
"open file:%s failed"
,
tsProcIOFile
);
...
...
@@ -475,7 +475,7 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
ssize_t
_bytes
=
0
;
size_t
len
;
char
*
line
=
NULL
;
char
tmp
[
1
0
];
char
tmp
[
1
5
];
int
readIndex
=
0
;
while
(
!
feof
(
fp
))
{
...
...
@@ -491,16 +491,21 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
}
else
if
(
strstr
(
line
,
"wchar:"
)
!=
NULL
)
{
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
wchars
);
readIndex
++
;
}
else
{
}
else
if
(
strstr
(
line
,
"read_bytes:"
)
!=
NULL
){
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
rbytes
);
readIndex
++
;
}
else
if
(
strstr
(
line
,
"write_bytes:"
)
!=
NULL
){
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
wbytes
);
readIndex
++
;
}
if
(
readIndex
>=
2
)
break
;
if
(
readIndex
>=
4
)
break
;
}
tfree
(
line
);
fclose
(
fp
);
if
(
readIndex
<
2
)
{
if
(
readIndex
<
4
)
{
uError
(
"read file:%s failed"
,
tsProcIOFile
);
return
false
;
}
...
...
@@ -508,30 +513,39 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
return
true
;
}
bool
taosGetProcIO
(
float
*
r
eadKB
,
float
*
wri
teKB
)
{
static
int64_t
lastR
ead
byte
=
-
1
;
static
int64_t
lastW
rite
byte
=
-
1
;
bool
taosGetProcIO
(
float
*
r
charKB
,
float
*
wcharKB
,
float
*
rbyteKB
,
float
*
wby
teKB
)
{
static
int64_t
lastR
char
=
-
1
,
lastR
byte
=
-
1
;
static
int64_t
lastW
char
=
-
1
,
lastW
byte
=
-
1
;
int64_t
curR
ead
byte
=
0
;
int64_t
curW
rite
byte
=
0
;
int64_t
curR
char
=
0
,
curR
byte
=
0
;
int64_t
curW
char
=
0
,
curW
byte
=
0
;
if
(
!
taosReadProcIO
(
&
curR
eadbyte
,
&
curWrite
byte
))
{
if
(
!
taosReadProcIO
(
&
curR
char
,
&
curWchar
,
&
curRbyte
,
&
curW
byte
))
{
return
false
;
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
if
(
lastRchar
==
-
1
||
lastWchar
==
-
1
||
lastRbyte
==
-
1
||
lastWbyte
==
-
1
)
{
lastRchar
=
curRchar
;
lastWchar
=
curWchar
;
lastRbyte
=
curRbyte
;
lastWbyte
=
curWbyte
;
return
false
;
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
writeKB
=
(
float
)((
double
)(
curWritebyte
-
lastWritebyte
)
/
1024
);
if
(
*
readKB
<
0
)
*
readKB
=
0
;
if
(
*
writeKB
<
0
)
*
writeKB
=
0
;
*
rcharKB
=
(
float
)((
double
)(
curRchar
-
lastRchar
)
/
1024
);
*
wcharKB
=
(
float
)((
double
)(
curWchar
-
lastWchar
)
/
1024
);
if
(
*
rcharKB
<
0
)
*
rcharKB
=
0
;
if
(
*
wcharKB
<
0
)
*
wcharKB
=
0
;
*
rbyteKB
=
(
float
)((
double
)(
curRbyte
-
lastRbyte
)
/
1024
);
*
wbyteKB
=
(
float
)((
double
)(
curWbyte
-
lastWbyte
)
/
1024
);
if
(
*
rbyteKB
<
0
)
*
rbyteKB
=
0
;
if
(
*
wbyteKB
<
0
)
*
wbyteKB
=
0
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastRchar
=
curRchar
;
lastWchar
=
curWchar
;
lastRbyte
=
curRbyte
;
lastWbyte
=
curWbyte
;
return
true
;
}
...
...
@@ -542,13 +556,13 @@ void taosGetSystemInfo() {
tsNumOfCores
=
taosGetCpuCores
();
tsTotalMemoryMB
=
taosGetTotalMemory
();
float
tmp1
,
tmp2
;
float
tmp1
,
tmp2
,
tmp3
,
tmp4
;
taosGetSysMemory
(
&
tmp1
);
taosGetProcMemory
(
&
tmp2
);
// taosGetDisk();
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
tmp4
);
taosGetSystemTimezone
();
taosGetSystemLocale
();
...
...
src/plugins/http/src/httpMetricsHandle.c
浏览文件 @
fdb2a099
...
...
@@ -123,9 +123,9 @@ bool metricsProcessRequest(HttpContext* pContext) {
}
{
int64_t
rchars
=
0
;
int64_t
wchars
=
0
;
bool
succeeded
=
taosReadProcIO
(
&
rchars
,
&
wchars
);
int64_t
rchars
=
0
,
rbytes
=
0
;
int64_t
wchars
=
0
,
wbytes
=
0
;
bool
succeeded
=
taosReadProcIO
(
&
rchars
,
&
wchars
,
&
rbytes
,
&
wbytes
);
if
(
!
succeeded
)
{
httpError
(
"failed to get io info"
);
}
else
{
...
...
src/plugins/monitor/src/monMain.c
浏览文件 @
fdb2a099
...
...
@@ -148,9 +148,17 @@ typedef struct {
char
sql
[
SQL_LENGTH
+
1
];
}
SMonConn
;
typedef
struct
{
float
io_read
;
float
io_write
;
float
io_read_disk
;
float
io_write_disk
;
}
SMonStat
;
static
void
*
monHttpStatusHashTable
;
static
SMonConn
tsMonitor
=
{
0
};
static
SMonStat
tsMonStat
=
{
0
};
static
int32_t
monQueryReqNum
=
0
,
monSubmitReqNum
=
0
;
static
bool
monHasMnodeMaster
=
false
;
...
...
@@ -163,6 +171,7 @@ static void monSaveDisksInfo();
static
void
monSaveGrantsInfo
();
static
void
monSaveHttpReqInfo
();
static
void
monClearStatisInfo
();
static
void
monGetSysStats
();
static
void
*
monThreadFunc
(
void
*
param
);
static
void
monBuildMonitorSql
(
char
*
sql
,
int32_t
cmd
);
static
void
monInitHttpStatusHashTable
();
...
...
@@ -300,6 +309,7 @@ static void *monThreadFunc(void *param) {
if
(
tsMonitor
.
state
==
MON_STATE_INITED
)
{
if
(
accessTimes
%
tsMonitorInterval
==
0
||
accessTimes
==
1
)
{
monGetSysStats
();
//monSaveDnodesInfo has to be the first, as it calculates
//stats using monSubmitReqNum before any insertion from monitor
monSaveDnodesInfo
();
...
...
@@ -398,6 +408,7 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
", disk_engine float, disk_used float, disk_total float"
", net_in float, net_out float"
", io_read float, io_write float"
", io_read_disk float, io_write_disk float"
", req_http int, req_http_rate float"
", req_select int, req_select_rate float"
", req_insert int, req_insert_success int, req_insert_rate float"
...
...
@@ -486,6 +497,15 @@ void monCleanupSystem() {
monInfo
(
"monitor module is cleaned up"
);
}
static
void
monGetSysStats
()
{
memset
(
&
tsMonStat
,
0
,
sizeof
(
SMonStat
));
bool
suc
=
taosGetProcIO
(
&
tsMonStat
.
io_read
,
&
tsMonStat
.
io_write
,
&
tsMonStat
.
io_read_disk
,
&
tsMonStat
.
io_write_disk
);
if
(
!
suc
)
{
monDebug
(
"failed to get io info"
);
}
}
// unit is MB
static
int32_t
monBuildMemorySql
(
char
*
sql
)
{
float
sysMemoryUsedMB
=
0
;
...
...
@@ -541,10 +561,8 @@ static int32_t monBuildReqSql(char *sql) {
static
int32_t
monBuildIoSql
(
char
*
sql
)
{
float
readKB
=
0
,
writeKB
=
0
;
bool
suc
=
taosGetProcIO
(
&
readKB
,
&
writeKB
);
if
(
!
suc
)
{
monDebug
(
"failed to get io info"
);
}
readKB
=
tsMonStat
.
io_read
;
writeKB
=
tsMonStat
.
io_write
;
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录