Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
43057943
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
43057943
编写于
3月 05, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/TD-11463-3.0
上级
b158160b
13ecd2b7
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
134 addition
and
158 deletion
+134
-158
include/common/tmsg.h
include/common/tmsg.h
+5
-0
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+11
-14
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-3
source/dnode/mgmt/impl/inc/dndEnv.h
source/dnode/mgmt/impl/inc/dndEnv.h
+12
-3
source/dnode/mgmt/impl/inc/dndMnode.h
source/dnode/mgmt/impl/inc/dndMnode.h
+0
-1
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+12
-13
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+0
-7
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+27
-10
source/dnode/vnode/src/vnd/vnodeInt.c
source/dnode/vnode/src/vnd/vnodeInt.c
+5
-0
source/libs/monitor/inc/monInt.h
source/libs/monitor/inc/monInt.h
+18
-2
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+38
-13
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+0
-3
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+5
-89
未找到文件。
include/common/tmsg.h
浏览文件 @
43057943
...
...
@@ -671,6 +671,11 @@ typedef struct {
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
int64_t
numOfSelectReqs
;
int64_t
numOfInsertReqs
;
int64_t
numOfInsertSuccessReqs
;
int64_t
numOfBatchInsertReqs
;
int64_t
numOfBatchInsertSuccessReqs
;
}
SVnodeLoad
;
typedef
struct
{
...
...
include/libs/monitor/monitor.h
浏览文件 @
43057943
...
...
@@ -95,20 +95,17 @@ typedef struct {
int64_t
disk_engine
;
// Byte
int64_t
disk_used
;
// Byte
int64_t
disk_total
;
// Byte
double
net_in
;
// bytes per second
double
net_out
;
// bytes per second
double
io_read
;
double
io_write
;
double
io_read_disk
;
double
io_write_disk
;
int32_t
req_select
;
float
req_select_rate
;
int32_t
req_insert
;
int32_t
req_insert_success
;
float
req_insert_rate
;
int32_t
req_insert_batch
;
int32_t
req_insert_batch_success
;
float
req_insert_batch_rate
;
int64_t
net_in
;
// bytes
int64_t
net_out
;
// bytes
int64_t
io_read
;
// bytes
int64_t
io_write
;
// bytes
int64_t
io_read_disk
;
// bytes
int64_t
io_write_disk
;
// bytes
int64_t
req_select
;
int64_t
req_insert
;
int64_t
req_insert_success
;
int64_t
req_insert_batch
;
int64_t
req_insert_batch_success
;
int32_t
errors
;
int32_t
vnodes_num
;
int32_t
masters
;
...
...
include/os/osSysinfo.h
浏览文件 @
43057943
...
...
@@ -43,10 +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
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
);
int32_t
taosGetIOSpeed
(
double
*
readKB
,
double
*
writeKB
,
double
*
readDiskKB
,
double
*
writeDiskKB
);
int32_t
taosGetProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
);
int32_t
taosGetCardInfo
(
int64_t
*
receive_bytes
,
int64_t
*
transmit_bytes
);
int32_t
taosGetBandSpeed
(
double
*
receive_bytes_per_sec
,
double
*
transmit_bytes_per_sec
);
int32_t
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
...
...
source/dnode/mgmt/impl/inc/dndEnv.h
浏览文件 @
43057943
...
...
@@ -105,10 +105,19 @@ typedef struct {
}
SBnodeMgmt
;
typedef
struct
{
int32_t
openVnodes
;
int32_t
totalVnodes
;
int32_t
masterNum
;
int64_t
numOfSelectReqs
;
int64_t
numOfInsertReqs
;
int64_t
numOfInsertSuccessReqs
;
int64_t
numOfBatchInsertReqs
;
int64_t
numOfBatchInsertSuccessReqs
;
}
SVnodesStat
;
typedef
struct
{
SVnodesStat
stat
;
SHashObj
*
hash
;
int32_t
openVnodes
;
int32_t
totalVnodes
;
int32_t
masterNum
;
SRWLatch
latch
;
SQWorkerPool
queryPool
;
SFWorkerPool
fetchPool
;
...
...
source/dnode/mgmt/impl/inc/dndMnode.h
浏览文件 @
43057943
...
...
@@ -34,7 +34,6 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
int32_t
dndGetMnodeMonitorInfo
(
SDnode
*
pDnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
);
int8_t
dndIsMnode
(
SDnode
*
pDnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
43057943
...
...
@@ -489,20 +489,19 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
pInfo
->
disk_engine
=
0
;
pInfo
->
disk_used
=
tsDataSpace
.
size
.
used
;
pInfo
->
disk_total
=
tsDataSpace
.
size
.
total
;
taosGetBandSpeed
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetIOSpeed
(
&
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
;
pInfo
->
req_insert_success
=
0
;
pInfo
->
req_insert_rate
=
0
;
pInfo
->
req_insert_batch
=
0
;
pInfo
->
req_insert_batch_success
=
0
;
pInfo
->
req_insert_batch_rate
=
0
;
taosGetCardInfo
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
SVnodesStat
*
pStat
=
&
pDnode
->
vmgmt
.
stat
;
pInfo
->
req_select
=
pStat
->
numOfSelectReqs
;
pInfo
->
req_insert
=
pStat
->
numOfInsertReqs
;
pInfo
->
req_insert_success
=
pStat
->
numOfInsertSuccessReqs
;
pInfo
->
req_insert_batch
=
pStat
->
numOfBatchInsertReqs
;
pInfo
->
req_insert_batch_success
=
pStat
->
numOfBatchInsertSuccessReqs
;
pInfo
->
errors
=
tsNumOfErrorLogs
;
pInfo
->
vnodes_num
=
p
Dnode
->
vmgmt
.
totalVnodes
;
pInfo
->
masters
=
p
Dnode
->
vmgmt
.
masterNum
;
pInfo
->
has_mnode
=
dndIsMnode
(
pDnode
)
;
pInfo
->
vnodes_num
=
p
Stat
->
totalVnodes
;
pInfo
->
masters
=
p
Stat
->
masterNum
;
pInfo
->
has_mnode
=
pDnode
->
mmgmt
.
deployed
;
}
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
43057943
...
...
@@ -640,10 +640,3 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
dndReleaseMnode
(
pDnode
,
pMnode
);
return
code
;
}
int8_t
dndIsMnode
(
SDnode
*
pDnode
)
{
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
)
return
0
;
dndReleaseMnode
(
pDnode
,
pMnode
);
return
1
;
}
\ No newline at end of file
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
43057943
...
...
@@ -382,7 +382,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
char
stepDesc
[
TSDB_STEP_DESC_LEN
]
=
{
0
};
snprintf
(
stepDesc
,
TSDB_STEP_DESC_LEN
,
"vgId:%d, start to restore, %d of %d have been opened"
,
pCfg
->
vgId
,
pMgmt
->
openVnodes
,
pMgmt
->
totalVnodes
);
pMgmt
->
stat
.
openVnodes
,
pMgmt
->
stat
.
totalVnodes
);
dndReportStartup
(
pDnode
,
"open-vnodes"
,
stepDesc
);
SVnodeCfg
cfg
=
{.
pDnode
=
pDnode
,
.
pTfs
=
pDnode
->
pTfs
,
.
vgId
=
pCfg
->
vgId
,
.
dbId
=
pCfg
->
dbUid
};
...
...
@@ -396,7 +396,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
pThread
->
opened
++
;
}
atomic_add_fetch_32
(
&
pMgmt
->
openVnodes
,
1
);
atomic_add_fetch_32
(
&
pMgmt
->
stat
.
openVnodes
,
1
);
}
dDebug
(
"thread:%d, total vnodes:%d, opened:%d failed:%d"
,
pThread
->
threadIndex
,
pThread
->
vnodeNum
,
pThread
->
opened
,
...
...
@@ -422,7 +422,7 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
return
-
1
;
}
pMgmt
->
totalVnodes
=
numOfVnodes
;
pMgmt
->
stat
.
totalVnodes
=
numOfVnodes
;
int32_t
threadNum
=
tsNumOfCores
;
#if 1
...
...
@@ -470,11 +470,11 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
free
(
threads
);
free
(
pCfgs
);
if
(
pMgmt
->
openVnodes
!=
pMgmt
->
totalVnodes
)
{
dError
(
"there are total vnodes:%d, opened:%d"
,
pMgmt
->
totalVnodes
,
pMgmt
->
openVnodes
);
if
(
pMgmt
->
stat
.
openVnodes
!=
pMgmt
->
stat
.
totalVnodes
)
{
dError
(
"there are total vnodes:%d, opened:%d"
,
pMgmt
->
stat
.
totalVnodes
,
pMgmt
->
stat
.
openVnodes
);
return
-
1
;
}
else
{
dInfo
(
"total vnodes:%d open successfully"
,
pMgmt
->
totalVnodes
);
dInfo
(
"total vnodes:%d open successfully"
,
pMgmt
->
stat
.
totalVnodes
);
return
0
;
}
}
...
...
@@ -980,13 +980,18 @@ void dndCleanupVnodes(SDnode *pDnode) {
void
dndGetVnodeLoads
(
SDnode
*
pDnode
,
SArray
*
pLoads
)
{
SVnodesMgmt
*
pMgmt
=
&
pDnode
->
vmgmt
;
SVnodesStat
*
pStat
=
&
pMgmt
->
stat
;
int32_t
totalVnodes
=
0
;
int32_t
masterNum
=
0
;
int64_t
numOfSelectReqs
=
0
;
int64_t
numOfInsertReqs
=
0
;
int64_t
numOfInsertSuccessReqs
=
0
;
int64_t
numOfBatchInsertReqs
=
0
;
int64_t
numOfBatchInsertSuccessReqs
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
int32_t
v
=
0
;
void
*
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
ppVnode
=
pIter
;
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
continue
;
...
...
@@ -996,12 +1001,24 @@ void dndGetVnodeLoads(SDnode *pDnode, SArray *pLoads) {
vnodeGetLoad
(
pVnode
->
pImpl
,
&
vload
);
taosArrayPush
(
pLoads
,
&
vload
);
numOfSelectReqs
+=
vload
.
numOfSelectReqs
;
numOfInsertReqs
+=
vload
.
numOfInsertReqs
;
numOfInsertSuccessReqs
+=
vload
.
numOfInsertSuccessReqs
;
numOfBatchInsertReqs
+=
vload
.
numOfBatchInsertReqs
;
numOfBatchInsertSuccessReqs
+=
vload
.
numOfBatchInsertSuccessReqs
;
totalVnodes
++
;
if
(
vload
.
role
==
TAOS_SYNC_STATE_LEADER
)
masterNum
++
;
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
totalVnodes
=
totalVnodes
;
pMgmt
->
masterNum
=
masterNum
;
pStat
->
totalVnodes
=
totalVnodes
;
pStat
->
masterNum
=
masterNum
;
pStat
->
numOfSelectReqs
=
numOfSelectReqs
;
pStat
->
numOfInsertReqs
=
numOfInsertReqs
;
pStat
->
numOfInsertSuccessReqs
=
numOfInsertSuccessReqs
;
pStat
->
numOfBatchInsertReqs
=
numOfBatchInsertReqs
;
pStat
->
numOfBatchInsertSuccessReqs
=
numOfBatchInsertSuccessReqs
;
}
source/dnode/vnode/src/vnd/vnodeInt.c
浏览文件 @
43057943
...
...
@@ -32,6 +32,11 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
pLoad
->
totalStorage
=
300
;
pLoad
->
compStorage
=
200
;
pLoad
->
pointsWritten
=
100
;
pLoad
->
numOfSelectReqs
=
1
;
pLoad
->
numOfInsertReqs
=
3
;
pLoad
->
numOfInsertSuccessReqs
=
2
;
pLoad
->
numOfBatchInsertReqs
=
5
;
pLoad
->
numOfBatchInsertSuccessReqs
=
4
;
return
0
;
}
...
...
source/libs/monitor/inc/monInt.h
浏览文件 @
43057943
...
...
@@ -28,9 +28,24 @@ typedef struct {
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
typedef
struct
{
int64_t
time
;
int64_t
req_select
;
int64_t
req_insert
;
int64_t
req_insert_batch
;
int64_t
net_in
;
int64_t
net_out
;
int64_t
io_read
;
int64_t
io_write
;
int64_t
io_read_disk
;
int64_t
io_write_disk
;
}
SMonState
;
typedef
struct
SMonInfo
{
SArray
*
logs
;
// array of SMonLogItem
SJson
*
pJson
;
int64_t
curTime
;
SMonState
lastState
;
SArray
*
logs
;
// array of SMonLogItem
SJson
*
pJson
;
}
SMonInfo
;
typedef
struct
{
...
...
@@ -39,6 +54,7 @@ typedef struct {
int32_t
maxLogs
;
const
char
*
server
;
uint16_t
port
;
SMonState
state
;
}
SMonitor
;
#ifdef __cplusplus
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
43057943
...
...
@@ -46,6 +46,7 @@ int32_t monInit(const SMonCfg *pCfg) {
tsMonitor
.
server
=
pCfg
->
server
;
tsMonitor
.
port
=
pCfg
->
port
;
tsLogFp
=
monRecordLog
;
tsMonitor
.
state
.
time
=
taosGetTimestampMs
();
pthread_mutex_init
(
&
tsMonitor
.
lock
,
NULL
);
return
0
;
}
...
...
@@ -76,20 +77,23 @@ SMonInfo *monCreateMonitorInfo() {
return
NULL
;
}
pMonitor
->
curTime
=
taosGetTimestampMs
();
pMonitor
->
lastState
=
tsMonitor
.
state
;
return
pMonitor
;
}
void
monCleanupMonitorInfo
(
SMonInfo
*
pMonitor
)
{
tsMonitor
.
state
=
pMonitor
->
lastState
;
tsMonitor
.
state
.
time
=
pMonitor
->
curTime
;
taosArrayDestroy
(
pMonitor
->
logs
);
tjsonDelete
(
pMonitor
->
pJson
);
free
(
pMonitor
);
}
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
SJson
*
pJson
=
pMonitor
->
pJson
;
int64_t
ms
=
taosGetTimestampMs
();
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
ms
,
TSDB_TIME_PRECISION_MILLI
);
SJson
*
pJson
=
pMonitor
->
pJson
;
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pMonitor
->
curTime
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pJson
,
"ts"
,
buf
);
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
...
...
@@ -203,6 +207,27 @@ void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
return
;
}
SMonState
*
pLast
=
&
pMonitor
->
lastState
;
double
interval
=
(
pMonitor
->
curTime
-
pLast
->
time
)
/
1000
.
0
;
double
req_select_rate
=
(
pInfo
->
req_select
-
pLast
->
req_select
)
/
interval
;
double
req_insert_rate
=
(
pInfo
->
req_insert
-
pLast
->
req_insert
)
/
interval
;
double
req_insert_batch_rate
=
(
pInfo
->
req_insert_batch
-
pLast
->
req_insert_batch
)
/
interval
;
double
net_in_rate
=
(
pInfo
->
net_in
-
pLast
->
net_in
)
/
interval
;
double
net_out_rate
=
(
pInfo
->
net_out
-
pLast
->
net_out
)
/
interval
;
double
io_read_rate
=
(
pInfo
->
io_read
-
pLast
->
io_read
)
/
interval
;
double
io_write_rate
=
(
pInfo
->
io_write
-
pLast
->
io_write
)
/
interval
;
double
io_read_disk_rate
=
(
pInfo
->
io_read_disk
-
pLast
->
io_read_disk
)
/
interval
;
double
io_write_disk_rate
=
(
pInfo
->
io_write_disk
-
pLast
->
io_write_disk
)
/
interval
;
pLast
->
req_select
=
pInfo
->
req_select
;
pLast
->
req_insert
=
pInfo
->
req_insert
;
pLast
->
req_insert_batch
=
pInfo
->
req_insert_batch
;
pLast
->
net_in
=
pInfo
->
net_in
;
pLast
->
net_out
=
pInfo
->
net_out
;
pLast
->
io_read
=
pInfo
->
io_read
;
pLast
->
io_write
=
pInfo
->
io_write
;
pLast
->
io_read_disk
=
pInfo
->
io_read_disk
;
pLast
->
io_write_disk
=
pInfo
->
io_write_disk
;
tjsonAddDoubleToObject
(
pJson
,
"uptime"
,
pInfo
->
uptime
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_engine"
,
pInfo
->
cpu_engine
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_system"
,
pInfo
->
cpu_system
);
...
...
@@ -213,20 +238,20 @@ void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
tjsonAddDoubleToObject
(
pJson
,
"disk_engine"
,
pInfo
->
disk_engine
);
tjsonAddDoubleToObject
(
pJson
,
"disk_used"
,
pInfo
->
disk_used
);
tjsonAddDoubleToObject
(
pJson
,
"disk_total"
,
pInfo
->
disk_total
);
tjsonAddDoubleToObject
(
pJson
,
"net_in"
,
pInfo
->
net_in
);
tjsonAddDoubleToObject
(
pJson
,
"net_out"
,
pInfo
->
net_out
);
tjsonAddDoubleToObject
(
pJson
,
"io_read"
,
pInfo
->
io_read
);
tjsonAddDoubleToObject
(
pJson
,
"io_write"
,
pInfo
->
io_wri
te
);
tjsonAddDoubleToObject
(
pJson
,
"io_read_disk"
,
pInfo
->
io_read_disk
);
tjsonAddDoubleToObject
(
pJson
,
"io_write_disk"
,
pInfo
->
io_write_disk
);
tjsonAddDoubleToObject
(
pJson
,
"net_in"
,
net_in_rate
);
tjsonAddDoubleToObject
(
pJson
,
"net_out"
,
net_out_rate
);
tjsonAddDoubleToObject
(
pJson
,
"io_read"
,
io_read_rate
);
tjsonAddDoubleToObject
(
pJson
,
"io_write"
,
io_write_ra
te
);
tjsonAddDoubleToObject
(
pJson
,
"io_read_disk"
,
io_read_disk_rate
);
tjsonAddDoubleToObject
(
pJson
,
"io_write_disk"
,
io_write_disk_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_select"
,
pInfo
->
req_select
);
tjsonAddDoubleToObject
(
pJson
,
"req_select_rate"
,
pInfo
->
req_select_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_select_rate"
,
req_select_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert"
,
pInfo
->
req_insert
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_success"
,
pInfo
->
req_insert_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_rate"
,
pInfo
->
req_insert_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_rate"
,
req_insert_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch"
,
pInfo
->
req_insert_batch
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_success"
,
pInfo
->
req_insert_batch_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_rate"
,
pInfo
->
req_insert_batch_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_rate"
,
req_insert_batch_rate
);
tjsonAddDoubleToObject
(
pJson
,
"errors"
,
pInfo
->
errors
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_num"
,
pInfo
->
vnodes_num
);
tjsonAddDoubleToObject
(
pJson
,
"masters"
,
pInfo
->
masters
);
...
...
source/libs/monitor/test/monTest.cpp
浏览文件 @
43057943
...
...
@@ -142,13 +142,10 @@ void MonitorTest::GetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
pInfo
->
io_read_disk
=
7.1
;
pInfo
->
io_write_disk
=
7.2
;
pInfo
->
req_select
=
8
;
pInfo
->
req_select_rate
=
8.1
;
pInfo
->
req_insert
=
9
;
pInfo
->
req_insert_success
=
10
;
pInfo
->
req_insert_rate
=
10.1
;
pInfo
->
req_insert_batch
=
11
;
pInfo
->
req_insert_batch_success
=
12
;
pInfo
->
req_insert_batch_rate
=
12.3
;
pInfo
->
errors
=
4
;
pInfo
->
vnodes_num
=
5
;
pInfo
->
masters
=
6
;
...
...
source/os/src/osSysinfo.c
浏览文件 @
43057943
...
...
@@ -118,7 +118,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
return
0
;
}
int32_t
taos
Read
ProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
int32_t
taos
Get
ProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
IO_COUNTERS
io_counter
;
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
rchars
)
*
rchars
=
io_counter
.
ReadTransferCount
;
...
...
@@ -135,9 +135,7 @@ void taosGetSystemInfo() {
taosGetTotalMemory
(
&
tsTotalMemoryKB
);
double
tmp1
,
tmp2
,
tmp3
,
tmp4
;
taosGetBandSpeed
(
&
tmp1
,
&
tmp2
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetIOSpeed
(
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
tmp4
);
}
void
taosKillSystem
()
{
...
...
@@ -227,7 +225,7 @@ void taosGetSystemInfo() {
tsNumOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
int32_t
taos
Read
ProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
int32_t
taos
Get
ProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
if
(
rchars
)
*
rchars
=
0
;
if
(
wchars
)
*
wchars
=
0
;
if
(
read_bytes
)
*
read_bytes
=
0
;
...
...
@@ -336,7 +334,7 @@ static char tsProcCpuFile[25] = {0};
static
char
tsProcMemFile
[
25
]
=
{
0
};
static
char
tsProcIOFile
[
25
]
=
{
0
};
static
void
taosGetProcInfos
()
{
static
void
taosGetProcI
O
nfos
()
{
tsPageSizeKB
=
sysconf
(
_SC_PAGESIZE
)
/
1024
;
tsOpenMax
=
sysconf
(
_SC_OPEN_MAX
);
tsStreamMax
=
sysconf
(
_SC_STREAM_MAX
);
...
...
@@ -544,41 +542,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
return
0
;
}
int32_t
taosGetBandSpeed
(
double
*
receive_bytes_per_sec
,
double
*
transmit_bytes_per_sec
)
{
static
int64_t
last_receive_bytes
=
0
;
static
int64_t
last_transmit_bytes
=
0
;
static
int64_t
last_time
=
0
;
int64_t
cur_receive_bytes
=
0
;
int64_t
cur_transmit_bytes
=
0
;
int64_t
cur_time
=
taosGetTimestampMs
();
if
(
taosGetCardInfo
(
&
cur_receive_bytes
,
&
cur_transmit_bytes
)
!=
0
)
{
return
-
1
;
}
if
(
last_time
==
0
||
last_time
>=
cur_time
)
{
last_time
=
cur_time
;
last_receive_bytes
=
cur_receive_bytes
;
last_transmit_bytes
=
cur_transmit_bytes
;
*
receive_bytes_per_sec
=
0
;
*
transmit_bytes_per_sec
=
0
;
return
0
;
}
*
receive_bytes_per_sec
=
(
cur_receive_bytes
-
last_receive_bytes
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
*
transmit_bytes_per_sec
=
(
cur_transmit_bytes
-
last_transmit_bytes
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
last_time
=
cur_time
;
last_transmit_bytes
=
cur_transmit_bytes
;
last_receive_bytes
=
cur_receive_bytes
;
if
(
*
receive_bytes_per_sec
<
0
)
*
receive_bytes_per_sec
=
0
;
if
(
*
transmit_bytes_per_sec
<
0
)
*
transmit_bytes_per_sec
=
0
;
return
0
;
}
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_bytes
)
{
int32_t
taosGetProcIO
(
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
)
return
-
1
;
...
...
@@ -620,61 +584,13 @@ int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, in
return
0
;
}
int32_t
taosGetIOSpeed
(
double
*
rchar_per_sec
,
double
*
wchar_per_sec
,
double
*
read_bytes_per_sec
,
double
*
write_bytes_per_sec
)
{
static
int64_t
last_rchar
=
-
1
;
static
int64_t
last_wchar
=
-
1
;
static
int64_t
last_read_bytes
=
-
1
;
static
int64_t
last_write_bytes
=
-
1
;
static
int64_t
last_time
=
0
;
int64_t
cur_rchar
=
0
;
int64_t
cur_wchar
=
0
;
int64_t
cur_read_bytes
=
0
;
int64_t
cur_write_bytes
=
0
;
int64_t
cur_time
=
taosGetTimestampMs
();
if
(
taosReadProcIO
(
&
cur_rchar
,
&
cur_wchar
,
&
cur_read_bytes
,
&
cur_write_bytes
)
!=
0
)
{
return
-
1
;
}
if
(
last_time
==
0
||
last_time
>=
cur_time
)
{
last_time
=
cur_time
;
last_rchar
=
cur_rchar
;
last_wchar
=
cur_wchar
;
last_read_bytes
=
cur_read_bytes
;
last_write_bytes
=
cur_write_bytes
;
return
-
1
;
}
*
rchar_per_sec
=
(
cur_rchar
-
last_rchar
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
*
wchar_per_sec
=
(
cur_wchar
-
last_wchar
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
*
read_bytes_per_sec
=
(
cur_read_bytes
-
last_read_bytes
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
*
write_bytes_per_sec
=
(
cur_write_bytes
-
last_write_bytes
)
/
(
double
)(
cur_time
-
last_time
)
*
1000
;
last_time
=
cur_time
;
last_rchar
=
cur_rchar
;
last_wchar
=
cur_wchar
;
last_read_bytes
=
cur_read_bytes
;
last_write_bytes
=
cur_write_bytes
;
if
(
*
rchar_per_sec
<
0
)
*
rchar_per_sec
=
0
;
if
(
*
wchar_per_sec
<
0
)
*
wchar_per_sec
=
0
;
if
(
*
read_bytes_per_sec
<
0
)
*
read_bytes_per_sec
=
0
;
if
(
*
write_bytes_per_sec
<
0
)
*
write_bytes_per_sec
=
0
;
return
0
;
}
void
taosGetSystemInfo
()
{
taosGetProcInfos
();
taosGetProcI
O
nfos
();
taosGetCpuCores
(
&
tsNumOfCores
);
taosGetTotalMemory
(
&
tsTotalMemoryKB
);
double
tmp1
,
tmp2
,
tmp3
,
tmp4
;
taosGetBandSpeed
(
&
tmp1
,
&
tmp2
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetIOSpeed
(
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
tmp4
);
}
void
taosKillSystem
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录