Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc82966e
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看板
提交
cc82966e
编写于
3月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
monitor
上级
7815a5e9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
285 addition
and
45 deletion
+285
-45
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+13
-8
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+25
-31
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+247
-6
未找到文件。
include/libs/monitor/monitor.h
浏览文件 @
cc82966e
...
...
@@ -23,6 +23,11 @@
extern
"C"
{
#endif
#define MON_STATUS_LEN 8
#define MON_ROLE_LEN 9
#define MON_VER_LEN 12
#define MON_LOG_LEN 1024
typedef
struct
{
int32_t
dnode_id
;
char
dnode_ep
[
TSDB_EP_LEN
];
...
...
@@ -31,19 +36,19 @@ typedef struct {
typedef
struct
{
int32_t
dnode_id
;
char
dnode_ep
[
TSDB_EP_LEN
];
char
status
[
8
];
char
status
[
MON_STATUS_LEN
];
}
SMonDnodeDesc
;
typedef
struct
{
int32_t
mnode_id
;
char
mnode_ep
[
TSDB_EP_LEN
];
char
role
[
8
];
char
role
[
MON_ROLE_LEN
];
}
SMonMnodeDesc
;
typedef
struct
{
char
first_ep
[
TSDB_EP_LEN
];
int32_t
first_ep_dnode_id
;
char
version
[
12
];
char
version
[
MON_VER_LEN
];
float
master_uptime
;
// day
int32_t
monitor_interval
;
// sec
int32_t
vgroups_total
;
...
...
@@ -57,18 +62,18 @@ typedef struct {
typedef
struct
{
int32_t
dnode_id
;
char
vnode_role
[
8
];
char
vnode_role
[
MON_ROLE_LEN
];
}
SMonVnodeDesc
;
typedef
struct
{
int32_t
vgroup_id
;
char
database_name
[
TSDB_DB_NAME_LEN
];
int32_t
tables_num
;
char
status
[
MON_STATUS_LEN
];
SMonVnodeDesc
vnodes
[
TSDB_MAX_REPLICA
];
}
SMonVgroupDesc
;
typedef
struct
{
char
database_name
[
TSDB_DB_NAME_LEN
];
int32_t
tables_num
;
char
status
[
10
];
SArray
*
vgroups
;
// array of SMonVgroupDesc
}
SMonVgroupInfo
;
...
...
@@ -124,7 +129,7 @@ typedef struct {
typedef
struct
{
int64_t
ts
;
int8_t
level
;
char
content
[
1024
];
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
typedef
struct
SMonInfo
SMonInfo
;
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
cc82966e
...
...
@@ -23,7 +23,7 @@
static
SMonitor
tsMonitor
=
{
0
};
int32_t
monInit
(
const
SMonCfg
*
pCfg
)
{
tsMonitor
.
logs
=
taosArrayInit
(
16
,
sizeof
(
SMon
Info
));
tsMonitor
.
logs
=
taosArrayInit
(
16
,
sizeof
(
SMon
LogItem
));
if
(
tsMonitor
.
logs
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -44,7 +44,7 @@ void monCleanup() {
void
monAddLogItem
(
SMonLogItem
*
pItem
)
{
taosWLockLatch
(
&
tsMonitor
.
lock
);
int32_t
size
=
taosArrayGetSize
(
tsMonitor
.
logs
);
if
(
size
>
tsMonitor
.
maxLogs
)
{
if
(
size
>
=
tsMonitor
.
maxLogs
)
{
uInfo
(
"too many logs for monitor"
);
}
else
{
taosArrayPush
(
tsMonitor
.
logs
,
pItem
);
...
...
@@ -118,9 +118,9 @@ void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
if
(
pDnodeJson
==
NULL
)
continue
;
SMonDnodeDesc
*
pDnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
if
(
tjsonAddDoubleToObject
(
pDnodesJson
,
"dnode_id"
,
pDnodeDesc
->
dnode_id
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
if
(
tjsonAddStringToObject
(
pDnodesJson
,
"dnode_ep"
,
pDnodeDesc
->
dnode_ep
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
if
(
tjsonAddStringToObject
(
pDnodesJson
,
"status"
,
pDnodeDesc
->
status
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
tjsonAddDoubleToObject
(
pDnodeJson
,
"dnode_id"
,
pDnodeDesc
->
dnode_id
);
tjsonAddStringToObject
(
pDnodeJson
,
"dnode_ep"
,
pDnodeDesc
->
dnode_ep
);
tjsonAddStringToObject
(
pDnodeJson
,
"status"
,
pDnodeDesc
->
status
);
if
(
tjsonAddItemToArray
(
pDnodesJson
,
pDnodeJson
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
}
...
...
@@ -133,48 +133,44 @@ void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
if
(
pMnodeJson
==
NULL
)
continue
;
SMonMnodeDesc
*
pMnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
if
(
tjsonAddDoubleToObject
(
pMnodesJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
if
(
tjsonAddStringToObject
(
pMnodesJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
if
(
tjsonAddStringToObject
(
pMnodesJson
,
"role"
,
pMnodeDesc
->
role
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
tjsonAddDoubleToObject
(
pMnodeJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
);
tjsonAddStringToObject
(
pMnodeJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
);
tjsonAddStringToObject
(
pMnodeJson
,
"role"
,
pMnodeDesc
->
role
);
if
(
tjsonAddItemToArray
(
pMnodesJson
,
pMnodeJson
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
}
}
void
monSetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
SJson
*
pJson
=
tjson
CreateObject
(
);
SJson
*
pJson
=
tjson
AddArrayToObject
(
pMonitor
->
pJson
,
"vgroup_infos"
);
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"vgroup_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddStringToObject
(
pJson
,
"database_name"
,
pInfo
->
database_name
);
tjsonAddDoubleToObject
(
pJson
,
"tables_num"
,
pInfo
->
tables_num
);
tjsonAddStringToObject
(
pJson
,
"status"
,
pInfo
->
status
);
SJson
*
pVgroupsJson
=
tjsonAddArrayToObject
(
pJson
,
"vgroups"
);
if
(
pVgroupsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
vgroups
);
++
i
)
{
SJson
*
pVgroupJson
=
tjsonCreateObject
();
if
(
pVgroupJson
==
NULL
)
continue
;
if
(
tjsonAddItemToArray
(
pJson
,
pVgroupJson
)
!=
0
)
{
tjsonDelete
(
pVgroupJson
);
continue
;
}
SMonVgroupDesc
*
pVgroupDesc
=
taosArrayGet
(
pInfo
->
vgroups
,
i
);
if
(
tjsonAddDoubleToObject
(
pVgroupJson
,
"vgroup_id"
,
pVgroupDesc
->
vgroup_id
)
!=
0
)
tjsonDelete
(
pVgroupJson
);
tjsonAddDoubleToObject
(
pVgroupJson
,
"vgroup_id"
,
pVgroupDesc
->
vgroup_id
);
tjsonAddStringToObject
(
pVgroupJson
,
"database_name"
,
pVgroupDesc
->
database_name
);
tjsonAddDoubleToObject
(
pVgroupJson
,
"tables_num"
,
pVgroupDesc
->
tables_num
);
tjsonAddStringToObject
(
pVgroupJson
,
"status"
,
pVgroupDesc
->
status
);
SJson
*
pVnodesJson
=
tjsonAddArrayToObject
(
pVgroupJson
,
"vnodes"
);
if
(
pVnodesJson
==
NULL
)
tjsonDelete
(
pVgroupJson
)
;
if
(
pVnodesJson
==
NULL
)
continue
;
for
(
int32_t
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
SMonVnodeDesc
*
pVnodeDesc
=
&
pVgroupDesc
->
vnodes
[
j
];
if
(
pVnodeDesc
[
j
].
dnode_id
<=
0
)
continue
;
if
(
pVnodeDesc
->
dnode_id
<=
0
)
continue
;
SJson
*
pVnodeJson
=
tjsonCreateObject
();
if
(
pVnodeJson
==
NULL
)
continue
;
if
(
tjsonAddDoubleToObject
(
pVnodeJson
,
"dnode_id"
,
pVnodeDesc
->
dnode_id
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
if
(
tjsonAddStringToObject
(
pVnodeJson
,
"vnode_role"
,
pVnodeDesc
->
vnode_role
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
tjsonAddDoubleToObject
(
pVnodeJson
,
"dnode_id"
,
pVnodeDesc
->
dnode_id
);
tjsonAddStringToObject
(
pVnodeJson
,
"vnode_role"
,
pVnodeDesc
->
vnode_role
);
if
(
tjsonAddItemToArray
(
pVnodesJson
,
pVnodeJson
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
}
...
...
@@ -235,7 +231,7 @@ void monSetDnodeInfo(SMonInfo *pMonitor, SMonDnodeInfo *pInfo) {
void
monSetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"disk
s
_infos"
,
pJson
)
!=
0
)
{
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"disk_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
...
...
@@ -261,7 +257,6 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
if
(
pLogdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"logdir"
,
pLogdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pLogdirJson
,
"name"
,
pInfo
->
logdir
.
name
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"level"
,
pInfo
->
logdir
.
level
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"avail"
,
pInfo
->
logdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"used"
,
pInfo
->
logdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"total"
,
pInfo
->
logdir
.
size
.
total
);
...
...
@@ -270,7 +265,6 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
if
(
pTempdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"tempdir"
,
pTempdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pTempdirJson
,
"name"
,
pInfo
->
tempdir
.
name
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"level"
,
pInfo
->
tempdir
.
level
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"avail"
,
pInfo
->
tempdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"used"
,
pInfo
->
tempdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
...
...
@@ -296,9 +290,9 @@ static void monSetLogInfo(SMonInfo *pMonitor) {
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
if
(
tjsonAddStringToObject
(
pLogItem
,
"ts"
,
buf
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddDoubleToObject
(
pLogItem
,
"level"
,
pLogItem
->
level
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddStringToObject
(
pLogItem
,
"content"
,
pLogItem
->
content
)
!=
0
)
tjsonDelete
(
pLogJson
);
tjsonAddStringToObject
(
pLogJson
,
"ts"
,
buf
);
tjsonAddDoubleToObject
(
pLogJson
,
"level"
,
pLogItem
->
level
);
tjsonAddStringToObject
(
pLogJson
,
"content"
,
pLogItem
->
content
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
}
...
...
source/libs/monitor/test/monTest.cpp
浏览文件 @
cc82966e
...
...
@@ -13,21 +13,262 @@
#include "os.h"
#include "monitor.h"
#include "tglobal.h"
class
MonitorTest
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
root
=
"/tmp/monTest"
;
}
static
void
TearDownTestSuite
()
{}
static
void
SetUpTestSuite
()
{
SMonCfg
cfg
;
cfg
.
maxLogs
=
2
;
cfg
.
port
=
80
;
cfg
.
server
=
"localhost"
;
monInit
(
&
cfg
);
}
static
void
TearDownTestSuite
()
{
monCleanup
();
}
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
static
const
char
*
root
;
void
GetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
);
void
GetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
);
void
GetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
);
void
GetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
);
void
GetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
);
void
GetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
);
void
AddLogInfo1
();
void
AddLogInfo2
();
};
const
char
*
MonitorTest
::
root
;
void
MonitorTest
::
GetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
pInfo
->
dnode_id
=
1
;
strcpy
(
pInfo
->
dnode_ep
,
"localhost"
);
}
void
MonitorTest
::
GetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
)
{
strcpy
(
pInfo
->
first_ep
,
"localhost:6030"
);
pInfo
->
first_ep_dnode_id
=
1
;
strcpy
(
pInfo
->
version
,
"3.0.0.0"
);
pInfo
->
master_uptime
=
1
;
pInfo
->
monitor_interval
=
2
;
pInfo
->
vgroups_total
=
3
;
pInfo
->
vgroups_alive
=
43
;
pInfo
->
vnodes_total
=
5
;
pInfo
->
vnodes_alive
=
6
;
pInfo
->
connections_total
=
7
;
pInfo
->
dnodes
=
taosArrayInit
(
4
,
sizeof
(
SMonDnodeDesc
));
SMonDnodeDesc
d1
=
{
0
};
d1
.
dnode_id
=
1
;
strcpy
(
d1
.
dnode_ep
,
"localhost:6030"
);
strcpy
(
d1
.
status
,
"ready"
);
taosArrayPush
(
pInfo
->
dnodes
,
&
d1
);
SMonDnodeDesc
d2
=
{
0
};
d2
.
dnode_id
=
2
;
strcpy
(
d2
.
dnode_ep
,
"localhost:7030"
);
strcpy
(
d2
.
status
,
"offline"
);
taosArrayPush
(
pInfo
->
dnodes
,
&
d2
);
pInfo
->
mnodes
=
taosArrayInit
(
4
,
sizeof
(
SMonMnodeDesc
));
SMonMnodeDesc
m1
=
{
0
};
m1
.
mnode_id
=
1
;
strcpy
(
m1
.
mnode_ep
,
"localhost:6030"
);
strcpy
(
m1
.
role
,
"master"
);
taosArrayPush
(
pInfo
->
mnodes
,
&
m1
);
SMonMnodeDesc
m2
=
{
0
};
m2
.
mnode_id
=
2
;
strcpy
(
m2
.
mnode_ep
,
"localhost:7030"
);
strcpy
(
m2
.
role
,
"unsynced"
);
taosArrayPush
(
pInfo
->
mnodes
,
&
m2
);
}
void
MonitorTest
::
GetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
pInfo
->
vgroups
=
taosArrayInit
(
4
,
sizeof
(
SMonVgroupDesc
));
SMonVgroupDesc
vg1
=
{
0
};
vg1
.
vgroup_id
=
1
;
strcpy
(
vg1
.
database_name
,
"d1"
);
vg1
.
tables_num
=
4
;
strcpy
(
vg1
.
status
,
"ready"
);
vg1
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg1
.
vnodes
[
0
].
vnode_role
,
"master"
);
vg1
.
vnodes
[
1
].
dnode_id
=
2
;
strcpy
(
vg1
.
vnodes
[
1
].
vnode_role
,
"slave"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg1
);
SMonVgroupDesc
vg2
=
{
0
};
vg2
.
vgroup_id
=
2
;
strcpy
(
vg2
.
database_name
,
"d2"
);
vg2
.
tables_num
=
5
;
strcpy
(
vg2
.
status
,
"offline"
);
vg2
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg2
.
vnodes
[
0
].
vnode_role
,
"master"
);
vg2
.
vnodes
[
1
].
dnode_id
=
2
;
strcpy
(
vg2
.
vnodes
[
1
].
vnode_role
,
"unsynced"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg2
);
SMonVgroupDesc
vg3
=
{
0
};
vg3
.
vgroup_id
=
3
;
strcpy
(
vg3
.
database_name
,
"d3"
);
vg3
.
tables_num
=
6
;
strcpy
(
vg3
.
status
,
"ready"
);
vg3
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg3
.
vnodes
[
0
].
vnode_role
,
"master"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg3
);
}
void
MonitorTest
::
GetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
)
{
pInfo
->
expire_time
=
1234567
;
pInfo
->
timeseries_total
=
234567
;
pInfo
->
timeseries_used
=
34567
;
}
void
MonitorTest
::
GetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
)
{
pInfo
->
uptime
=
1.2
;
pInfo
->
cpu_engine
=
2.1
;
pInfo
->
cpu_system
=
2.1
;
pInfo
->
cpu_cores
=
2
;
pInfo
->
mem_engine
=
3.1
;
pInfo
->
mem_system
=
3.2
;
pInfo
->
mem_total
=
3.3
;
pInfo
->
disk_engine
=
4.1
;
pInfo
->
disk_used
=
4.2
;
pInfo
->
disk_total
=
4.3
;
pInfo
->
net_in
=
5.1
;
pInfo
->
net_out
=
5.2
;
pInfo
->
io_read
=
6.1
;
pInfo
->
io_write
=
6.2
;
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
;
pInfo
->
has_mnode
=
1
;
}
void
MonitorTest
::
GetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
pInfo
->
datadirs
=
taosArrayInit
(
2
,
sizeof
(
SMonDiskDesc
));
SMonDiskDesc
d1
=
{
0
};
strcpy
(
d1
.
name
,
"/t1/d1/d"
);
d1
.
level
=
0
;
d1
.
size
.
avail
=
11
;
d1
.
size
.
total
=
12
;
d1
.
size
.
used
=
13
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d1
);
SMonDiskDesc
d2
=
{
0
};
strcpy
(
d2
.
name
,
"/t2d2/d"
);
d2
.
level
=
2
;
d2
.
size
.
avail
=
21
;
d2
.
size
.
total
=
22
;
d2
.
size
.
used
=
23
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d2
);
SMonDiskDesc
d3
=
{
0
};
strcpy
(
d3
.
name
,
"/t3/d3/d"
);
d3
.
level
=
3
;
d3
.
size
.
avail
=
31
;
d3
.
size
.
total
=
32
;
d3
.
size
.
used
=
33
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d3
);
strcpy
(
pInfo
->
logdir
.
name
,
"/log/dir/d"
);
pInfo
->
logdir
.
size
.
avail
=
41
;
pInfo
->
logdir
.
size
.
total
=
42
;
pInfo
->
logdir
.
size
.
used
=
43
;
strcpy
(
pInfo
->
tempdir
.
name
,
"/data/dir/d"
);
pInfo
->
tempdir
.
size
.
avail
=
51
;
pInfo
->
tempdir
.
size
.
total
=
52
;
pInfo
->
tempdir
.
size
.
used
=
53
;
}
void
MonitorTest
::
AddLogInfo1
()
{
SMonLogItem
log1
=
{
0
};
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
1
;
strcpy
(
log1
.
content
,
"1 -------------------------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
=
{
0
};
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
1
;
strcpy
(
log2
.
content
,
"1 ------------------------ b"
);
monAddLogItem
(
&
log2
);
SMonLogItem
log3
=
{
0
};
log3
.
ts
=
taosGetTimestampMs
();
log3
.
level
=
1
;
strcpy
(
log3
.
content
,
"1 ------- c"
);
monAddLogItem
(
&
log3
);
}
void
MonitorTest
::
AddLogInfo2
()
{
SMonLogItem
log1
;
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
01
;
strcpy
(
log1
.
content
,
"2 ------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
;
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
0
;
strcpy
(
log2
.
content
,
"2 ------- b"
);
monAddLogItem
(
&
log2
);
}
TEST_F
(
MonitorTest
,
01
_Full
)
{
AddLogInfo1
();
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
SMonBasicInfo
basicInfo
=
{
0
};
GetBasicInfo
(
pMonitor
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonGrantInfo
grantInfo
=
{
0
};
GetClusterInfo
(
pMonitor
,
&
clusterInfo
);
GetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
GetGrantInfo
(
pMonitor
,
&
grantInfo
);
monSetClusterInfo
(
pMonitor
,
&
clusterInfo
);
monSetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
SMonDnodeInfo
dnodeInfo
=
{
0
};
GetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
SMonDiskInfo
diskInfo
=
{
0
};
GetDiskInfo
(
pMonitor
,
&
diskInfo
);
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
taosArrayDestroy
(
clusterInfo
.
dnodes
);
taosArrayDestroy
(
clusterInfo
.
mnodes
);
taosArrayDestroy
(
vgroupInfo
.
vgroups
);
taosArrayDestroy
(
diskInfo
.
datadirs
);
}
TEST_F
(
MonitorTest
,
02
_Log
)
{
AddLogInfo2
();
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
TEST_F
(
MonitorTest
,
01
_Open_Close
)
{
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录