Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7f3b1502
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7f3b1502
编写于
4月 11, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(cluster): get monitor info in multi-process mode
上级
a6be63e2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
92 addition
and
64 deletion
+92
-64
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+5
-2
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-1
source/dnode/mgmt/dm/dmMonitor.c
source/dnode/mgmt/dm/dmMonitor.c
+9
-10
source/dnode/mgmt/qm/qmWorker.c
source/dnode/mgmt/qm/qmWorker.c
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+2
-0
source/libs/monitor/src/monMain.c
source/libs/monitor/src/monMain.c
+3
-0
source/libs/monitor/src/monMsg.c
source/libs/monitor/src/monMsg.c
+7
-7
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+29
-43
tests/script/tmp/monitor.sim
tests/script/tmp/monitor.sim
+35
-0
未找到文件。
include/libs/monitor/monitor.h
浏览文件 @
7f3b1502
...
...
@@ -78,6 +78,9 @@ typedef struct {
typedef
struct
{
float
uptime
;
// day
int8_t
has_mnode
;
int8_t
has_qnode
;
int8_t
has_snode
;
int8_t
has_bnode
;
SMonDiskDesc
logdir
;
SMonDiskDesc
tempdir
;
}
SMonDnodeInfo
;
...
...
@@ -134,8 +137,8 @@ typedef struct {
typedef
struct
{
int32_t
expire_time
;
int
32
_t
timeseries_used
;
int
32
_t
timeseries_total
;
int
64
_t
timeseries_used
;
int
64
_t
timeseries_total
;
}
SMonGrantInfo
;
typedef
struct
{
...
...
include/os/osSysinfo.h
浏览文件 @
7f3b1502
...
...
@@ -39,7 +39,7 @@ int32_t taosGetEmail(char *email, int32_t maxLen);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
float
*
numOfCores
);
int32_t
taosGetCpuCores
(
float
*
numOfCores
);
int32_t
taosGetCpuUsage
(
double
*
cpu_system
,
double
*
cpu_engine
);
void
taosGetCpuUsage
(
double
*
cpu_system
,
double
*
cpu_engine
);
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
);
int32_t
taosGetProcMemory
(
int64_t
*
usedKB
);
int32_t
taosGetSysMemory
(
int64_t
*
usedKB
);
...
...
source/dnode/mgmt/dm/dmMonitor.c
浏览文件 @
7f3b1502
...
...
@@ -25,11 +25,10 @@ static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
static
void
dmGetMonitorDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
pInfo
->
uptime
=
(
taosGetTimestampMs
()
-
pDnode
->
rebootTime
)
/
(
86400000
.
0
f
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
MNODE
);
if
(
pWrapper
!=
NULL
)
{
pInfo
->
has_mnode
=
pWrapper
->
required
;
dndReleaseWrapper
(
pWrapper
);
}
pInfo
->
has_mnode
=
pDnode
->
wrappers
[
MNODE
].
required
;
pInfo
->
has_qnode
=
pDnode
->
wrappers
[
QNODE
].
required
;
pInfo
->
has_snode
=
pDnode
->
wrappers
[
SNODE
].
required
;
pInfo
->
has_bnode
=
pDnode
->
wrappers
[
BNODE
].
required
;
tstrncpy
(
pInfo
->
logdir
.
name
,
tsLogDir
,
sizeof
(
pInfo
->
logdir
.
name
));
pInfo
->
logdir
.
size
=
tsLogSpace
.
size
;
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
...
...
@@ -65,7 +64,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
bool
getFromAPI
=
!
tsMultiProcess
;
pWrapper
=
&
pDnode
->
wrappers
[
MNODE
];
if
(
getFromAPI
)
{
if
(
dndMarkWrapper
(
pWrapper
)
!
=
0
)
{
if
(
dndMarkWrapper
(
pWrapper
)
=
=
0
)
{
mmGetMonitorInfo
(
pWrapper
,
&
mmInfo
);
dndReleaseWrapper
(
pWrapper
);
}
...
...
@@ -82,7 +81,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
VNODES
];
if
(
getFromAPI
)
{
if
(
dndMarkWrapper
(
pWrapper
)
!
=
0
)
{
if
(
dndMarkWrapper
(
pWrapper
)
=
=
0
)
{
vmGetMonitorInfo
(
pWrapper
,
&
vmInfo
);
dndReleaseWrapper
(
pWrapper
);
}
...
...
@@ -99,7 +98,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
QNODE
];
if
(
getFromAPI
)
{
if
(
dndMarkWrapper
(
pWrapper
)
!
=
0
)
{
if
(
dndMarkWrapper
(
pWrapper
)
=
=
0
)
{
qmGetMonitorInfo
(
pWrapper
,
&
qmInfo
);
dndReleaseWrapper
(
pWrapper
);
}
...
...
@@ -116,7 +115,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
SNODE
];
if
(
getFromAPI
)
{
if
(
dndMarkWrapper
(
pWrapper
)
!
=
0
)
{
if
(
dndMarkWrapper
(
pWrapper
)
=
=
0
)
{
smGetMonitorInfo
(
pWrapper
,
&
smInfo
);
dndReleaseWrapper
(
pWrapper
);
}
...
...
@@ -133,7 +132,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
BNODE
];
if
(
getFromAPI
)
{
if
(
dndMarkWrapper
(
pWrapper
)
!
=
0
)
{
if
(
dndMarkWrapper
(
pWrapper
)
=
=
0
)
{
bmGetMonitorInfo
(
pWrapper
,
&
bmInfo
);
dndReleaseWrapper
(
pWrapper
);
}
...
...
source/dnode/mgmt/qm/qmWorker.c
浏览文件 @
7f3b1502
...
...
@@ -32,7 +32,7 @@ static void qmProcessMonitorQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
int32_t
code
=
-
1
;
if
(
pMsg
->
rpcMsg
.
msgType
==
TDMT_MON_
S
M_INFO
)
{
if
(
pMsg
->
rpcMsg
.
msgType
==
TDMT_MON_
Q
M_INFO
)
{
code
=
qmProcessGetMonQmInfoReq
(
pMgmt
->
pWrapper
,
pMsg
);
}
else
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
7f3b1502
...
...
@@ -330,9 +330,11 @@ static int32_t mndProcessStatusReq(SNodeMsg *pReq) {
SVgObj
*
pVgroup
=
mndAcquireVgroup
(
pMnode
,
pVload
->
vgId
);
if
(
pVgroup
!=
NULL
)
{
mInfo
(
"------>0 vgId:%d, numOfTimeSeries:%"
PRId64
,
pVgroup
->
vgId
,
pVload
->
numOfTimeSeries
);
if
(
pVload
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
pVgroup
->
numOfTables
=
pVload
->
numOfTables
;
pVgroup
->
numOfTimeSeries
=
pVload
->
numOfTimeSeries
;
mInfo
(
"------>1 vgId:%d, numOfTimeSeries:%"
PRId64
,
pVgroup
->
vgId
,
pVgroup
->
numOfTimeSeries
);
pVgroup
->
totalStorage
=
pVload
->
totalStorage
;
pVgroup
->
compStorage
=
pVload
->
compStorage
;
pVgroup
->
pointsWritten
=
pVload
->
pointsWritten
;
...
...
source/libs/monitor/src/monMain.c
浏览文件 @
7f3b1502
...
...
@@ -375,6 +375,9 @@ static void monGenDnodeJson(SMonInfo *pMonitor) {
tjsonAddDoubleToObject
(
pJson
,
"vnodes_num"
,
pStat
->
totalVnodes
);
tjsonAddDoubleToObject
(
pJson
,
"masters"
,
pStat
->
masterNum
);
tjsonAddDoubleToObject
(
pJson
,
"has_mnode"
,
pInfo
->
has_mnode
);
tjsonAddDoubleToObject
(
pJson
,
"has_qnode"
,
pInfo
->
has_qnode
);
tjsonAddDoubleToObject
(
pJson
,
"has_snode"
,
pInfo
->
has_snode
);
tjsonAddDoubleToObject
(
pJson
,
"has_bnode"
,
pInfo
->
has_bnode
);
}
static
void
monGenDiskJson
(
SMonInfo
*
pMonitor
)
{
...
...
source/libs/monitor/src/monMsg.c
浏览文件 @
7f3b1502
...
...
@@ -194,9 +194,9 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
if
(
tDecodeCStrTo
(
decoder
,
desc
.
database_name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
decoder
,
desc
.
status
)
<
0
)
return
-
1
;
for
(
int32_t
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
SMonVnodeDesc
vdesc
=
{
0
}
;
if
(
tDecodeI32
(
decoder
,
&
vdesc
.
dnode_id
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
decoder
,
vdesc
.
vnode_role
)
<
0
)
return
-
1
;
SMonVnodeDesc
*
pVDesc
=
&
desc
.
vnodes
[
j
]
;
if
(
tDecodeI32
(
decoder
,
&
pVDesc
->
dnode_id
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
decoder
,
pVDesc
->
vnode_role
)
<
0
)
return
-
1
;
}
taosArrayPush
(
pInfo
->
vgroups
,
&
desc
);
}
...
...
@@ -205,15 +205,15 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
int32_t
tEncodeSMonGrantInfo
(
SCoder
*
encoder
,
const
SMonGrantInfo
*
pInfo
)
{
if
(
tEncodeI32
(
encoder
,
pInfo
->
expire_time
)
<
0
)
return
-
1
;
if
(
tEncodeI
32
(
encoder
,
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
if
(
tEncodeI
32
(
encoder
,
pInfo
->
timeseries_total
)
<
0
)
return
-
1
;
if
(
tEncodeI
64
(
encoder
,
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
if
(
tEncodeI
64
(
encoder
,
pInfo
->
timeseries_total
)
<
0
)
return
-
1
;
return
0
;
}
int32_t
tDecodeSMonGrantInfo
(
SCoder
*
decoder
,
SMonGrantInfo
*
pInfo
)
{
if
(
tDecodeI32
(
decoder
,
&
pInfo
->
expire_time
)
<
0
)
return
-
1
;
if
(
tDecodeI
32
(
decoder
,
&
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
if
(
tDecodeI
32
(
decoder
,
&
pInfo
->
timeseries_total
)
<
0
)
return
-
1
;
if
(
tDecodeI
64
(
decoder
,
&
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
if
(
tDecodeI
64
(
decoder
,
&
pInfo
->
timeseries_total
)
<
0
)
return
-
1
;
return
0
;
}
...
...
source/os/src/osSysinfo.c
浏览文件 @
7f3b1502
...
...
@@ -369,53 +369,33 @@ int32_t taosGetCpuCores(float *numOfCores) {
#endif
}
int32_t
taosGetCpuUsage
(
double
*
cpu_system
,
double
*
cpu_engine
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
*
cpu_system
=
0
;
*
cpu_engine
=
0
;
return
0
;
#elif defined(_TD_DARWIN_64)
void
taosGetCpuUsage
(
double
*
cpu_system
,
double
*
cpu_engine
)
{
static
int64_t
lastSysUsed
=
0
;
static
int64_t
lastSysTotal
=
0
;
static
int64_t
lastProcTotal
=
0
;
static
int64_t
curSysUsed
=
0
;
static
int64_t
curSysTotal
=
0
;
static
int64_t
curProcTotal
=
0
;
*
cpu_system
=
0
;
*
cpu_engine
=
0
;
return
0
;
#else
static
uint64_t
lastSysUsed
=
0
;
static
uint64_t
lastSysTotal
=
0
;
static
uint64_t
lastProcTotal
=
0
;
SysCpuInfo
sysCpu
;
ProcCpuInfo
procCpu
;
if
(
taosGetSysCpuInfo
(
&
sysCpu
)
!=
0
)
{
return
-
1
;
}
if
(
taosGetProcCpuInfo
(
&
procCpu
)
!=
0
)
{
return
-
1
;
}
uint64_t
curSysUsed
=
sysCpu
.
user
+
sysCpu
.
nice
+
sysCpu
.
system
;
uint64_t
curSysTotal
=
curSysUsed
+
sysCpu
.
idle
;
uint64_t
curProcTotal
=
procCpu
.
utime
+
procCpu
.
stime
+
procCpu
.
cutime
+
procCpu
.
cstime
;
SysCpuInfo
sysCpu
=
{
0
};
ProcCpuInfo
procCpu
=
{
0
};
if
(
taosGetSysCpuInfo
(
&
sysCpu
)
==
0
&&
taosGetProcCpuInfo
(
&
procCpu
)
==
0
)
{
curSysUsed
=
sysCpu
.
user
+
sysCpu
.
nice
+
sysCpu
.
system
;
curSysTotal
=
curSysUsed
+
sysCpu
.
idle
;
curProcTotal
=
procCpu
.
utime
+
procCpu
.
stime
+
procCpu
.
cutime
+
procCpu
.
cstime
;
if
(
lastSysUsed
==
0
||
lastSysTotal
==
0
||
lastProcTotal
==
0
)
{
lastSysUsed
=
curSysUsed
>
1
?
curSysUsed
:
1
;
lastSysTotal
=
curSysTotal
>
1
?
curSysTotal
:
1
;
lastProcTotal
=
curProcTotal
>
1
?
curProcTotal
:
1
;
return
-
1
;
}
if
(
curSysTotal
>
lastSysTotal
&&
curSysUsed
>=
lastSysUsed
&&
curProcTotal
>=
lastProcTotal
)
{
*
cpu_engine
=
(
curSysUsed
-
lastSysUsed
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
;
*
cpu_system
=
(
curProcTotal
-
lastProcTotal
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
;
}
if
(
curSysTotal
==
lastSysTotal
)
{
return
-
1
;
lastSysUsed
=
curSysUsed
;
lastSysTotal
=
curSysTotal
;
lastProcTotal
=
curProcTotal
;
}
*
cpu_engine
=
(
curSysUsed
-
lastSysUsed
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
;
*
cpu_system
=
(
curProcTotal
-
lastProcTotal
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
;
lastSysUsed
=
curSysUsed
;
lastSysTotal
=
curSysTotal
;
lastProcTotal
=
curProcTotal
;
return
0
;
#endif
}
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
)
{
...
...
@@ -618,7 +598,6 @@ void taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, i
static
int64_t
last_wchars
=
0
;
static
int64_t
last_read_bytes
=
0
;
static
int64_t
last_write_bytes
=
0
;
static
int64_t
cur_rchars
=
0
;
static
int64_t
cur_wchars
=
0
;
static
int64_t
cur_read_bytes
=
0
;
...
...
@@ -632,6 +611,11 @@ void taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, i
last_wchars
=
cur_wchars
;
last_read_bytes
=
cur_read_bytes
;
last_write_bytes
=
cur_write_bytes
;
}
else
{
*
rchars
=
0
;
*
wchars
=
0
;
*
read_bytes
=
0
;
*
write_bytes
=
0
;
}
}
...
...
@@ -693,7 +677,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
void
taosGetCardInfoDelta
(
int64_t
*
receive_bytes
,
int64_t
*
transmit_bytes
)
{
static
int64_t
last_receive_bytes
=
0
;
static
int64_t
last_transmit_bytes
=
0
;
static
int64_t
cur_receive_bytes
=
0
;
static
int64_t
cur_transmit_bytes
=
0
;
if
(
taosGetCardInfo
(
&
cur_receive_bytes
,
&
cur_transmit_bytes
)
==
0
)
{
...
...
@@ -701,6 +684,9 @@ void taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes) {
*
transmit_bytes
=
cur_transmit_bytes
-
last_transmit_bytes
;
last_receive_bytes
=
cur_receive_bytes
;
last_transmit_bytes
=
cur_transmit_bytes
;
}
else
{
*
receive_bytes
=
0
;
*
transmit_bytes
=
0
;
}
}
...
...
tests/script/tmp/monitor.sim
0 → 100644
浏览文件 @
7f3b1502
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c monitorfqdn -v localhost
system sh/cfg.sh -n dnode1 -c monitorport -v 80
system sh/cfg.sh -n dnode1 -c monitorInterval -v 1
system sh/cfg.sh -n dnode1 -c monitorComp -v 1
#system sh/cfg.sh -n dnode1 -c supportVnodes -v 128
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== show dnodes
sleep 2000
sql create database db vgroups 2;
sleep 2000
print =============== create drop qnode 1
sql create qnode on dnode 1
sql create snode on dnode 1
sql create bnode on dnode 1
return
print =============== restart
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
return
system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录