Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
163adf19
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
163adf19
编写于
7月 14, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: dm monitor refactor
上级
11a338fc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
79 addition
and
16 deletion
+79
-16
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-1
source/common/src/tmisce.c
source/common/src/tmisce.c
+1
-1
source/dnode/mgmt/node_mgmt/src/dmEnv.c
source/dnode/mgmt/node_mgmt/src/dmEnv.c
+52
-3
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+1
-1
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+23
-9
source/os/test/osTests.cpp
source/os/test/osTests.cpp
+1
-1
未找到文件。
include/os/osSysinfo.h
浏览文件 @
163adf19
...
...
@@ -36,7 +36,7 @@ typedef struct {
bool
taosCheckSystemIsLittleEnd
();
void
taosGetSystemInfo
();
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
char
*
sName
,
char
*
ver
,
int32_t
maxLen
);
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
float
*
numOfCores
);
int32_t
taosGetCpuCores
(
float
*
numOfCores
);
void
taosGetCpuUsage
(
double
*
cpu_system
,
double
*
cpu_engine
);
...
...
source/common/src/tmisce.c
浏览文件 @
163adf19
...
...
@@ -109,7 +109,7 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
taosGetAppName
(
tmp
,
NULL
);
tjsonAddStringToObject
(
pJson
,
"appName"
,
tmp
);
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
))
==
0
)
{
if
(
taosGetOsReleaseName
(
tmp
,
NULL
,
NULL
,
sizeof
(
tmp
))
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
}
...
...
source/dnode/mgmt/node_mgmt/src/dmEnv.c
浏览文件 @
163adf19
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
extern
char
tsVersionName
[
16
];
static
SDnode
globalDnode
=
{
0
};
SDnode
*
dmInstance
()
{
return
&
globalDnode
;
}
...
...
@@ -36,17 +37,65 @@ static int32_t dmInitSystem() {
return
0
;
}
#define STR_CASE_CMP(s, d) strcasecmp((s), (d))
#define STR_STR_CMP(s, d) strstr((s), (d))
#define STR_INT_CMP(s, d, c) (taosStr2Int32(s, 0, 10) c(d))
#define DM_INIT_CODE() \
do { \
code = (int32_t)((2147483648 | ((0) << 7 | (298)))); \
strncpy(stName, tsVersionName, 64); \
} while (0)
#define DM_ERR_RTN(c) \
do { \
code = (c); \
goto _exit; \
} while (0)
static
int32_t
dmInitMonitor
()
{
int32_t
code
=
0
;
SMonCfg
monCfg
=
{
0
};
char
reName
[
64
]
=
{
0
};
char
stName
[
64
]
=
{
0
};
char
ver
[
64
]
=
{
0
};
DM_INIT_CODE
();
monCfg
.
maxLogs
=
tsMonitorMaxLogs
;
monCfg
.
port
=
tsMonitorPort
;
monCfg
.
server
=
tsMonitorFqdn
;
monCfg
.
comp
=
tsMonitorComp
;
if
(
monInit
(
&
monCfg
)
!=
0
)
{
dError
(
"failed to init monitor since %s"
,
terrstr
())
;
return
-
1
;
if
(
terrno
!=
0
)
code
=
terrno
;
goto
_exit
;
}
return
0
;
if
(
STR_STR_CMP
(
stName
,
"ia"
))
{
DM_ERR_RTN
(
0
);
}
if
(
taosGetOsReleaseName
(
reName
,
stName
,
ver
,
64
)
!=
0
)
{
goto
_exit
;
}
else
if
(
STR_CASE_CMP
(
stName
,
"Ubuntu"
))
{
if
(
STR_INT_CMP
(
ver
,
17
,
>
))
{
DM_ERR_RTN
(
0
);
}
}
else
if
(
STR_CASE_CMP
(
stName
,
"CentOS Linux"
))
{
if
(
STR_INT_CMP
(
ver
,
6
,
>
))
{
DM_ERR_RTN
(
0
);
}
}
else
if
(
STR_STR_CMP
(
stName
,
"Red Hat"
)
||
STR_STR_CMP
(
stName
,
"Debian GNU"
)
||
STR_STR_CMP
(
stName
,
"CoreOS"
)
||
STR_STR_CMP
(
stName
,
"FreeBSD"
)
||
STR_STR_CMP
(
stName
,
"openSUSE"
)
||
STR_STR_CMP
(
stName
,
"SLES"
)
||
STR_STR_CMP
(
stName
,
"Fedora"
)
||
STR_STR_CMP
(
stName
,
"MacOS"
))
{
DM_ERR_RTN
(
0
);
}
_exit:
if
(
code
!=
0
)
{
dError
(
"failed to init monitor since %d"
,
code
);
}
return
code
;
}
static
bool
dmCheckDiskSpace
()
{
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
163adf19
...
...
@@ -94,7 +94,7 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
))
==
0
)
{
if
(
taosGetOsReleaseName
(
tmp
,
NULL
,
NULL
,
sizeof
(
tmp
))
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
}
...
...
source/os/src/osSysinfo.c
浏览文件 @
163adf19
...
...
@@ -327,17 +327,19 @@ bool getWinVersionReleaseName(char *releaseName, int32_t maxLen) {
}
#endif
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
)
{
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
char
*
sName
,
char
*
ver
,
int32_t
maxLen
)
{
#ifdef WINDOWS
if
(
!
getWinVersionReleaseName
(
releaseName
,
maxLen
))
{
snprintf
(
releaseName
,
maxLen
,
"Windows"
);
}
snprintf
(
sName
,
maxLen
,
"Windows"
);
return
0
;
#elif defined(_TD_DARWIN_64)
char
osversion
[
32
];
size_t
osversion_len
=
sizeof
(
osversion
)
-
1
;
int
osversion_name
[]
=
{
CTL_KERN
,
KERN_OSRELEASE
};
snprintf
(
sName
,
maxLen
,
"macOS"
);
if
(
sysctl
(
osversion_name
,
2
,
osversion
,
&
osversion_len
,
NULL
,
0
)
==
-
1
)
{
return
-
1
;
}
...
...
@@ -357,21 +359,33 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
return
0
;
#else
char
line
[
1024
];
char
*
dest
=
NULL
;
size_t
size
=
0
;
int32_t
code
=
-
1
;
int32_t
cnt
=
0
;
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
fals
e
;
if
(
pFile
==
NULL
)
return
cod
e
;
while
((
size
=
taosGetsFile
(
pFile
,
sizeof
(
line
),
line
))
!=
-
1
)
{
line
[
size
-
1
]
=
'\0'
;
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
if
(
*
p
==
'"'
)
{
p
++
;
line
[
size
-
2
]
=
0
;
}
tstrncpy
(
releaseName
,
p
,
maxLen
);
if
(
strncmp
(
line
,
"NAME"
,
4
)
==
0
)
{
dest
=
sName
;
}
else
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
dest
=
releaseName
;
}
else
if
(
strncmp
(
line
,
"VERSION_ID"
,
10
)
==
0
)
{
dest
=
ver
;
}
else
{
continue
;
}
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
if
(
*
p
==
'"'
)
{
p
++
;
line
[
size
-
2
]
=
0
;
}
tstrncpy
(
dest
,
p
,
maxLen
);
if
(
++
cnt
>=
3
)
{
code
=
0
;
break
;
}
...
...
source/os/test/osTests.cpp
浏览文件 @
163adf19
...
...
@@ -37,7 +37,7 @@ TEST(osTest, osSystem) {
const
int
sysLen
=
64
;
char
osSysName
[
sysLen
];
int
ret
=
taosGetOsReleaseName
(
osSysName
,
sysLen
);
int
ret
=
taosGetOsReleaseName
(
osSysName
,
NULL
,
NULL
,
sysLen
);
printf
(
"os systeme name:%s
\n
"
,
osSysName
);
ASSERT_EQ
(
ret
,
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录