Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bef117d7
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看板
提交
bef117d7
编写于
3月 07, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable monitor gzip
上级
e6a68878
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
44 addition
and
22 deletion
+44
-22
include/common/tglobal.h
include/common/tglobal.h
+1
-0
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+1
-0
include/util/thttp.h
include/util/thttp.h
+3
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+3
-0
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+1
-1
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+1
-1
source/libs/monitor/inc/monInt.h
source/libs/monitor/inc/monInt.h
+1
-0
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+2
-1
source/util/src/thttp.c
source/util/src/thttp.c
+31
-18
未找到文件。
include/common/tglobal.h
浏览文件 @
bef117d7
...
...
@@ -58,6 +58,7 @@ extern int32_t tsMonitorInterval;
extern
char
tsMonitorFqdn
[];
extern
uint16_t
tsMonitorPort
;
extern
int32_t
tsMonitorMaxLogs
;
extern
bool
tsMonitorComp
;
// query buffer management
extern
int32_t
tsQueryBufferSize
;
// maximum allowed usage buffer size in MB for each data node during query processing
...
...
include/libs/monitor/monitor.h
浏览文件 @
bef117d7
...
...
@@ -130,6 +130,7 @@ typedef struct {
const
char
*
server
;
uint16_t
port
;
int32_t
maxLogs
;
bool
comp
;
}
SMonCfg
;
int32_t
monInit
(
const
SMonCfg
*
pCfg
);
...
...
include/util/thttp.h
浏览文件 @
bef117d7
...
...
@@ -22,7 +22,9 @@
extern
"C"
{
#endif
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
);
typedef
enum
{
HTTP_GZIP
,
HTTP_FLAT
}
EHttpCompFlag
;
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
);
#ifdef __cplusplus
}
...
...
source/common/src/tglobal.c
浏览文件 @
bef117d7
...
...
@@ -52,6 +52,7 @@ int32_t tsMonitorInterval = 5;
char
tsMonitorFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
uint16_t
tsMonitorPort
=
6043
;
int32_t
tsMonitorMaxLogs
=
100
;
bool
tsMonitorComp
=
false
;
/*
* denote if the server needs to compress response message at the application layer to client, including query rsp,
...
...
@@ -346,6 +347,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddString
(
pCfg
,
"monitorFqdn"
,
tsMonitorFqdn
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"monitorPort"
,
tsMonitorPort
,
1
,
65056
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"monitorMaxLogs"
,
tsMonitorMaxLogs
,
1
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"monitorComp"
,
tsMonitorComp
,
0
)
!=
0
)
return
-
1
;
return
0
;
}
...
...
@@ -462,6 +464,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tstrncpy
(
tsMonitorFqdn
,
cfgGetItem
(
pCfg
,
"monitorFqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsMonitorPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"monitorPort"
)
->
i32
;
tsMonitorMaxLogs
=
cfgGetItem
(
pCfg
,
"monitorMaxLogs"
)
->
i32
;
tsMonitorComp
=
cfgGetItem
(
pCfg
,
"monitorComp"
)
->
bval
;
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
bef117d7
...
...
@@ -298,7 +298,7 @@ int32_t dndInit() {
return
-
1
;
}
SMonCfg
monCfg
=
{.
maxLogs
=
tsMonitorMaxLogs
,
.
port
=
tsMonitorPort
,
.
server
=
tsMonitorFqdn
};
SMonCfg
monCfg
=
{.
maxLogs
=
tsMonitorMaxLogs
,
.
port
=
tsMonitorPort
,
.
server
=
tsMonitorFqdn
,
.
comp
=
tsMonitorComp
};
if
(
monInit
(
&
monCfg
)
!=
0
)
{
dError
(
"failed to init monitor since %s"
,
terrstr
());
dndCleanup
();
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
bef117d7
...
...
@@ -87,7 +87,7 @@ static int32_t mndProcessTelemTimer(SMnodeMsg* pReq) {
taosWLockLatch
(
&
pMgmt
->
lock
);
char
*
pCont
=
mndBuildTelemetryReport
(
pMnode
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
TELEMETRY_SERVER
,
TELEMETRY_PORT
,
pCont
,
strlen
(
pCont
));
taosSendHttpReport
(
TELEMETRY_SERVER
,
TELEMETRY_PORT
,
pCont
,
strlen
(
pCont
)
,
HTTP_FLAT
);
free
(
pCont
);
}
taosWUnLockLatch
(
&
pMgmt
->
lock
);
...
...
source/libs/monitor/inc/monInt.h
浏览文件 @
bef117d7
...
...
@@ -54,6 +54,7 @@ typedef struct {
int32_t
maxLogs
;
const
char
*
server
;
uint16_t
port
;
bool
comp
;
SMonState
state
;
}
SMonitor
;
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
bef117d7
...
...
@@ -45,6 +45,7 @@ int32_t monInit(const SMonCfg *pCfg) {
tsMonitor
.
maxLogs
=
pCfg
->
maxLogs
;
tsMonitor
.
server
=
pCfg
->
server
;
tsMonitor
.
port
=
pCfg
->
port
;
tsMonitor
.
comp
=
pCfg
->
comp
;
tsLogFp
=
monRecordLog
;
tsMonitor
.
state
.
time
=
taosGetTimestampMs
();
pthread_mutex_init
(
&
tsMonitor
.
lock
,
NULL
);
...
...
@@ -375,7 +376,7 @@ void monSendReport(SMonInfo *pMonitor) {
char
*
pCont
=
tjsonToString
(
pMonitor
->
pJson
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
));
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
)
,
tsMonitor
.
comp
);
free
(
pCont
);
}
}
source/util/src/thttp.c
浏览文件 @
bef117d7
...
...
@@ -18,6 +18,28 @@
#include "taoserror.h"
#include "tlog.h"
static
int32_t
taosBuildHttpHeader
(
const
char
*
server
,
int32_t
contLen
,
char
*
pHead
,
int32_t
headLen
,
EHttpCompFlag
flag
)
{
if
(
flag
==
HTTP_FLAT
)
{
return
snprintf
(
pHead
,
headLen
,
"POST /report HTTP/1.1
\n
"
"Host: %s
\n
"
"Content-Type: application/json
\n
"
"Content-Length: %d
\n\n
"
,
server
,
contLen
);
}
else
if
(
flag
==
HTTP_GZIP
)
{
return
snprintf
(
pHead
,
headLen
,
"POST /report HTTP/1.1
\n
"
"Host: %s
\n
"
"Content-Type: application/json
\n
"
"Content-Encoding: gzip
\n
"
"Content-Length: %d
\n\n
"
,
server
,
contLen
);
}
else
{
return
-
1
;
}
}
#ifdef USE_UV
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
if
(
status
<
0
)
{
...
...
@@ -36,7 +58,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
}
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
)
{
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
uint32_t
ipv4
=
taosGetIpv4FromFqdn
(
server
);
if
(
ipv4
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -50,18 +72,14 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, const char* pCont,
struct
sockaddr_in
dest
=
{
0
};
uv_ip4_addr
(
ipv4Buf
,
port
,
&
dest
);
uv_tcp_t
socket_tcp
=
{
0
};
uv_loop_t
*
loop
=
uv_default_loop
();
uv_tcp_t
socket_tcp
=
{
0
};
uv_loop_t
*
loop
=
uv_default_loop
();
uv_tcp_init
(
loop
,
&
socket_tcp
);
uv_connect_t
*
connect
=
(
uv_connect_t
*
)
malloc
(
sizeof
(
uv_connect_t
));
char
header
[
1024
]
=
{
0
};
int32_t
headLen
=
snprintf
(
header
,
sizeof
(
header
),
"POST /report HTTP/1.1
\n
"
"Host: %s
\n
"
"Content-Type: application/json
\n
"
"Content-Length: %d
\n\n
"
,
server
,
contLen
);
int32_t
headLen
=
taosBuildHttpHeader
(
server
,
contLen
,
header
,
sizeof
(
header
),
flag
);
uv_buf_t
wb
[
2
];
wb
[
0
]
=
uv_buf_init
((
char
*
)
header
,
headLen
);
wb
[
1
]
=
uv_buf_init
((
char
*
)
pCont
,
contLen
);
...
...
@@ -76,7 +94,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, const char* pCont,
}
#else
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
)
{
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
const
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
int32_t
code
=
-
1
;
SOCKET
fd
=
0
;
...
...
@@ -94,15 +112,10 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, const char* pCont,
goto
SEND_OVER
;
}
char
header
[
4096
]
=
{
0
};
int32_t
headLen
=
snprintf
(
header
,
sizeof
(
header
),
"POST /report HTTP/1.1
\n
"
"Host: %s
\n
"
"Content-Type: application/json
\n
"
"Content-Length: %d
\n\n
"
,
server
,
contLen
);
char
header
[
1024
]
=
{
0
};
int32_t
headLen
=
taosBuildHttpHeader
(
server
,
contLen
,
header
,
sizeof
(
header
),
flag
);
if
(
taosWriteSocket
(
fd
,
(
void
*
)
header
,
headLen
)
<
0
)
{
if
(
taosWriteSocket
(
fd
,
header
,
headLen
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to send http header to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录