Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3f592b7b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
3f592b7b
编写于
10月 25, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10430] move telem from dnode to mnode
上级
3b1add19
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
70 deletion
+66
-70
source/server/dnode/src/dnodeCheck.c
source/server/dnode/src/dnodeCheck.c
+0
-2
source/server/dnode/src/dnodeInt.c
source/server/dnode/src/dnodeInt.c
+0
-2
source/server/mnode/inc/mnodeDef.h
source/server/mnode/inc/mnodeDef.h
+1
-0
source/server/mnode/inc/mnodeTelem.h
source/server/mnode/inc/mnodeTelem.h
+6
-6
source/server/mnode/src/mnodeTelem.c
source/server/mnode/src/mnodeTelem.c
+57
-60
source/server/mnode/src/mondeInt.c
source/server/mnode/src/mondeInt.c
+2
-0
未找到文件。
source/server/dnode/src/dnodeCheck.c
浏览文件 @
3f592b7b
...
...
@@ -14,8 +14,6 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "dnodeCheck.h"
#define MIN_AVAIL_MEMORY_MB 32
...
...
source/server/dnode/src/dnodeInt.c
浏览文件 @
3f592b7b
...
...
@@ -28,7 +28,6 @@
#include "dnodeMain.h"
#include "dnodeMnodeEps.h"
#include "dnodeStatus.h"
#include "dnodeTelem.h"
#include "dnodeTrans.h"
#include "mnode.h"
#include "vnode.h"
...
...
@@ -73,7 +72,6 @@ int32_t dnodeInit() {
taosStepAdd
(
tsSteps
,
"dnode-mnode"
,
dnodeInitMnodeModule
,
mnodeCleanup
);
taosStepAdd
(
tsSteps
,
"dnode-trans"
,
dnodeInitTrans
,
dnodeCleanupTrans
);
taosStepAdd
(
tsSteps
,
"dnode-status"
,
dnodeInitStatus
,
dnodeCleanupStatus
);
taosStepAdd
(
tsSteps
,
"dnode-telem"
,
dnodeInitTelem
,
dnodeCleanupTelem
);
//taosStepAdd(tsSteps, "dnode-script",scriptEnvPoolInit, scriptEnvPoolCleanup);
taosStepExec
(
tsSteps
);
...
...
source/server/mnode/inc/mnodeDef.h
浏览文件 @
3f592b7b
...
...
@@ -16,6 +16,7 @@
#ifndef _TD_MNODE_DEF_H_
#define _TD_MNODE_DEF_H_
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
...
...
source/server/
dnode/inc/d
nodeTelem.h
→
source/server/
mnode/inc/m
nodeTelem.h
浏览文件 @
3f592b7b
...
...
@@ -13,19 +13,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_
D
NODE_TELEMETRY_H_
#define _TD_
D
NODE_TELEMETRY_H_
#ifndef _TD_
M
NODE_TELEMETRY_H_
#define _TD_
M
NODE_TELEMETRY_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include "
d
nodeInt.h"
#include "
m
nodeInt.h"
int32_t
d
nodeInitTelem
();
void
d
nodeCleanupTelem
();
int32_t
m
nodeInitTelem
();
void
m
nodeCleanupTelem
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_
D
NODE_TELEMETRY_H_*/
#endif
/*_TD_
M
NODE_TELEMETRY_H_*/
source/server/
dnode/src/d
nodeTelem.c
→
source/server/
mnode/src/m
nodeTelem.c
浏览文件 @
3f592b7b
...
...
@@ -14,12 +14,9 @@
*/
#define _DEFAULT_SOURCE
#include "
os
.h"
#include "
mnodeTelem
.h"
#include "tbuffer.h"
#include "tglobal.h"
#include "dnodeCfg.h"
#include "dnodeTelem.h"
#include "mnode.h"
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_PORT 80
...
...
@@ -38,9 +35,9 @@ static struct {
char
email
[
TSDB_FQDN_LEN
];
}
tsTelem
;
static
void
d
nodeBeginObject
(
SBufferWriter
*
bw
)
{
tbufWriteChar
(
bw
,
'{'
);
}
static
void
m
nodeBeginObject
(
SBufferWriter
*
bw
)
{
tbufWriteChar
(
bw
,
'{'
);
}
static
void
d
nodeCloseObject
(
SBufferWriter
*
bw
)
{
static
void
m
nodeCloseObject
(
SBufferWriter
*
bw
)
{
size_t
len
=
tbufTell
(
bw
);
if
(
tbufGetData
(
bw
,
false
)[
len
-
1
]
==
','
)
{
tbufWriteCharAt
(
bw
,
len
-
1
,
'}'
);
...
...
@@ -66,14 +63,14 @@ static void closeArray(SBufferWriter* bw) {
}
#endif
static
void
d
nodeWriteString
(
SBufferWriter
*
bw
,
const
char
*
str
)
{
static
void
m
nodeWriteString
(
SBufferWriter
*
bw
,
const
char
*
str
)
{
tbufWriteChar
(
bw
,
'"'
);
tbufWrite
(
bw
,
str
,
strlen
(
str
));
tbufWriteChar
(
bw
,
'"'
);
}
static
void
d
nodeAddIntField
(
SBufferWriter
*
bw
,
const
char
*
k
,
int64_t
v
)
{
d
nodeWriteString
(
bw
,
k
);
static
void
m
nodeAddIntField
(
SBufferWriter
*
bw
,
const
char
*
k
,
int64_t
v
)
{
m
nodeWriteString
(
bw
,
k
);
tbufWriteChar
(
bw
,
':'
);
char
buf
[
32
];
sprintf
(
buf
,
"%"
PRId64
,
v
);
...
...
@@ -81,14 +78,14 @@ static void dnodeAddIntField(SBufferWriter* bw, const char* k, int64_t v) {
tbufWriteChar
(
bw
,
','
);
}
static
void
d
nodeAddStringField
(
SBufferWriter
*
bw
,
const
char
*
k
,
const
char
*
v
)
{
d
nodeWriteString
(
bw
,
k
);
static
void
m
nodeAddStringField
(
SBufferWriter
*
bw
,
const
char
*
k
,
const
char
*
v
)
{
m
nodeWriteString
(
bw
,
k
);
tbufWriteChar
(
bw
,
':'
);
d
nodeWriteString
(
bw
,
v
);
m
nodeWriteString
(
bw
,
v
);
tbufWriteChar
(
bw
,
','
);
}
static
void
d
nodeAddCpuInfo
(
SBufferWriter
*
bw
)
{
static
void
m
nodeAddCpuInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
int32_t
done
=
0
;
...
...
@@ -102,11 +99,11 @@ static void dnodeAddCpuInfo(SBufferWriter* bw) {
line
[
size
-
1
]
=
'\0'
;
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
d
nodeAddStringField
(
bw
,
"cpuModel"
,
v
);
m
nodeAddStringField
(
bw
,
"cpuModel"
,
v
);
done
|=
1
;
}
else
if
(((
done
&
2
)
==
0
)
&&
strncmp
(
line
,
"cpu cores"
,
9
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
d
nodeWriteString
(
bw
,
"numOfCpu"
);
m
nodeWriteString
(
bw
,
"numOfCpu"
);
tbufWriteChar
(
bw
,
':'
);
tbufWrite
(
bw
,
v
,
strlen
(
v
));
tbufWriteChar
(
bw
,
','
);
...
...
@@ -118,7 +115,7 @@ static void dnodeAddCpuInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
d
nodeAddOsInfo
(
SBufferWriter
*
bw
)
{
static
void
m
nodeAddOsInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
...
...
@@ -135,7 +132,7 @@ static void dnodeAddOsInfo(SBufferWriter* bw) {
p
++
;
line
[
size
-
2
]
=
0
;
}
d
nodeAddStringField
(
bw
,
"os"
,
p
);
m
nodeAddStringField
(
bw
,
"os"
,
p
);
break
;
}
}
...
...
@@ -144,7 +141,7 @@ static void dnodeAddOsInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
d
nodeAddMemoryInfo
(
SBufferWriter
*
bw
)
{
static
void
m
nodeAddMemoryInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
...
...
@@ -158,7 +155,7 @@ static void dnodeAddMemoryInfo(SBufferWriter* bw) {
if
(
strncmp
(
line
,
"MemTotal"
,
8
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
':'
)
+
1
;
while
(
*
p
==
' '
)
p
++
;
d
nodeAddStringField
(
bw
,
"memory"
,
p
);
m
nodeAddStringField
(
bw
,
"memory"
,
p
);
break
;
}
}
...
...
@@ -167,57 +164,57 @@ static void dnodeAddMemoryInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
d
nodeAddVersionInfo
(
SBufferWriter
*
bw
)
{
d
nodeAddStringField
(
bw
,
"version"
,
version
);
d
nodeAddStringField
(
bw
,
"buildInfo"
,
buildinfo
);
d
nodeAddStringField
(
bw
,
"gitInfo"
,
gitinfo
);
d
nodeAddStringField
(
bw
,
"email"
,
tsTelem
.
email
);
static
void
m
nodeAddVersionInfo
(
SBufferWriter
*
bw
)
{
m
nodeAddStringField
(
bw
,
"version"
,
version
);
m
nodeAddStringField
(
bw
,
"buildInfo"
,
buildinfo
);
m
nodeAddStringField
(
bw
,
"gitInfo"
,
gitinfo
);
m
nodeAddStringField
(
bw
,
"email"
,
tsTelem
.
email
);
}
static
void
d
nodeAddRuntimeInfo
(
SBufferWriter
*
bw
)
{
static
void
m
nodeAddRuntimeInfo
(
SBufferWriter
*
bw
)
{
SMnodeStat
stat
=
{
0
};
if
(
mnodeGetStatistics
(
&
stat
)
!=
0
)
{
return
;
}
d
nodeAddIntField
(
bw
,
"numOfDnode"
,
stat
.
numOfDnode
);
d
nodeAddIntField
(
bw
,
"numOfMnode"
,
stat
.
numOfMnode
);
d
nodeAddIntField
(
bw
,
"numOfVgroup"
,
stat
.
numOfVgroup
);
d
nodeAddIntField
(
bw
,
"numOfDatabase"
,
stat
.
numOfDatabase
);
d
nodeAddIntField
(
bw
,
"numOfSuperTable"
,
stat
.
numOfSuperTable
);
d
nodeAddIntField
(
bw
,
"numOfChildTable"
,
stat
.
numOfChildTable
);
d
nodeAddIntField
(
bw
,
"numOfColumn"
,
stat
.
numOfColumn
);
d
nodeAddIntField
(
bw
,
"numOfPoint"
,
stat
.
totalPoints
);
d
nodeAddIntField
(
bw
,
"totalStorage"
,
stat
.
totalStorage
);
d
nodeAddIntField
(
bw
,
"compStorage"
,
stat
.
compStorage
);
m
nodeAddIntField
(
bw
,
"numOfDnode"
,
stat
.
numOfDnode
);
m
nodeAddIntField
(
bw
,
"numOfMnode"
,
stat
.
numOfMnode
);
m
nodeAddIntField
(
bw
,
"numOfVgroup"
,
stat
.
numOfVgroup
);
m
nodeAddIntField
(
bw
,
"numOfDatabase"
,
stat
.
numOfDatabase
);
m
nodeAddIntField
(
bw
,
"numOfSuperTable"
,
stat
.
numOfSuperTable
);
m
nodeAddIntField
(
bw
,
"numOfChildTable"
,
stat
.
numOfChildTable
);
m
nodeAddIntField
(
bw
,
"numOfColumn"
,
stat
.
numOfColumn
);
m
nodeAddIntField
(
bw
,
"numOfPoint"
,
stat
.
totalPoints
);
m
nodeAddIntField
(
bw
,
"totalStorage"
,
stat
.
totalStorage
);
m
nodeAddIntField
(
bw
,
"compStorage"
,
stat
.
compStorage
);
}
static
void
d
nodeSendTelemetryReport
()
{
static
void
m
nodeSendTelemetryReport
()
{
char
buf
[
128
]
=
{
0
};
uint32_t
ip
=
taosGetIpv4FromFqdn
(
TELEMETRY_SERVER
);
if
(
ip
==
0xffffffff
)
{
d
Trace
(
"failed to get IP address of "
TELEMETRY_SERVER
", reason:%s"
,
strerror
(
errno
));
m
Trace
(
"failed to get IP address of "
TELEMETRY_SERVER
", reason:%s"
,
strerror
(
errno
));
return
;
}
SOCKET
fd
=
taosOpenTcpClientSocket
(
ip
,
TELEMETRY_PORT
,
0
);
if
(
fd
<
0
)
{
d
Trace
(
"failed to create socket for telemetry, reason:%s"
,
strerror
(
errno
));
m
Trace
(
"failed to create socket for telemetry, reason:%s"
,
strerror
(
errno
));
return
;
}
char
clusterId
[
TSDB_CLUSTER_ID_LEN
]
=
{
0
};
d
nodeGetClusterId
(
clusterId
);
m
nodeGetClusterId
(
clusterId
);
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
d
nodeBeginObject
(
&
bw
);
d
nodeAddStringField
(
&
bw
,
"instanceId"
,
clusterId
);
d
nodeAddIntField
(
&
bw
,
"reportVersion"
,
1
);
d
nodeAddOsInfo
(
&
bw
);
d
nodeAddCpuInfo
(
&
bw
);
d
nodeAddMemoryInfo
(
&
bw
);
d
nodeAddVersionInfo
(
&
bw
);
d
nodeAddRuntimeInfo
(
&
bw
);
d
nodeCloseObject
(
&
bw
);
m
nodeBeginObject
(
&
bw
);
m
nodeAddStringField
(
&
bw
,
"instanceId"
,
clusterId
);
m
nodeAddIntField
(
&
bw
,
"reportVersion"
,
1
);
m
nodeAddOsInfo
(
&
bw
);
m
nodeAddCpuInfo
(
&
bw
);
m
nodeAddMemoryInfo
(
&
bw
);
m
nodeAddVersionInfo
(
&
bw
);
m
nodeAddRuntimeInfo
(
&
bw
);
m
nodeCloseObject
(
&
bw
);
const
char
*
header
=
"POST /report HTTP/1.1
\n
"
...
...
@@ -235,18 +232,18 @@ static void dnodeSendTelemetryReport() {
// read something to avoid nginx error 499
if
(
taosReadSocket
(
fd
,
buf
,
10
)
<
0
)
{
d
Trace
(
"failed to receive response since %s"
,
strerror
(
errno
));
m
Trace
(
"failed to receive response since %s"
,
strerror
(
errno
));
}
taosCloseSocket
(
fd
);
}
static
void
*
d
nodeTelemThreadFp
(
void
*
param
)
{
static
void
*
m
nodeTelemThreadFp
(
void
*
param
)
{
struct
timespec
end
=
{
0
};
clock_gettime
(
CLOCK_REALTIME
,
&
end
);
end
.
tv_sec
+=
300
;
// wait 5 minutes before send first report
setThreadName
(
"
d
node-telem"
);
setThreadName
(
"
m
node-telem"
);
while
(
!
tsTelem
.
exit
)
{
int32_t
r
=
0
;
...
...
@@ -258,7 +255,7 @@ static void* dnodeTelemThreadFp(void* param) {
if
(
r
!=
ETIMEDOUT
)
continue
;
if
(
mnodeGetStatus
()
==
MN_STATUS_READY
)
{
d
nodeSendTelemetryReport
();
m
nodeSendTelemetryReport
();
}
end
.
tv_sec
+=
REPORT_INTERVAL
;
}
...
...
@@ -266,20 +263,20 @@ static void* dnodeTelemThreadFp(void* param) {
return
NULL
;
}
static
void
d
nodeGetEmail
(
char
*
filepath
)
{
static
void
m
nodeGetEmail
(
char
*
filepath
)
{
int32_t
fd
=
taosOpenFileRead
(
filepath
);
if
(
fd
<
0
)
{
return
;
}
if
(
taosReadFile
(
fd
,
(
void
*
)
tsTelem
.
email
,
TSDB_FQDN_LEN
)
<
0
)
{
d
Error
(
"failed to read %d bytes from file %s since %s"
,
TSDB_FQDN_LEN
,
filepath
,
strerror
(
errno
));
m
Error
(
"failed to read %d bytes from file %s since %s"
,
TSDB_FQDN_LEN
,
filepath
,
strerror
(
errno
));
}
taosCloseFile
(
fd
);
}
int32_t
d
nodeInitTelem
()
{
int32_t
m
nodeInitTelem
()
{
tsTelem
.
enable
=
tsEnableTelemetryReporting
;
if
(
!
tsTelem
.
enable
)
return
0
;
...
...
@@ -288,23 +285,23 @@ int32_t dnodeInitTelem() {
pthread_cond_init
(
&
tsTelem
.
cond
,
NULL
);
tsTelem
.
email
[
0
]
=
0
;
d
nodeGetEmail
(
"/usr/local/taos/email"
);
m
nodeGetEmail
(
"/usr/local/taos/email"
);
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_JOINABLE
);
int32_t
code
=
pthread_create
(
&
tsTelem
.
thread
,
&
attr
,
d
nodeTelemThreadFp
,
NULL
);
int32_t
code
=
pthread_create
(
&
tsTelem
.
thread
,
&
attr
,
m
nodeTelemThreadFp
,
NULL
);
pthread_attr_destroy
(
&
attr
);
if
(
code
!=
0
)
{
d
Trace
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
m
Trace
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
}
dInfo
(
"d
node telemetry is initialized"
);
mInfo
(
"m
node telemetry is initialized"
);
return
0
;
}
void
d
nodeCleanupTelem
()
{
void
m
nodeCleanupTelem
()
{
if
(
!
tsTelem
.
enable
)
return
;
if
(
taosCheckPthreadValid
(
tsTelem
.
thread
))
{
...
...
source/server/mnode/src/mondeInt.c
浏览文件 @
3f592b7b
...
...
@@ -34,6 +34,7 @@
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeWorker.h"
#include "mnodeTelem.h"
static
struct
{
int32_t
state
;
...
...
@@ -127,6 +128,7 @@ static int32_t mnodeInitStep2() {
taosStepAdd
(
steps
,
"mnode-show"
,
mnodeInitShow
,
mnodeCleanUpShow
);
taosStepAdd
(
steps
,
"mnode-sync"
,
mnodeInitSync
,
mnodeCleanUpSync
);
taosStepAdd
(
steps
,
"mnode-worker"
,
NULL
,
mnodeCleanupWorker
);
taosStepAdd
(
steps
,
"mnode-telem"
,
mnodeInitTelem
,
mnodeCleanupTelem
);
taosStepAdd
(
steps
,
"mnode-timer"
,
NULL
,
mnodeCleanupTimer
);
tsMint
.
steps2
=
steps
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录