Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09be95e4
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
09be95e4
编写于
3月 05, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sysinfo for monitor
上级
09f27bdc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
75 deletion
+69
-75
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+5
-5
include/os/osSysinfo.h
include/os/osSysinfo.h
+2
-2
source/dnode/mgmt/impl/inc/dndEnv.h
source/dnode/mgmt/impl/inc/dndEnv.h
+1
-0
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+6
-8
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+7
-0
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+48
-60
未找到文件。
include/libs/monitor/monitor.h
浏览文件 @
09be95e4
...
...
@@ -92,11 +92,11 @@ typedef struct {
int64_t
mem_engine
;
// KB
int64_t
mem_system
;
// KB
int64_t
mem_total
;
// KB
float
disk_engine
;
// GB
float
disk_used
;
// GB
float
disk_total
;
// GB
int64_t
net_in
;
int64_t
net_out
;
int64_t
disk_engine
;
// Byte
int64_t
disk_used
;
// Byte
int64_t
disk_total
;
// Byte
int64_t
net_in
;
// Byte
int64_t
net_out
;
// Byte
float
io_read
;
float
io_write
;
float
io_read_disk
;
...
...
include/os/osSysinfo.h
浏览文件 @
09be95e4
...
...
@@ -43,8 +43,8 @@ int32_t taosGetTotalMemory(int64_t *totalKB);
int32_t
taosGetProcMemory
(
int64_t
*
usedKB
);
int32_t
taosGetSysMemory
(
int64_t
*
usedKB
);
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
write
KB
);
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
);
int32_t
taosGetProcIO
Speed
(
float
*
readKB
,
float
*
writeKB
,
float
*
readDiskKB
,
float
*
writeDisk
KB
);
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
);
...
...
source/dnode/mgmt/impl/inc/dndEnv.h
浏览文件 @
09be95e4
...
...
@@ -108,6 +108,7 @@ typedef struct {
SHashObj
*
hash
;
int32_t
openVnodes
;
int32_t
totalVnodes
;
int32_t
masterNum
;
SRWLatch
latch
;
SQWorkerPool
queryPool
;
SFWorkerPool
fetchPool
;
...
...
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
09be95e4
...
...
@@ -487,12 +487,10 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
taosGetSysMemory
(
&
pInfo
->
mem_system
);
pInfo
->
mem_total
=
tsTotalMemoryKB
;
pInfo
->
disk_engine
=
0
;
pInfo
->
disk_used
=
tsDataSpace
.
size
.
used
/
(
1024
*
1024
*
1024
.
0
)
;
pInfo
->
disk_total
=
tsDataSpace
.
size
.
avail
/
(
1024
*
1024
*
1024
.
0
)
;
pInfo
->
disk_used
=
tsDataSpace
.
size
.
used
;
pInfo
->
disk_total
=
tsDataSpace
.
size
.
avail
;
taosGetCardInfo
(
NULL
,
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
);
pInfo
->
io_read_disk
=
0
;
pInfo
->
io_write_disk
=
0
;
taosGetProcIOSpeed
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
pInfo
->
req_select
=
0
;
pInfo
->
req_select_rate
=
0
;
pInfo
->
req_insert
=
0
;
...
...
@@ -501,9 +499,9 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
pInfo
->
req_insert_batch
=
0
;
pInfo
->
req_insert_batch_success
=
0
;
pInfo
->
req_insert_batch_rate
=
0
;
pInfo
->
errors
=
0
;
pInfo
->
vnodes_num
=
0
;
pInfo
->
masters
=
0
;
pInfo
->
errors
=
tsNumOfErrorLogs
;
pInfo
->
vnodes_num
=
pDnode
->
vmgmt
.
totalVnodes
;
pInfo
->
masters
=
pDnode
->
vmgmt
.
masterNum
;
pInfo
->
has_mnode
=
dndIsMnode
(
pDnode
);
}
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
09be95e4
...
...
@@ -17,6 +17,7 @@
#include "dndVnodes.h"
#include "dndMgmt.h"
#include "dndTransport.h"
#include "sync.h"
typedef
struct
{
int32_t
vgId
;
...
...
@@ -979,6 +980,8 @@ void dndCleanupVnodes(SDnode *pDnode) {
void
dndGetVnodeLoads
(
SDnode
*
pDnode
,
SArray
*
pLoads
)
{
SVnodesMgmt
*
pMgmt
=
&
pDnode
->
vmgmt
;
int32_t
totalVnodes
=
0
;
int32_t
masterNum
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
...
...
@@ -993,8 +996,12 @@ void dndGetVnodeLoads(SDnode *pDnode, SArray *pLoads) {
vnodeGetLoad
(
pVnode
->
pImpl
,
&
vload
);
taosArrayPush
(
pLoads
,
&
vload
);
totalVnodes
++
;
if
(
vload
.
role
==
TAOS_SYNC_STATE_LEADER
)
masterNum
++
;
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
totalVnodes
=
totalVnodes
;
pMgmt
->
masterNum
=
masterNum
;
}
source/os/src/osSysinfo.c
浏览文件 @
09be95e4
...
...
@@ -124,52 +124,26 @@ int32_t taosGetBandSpeed(float *bandSpeedKb) {
return
0
;
}
int32_t
taosReadProcIO
(
int64_t
*
r
eadbyte
,
int64_t
*
writebyte
)
{
int32_t
taosReadProcIO
(
int64_t
*
r
chars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
IO_COUNTERS
io_counter
;
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
readbyte
)
*
readbyte
=
io_counter
.
ReadTransferCount
;
if
(
writebyte
)
*
writebyte
=
io_counter
.
WriteTransferCount
;
if
(
rchars
)
*
rchars
=
io_counter
.
ReadTransferCount
;
if
(
wchars
)
*
wchars
=
io_counter
.
WriteTransferCount
;
if
(
read_bytes
)
*
read_bytes
=
0
;
if
(
write_bytes
)
*
write_bytes
=
0
;
return
0
;
}
return
-
1
;
}
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
)
!=
0
)
{
return
-
1
;
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
-
1
;
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
writeKB
=
(
float
)((
double
)(
curWritebyte
-
lastWritebyte
)
/
1024
);
if
(
*
readKB
<
0
)
*
readKB
=
0
;
if
(
*
writeKB
<
0
)
*
writeKB
=
0
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
0
;
}
void
taosGetSystemInfo
()
{
taosGetCpuCores
(
&
tsNumOfCores
);
taosGetTotalMemory
(
&
tsTotalMemoryKB
);
float
tmp1
,
tmp2
;
float
tmp1
,
tmp2
,
tmp3
,
tmp4
;
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
Speed
(
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
tmp4
);
}
void
taosKillSystem
()
{
...
...
@@ -259,15 +233,11 @@ void taosGetSystemInfo() {
tsNumOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
if
(
rchars
)
*
rchars
=
0
;
if
(
wchars
)
*
wchars
=
0
;
return
0
;
}
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
*
readKB
=
0
;
*
writeKB
=
0
;
if
(
read_bytes
)
*
read_bytes
=
0
;
if
(
write_bytes
)
*
write_bytes
=
0
;
return
0
;
}
...
...
@@ -631,8 +601,7 @@ int32_t taosGetBandSpeed(float *bandSpeedKb) {
return
0
;
}
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
// FILE *fp = fopen(tsProcIOFile, "r");
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
TdFilePtr
pFile
=
taosOpenFile
(
tsProcIOFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
// printf("open file:%s failed", tsProcIOFile);
...
...
@@ -655,16 +624,22 @@ int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
}
else
if
(
strstr
(
line
,
"wchar:"
)
!=
NULL
)
{
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
wchars
);
readIndex
++
;
}
else
{
}
if
(
strstr
(
line
,
"read_bytes:"
)
!=
NULL
)
{
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
read_bytes
);
readIndex
++
;
}
else
if
(
strstr
(
line
,
"write_bytes::"
)
!=
NULL
)
{
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
write_bytes
);
readIndex
++
;
}
else
{
}
if
(
readIndex
>=
2
)
break
;
if
(
readIndex
>=
4
)
break
;
}
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
if
(
readIndex
<
2
)
{
if
(
readIndex
<
4
)
{
// printf("read file:%s failed", tsProcIOFile);
return
-
1
;
}
...
...
@@ -672,30 +647,43 @@ int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
return
0
;
}
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int32_t
taosGetProcIOSpeed
(
float
*
readKB
,
float
*
writeKB
,
float
*
readDiskKB
,
float
*
writeDiskKB
)
{
static
int64_t
lastRchar
=
-
1
;
static
int64_t
lastWchar
=
-
1
;
static
int64_t
lastRbyte
=
-
1
;
static
int64_t
lastWbyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
int64_t
curRchar
=
0
;
int64_t
curWchar
=
0
;
int64_t
curRbyte
=
0
;
int64_t
curWbyte
=
0
;
if
(
taosReadProcIO
(
&
curR
eadbyte
,
&
curWrite
byte
)
!=
0
)
{
if
(
taosReadProcIO
(
&
curR
char
,
&
curWchar
,
&
curRbyte
,
&
curW
byte
)
!=
0
)
{
return
-
1
;
}
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
-
1
;
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
writeKB
=
(
float
)((
double
)(
curWritebyte
-
lastWritebyte
)
/
1024
);
*
readKB
=
(
curRchar
-
lastRchar
)
/
1024
.
0
f
;
*
writeKB
=
(
curWchar
-
lastWchar
)
/
1024
.
0
f
;
*
readDiskKB
=
(
curRbyte
-
lastRbyte
)
/
1024
.
0
f
;
*
writeDiskKB
=
(
curWbyte
-
lastWbyte
)
/
1024
.
0
f
;
if
(
*
readKB
<
0
)
*
readKB
=
0
;
if
(
*
writeKB
<
0
)
*
writeKB
=
0
;
if
(
*
readDiskKB
<
0
)
*
readDiskKB
=
0
;
if
(
*
writeDiskKB
<
0
)
*
writeDiskKB
=
0
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastRchar
=
curRchar
;
lastWchar
=
curWchar
;
lastRbyte
=
curRbyte
;
lastWbyte
=
curWbyte
;
return
0
;
}
...
...
@@ -705,10 +693,10 @@ void taosGetSystemInfo() {
taosGetCpuCores
(
&
tsNumOfCores
);
taosGetTotalMemory
(
&
tsTotalMemoryKB
);
float
tmp1
,
tmp2
;
float
tmp1
,
tmp2
,
tmp3
,
tmp4
;
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
Speed
(
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
tmp4
);
}
void
taosKillSystem
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录