Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c018e918
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看板
提交
c018e918
编写于
3月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
6cfff92b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
62 deletion
+58
-62
include/os/osSysinfo.h
include/os/osSysinfo.h
+3
-3
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+2
-2
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+53
-57
未找到文件。
include/os/osSysinfo.h
浏览文件 @
c018e918
...
...
@@ -34,9 +34,9 @@ typedef struct {
}
SDiskSpace
;
void
taosGetSystemInfo
();
bool
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
bool
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
bool
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_t
*
numOfCores
);
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_t
*
numOfCores
);
int32_t
taosGetCpuCores
();
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
);
bool
taosGetTotalSysMemoryKB
(
uint64_t
*
kb
);
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
c018e918
...
...
@@ -52,12 +52,12 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
)))
{
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
))
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
}
int32_t
numOfCores
=
0
;
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
))
{
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
)
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"cpuModel"
,
tmp
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
numOfCores
);
}
else
{
...
...
source/os/src/osSysinfo.c
浏览文件 @
c018e918
...
...
@@ -80,7 +80,6 @@ bool taosGetProcMemory(float *memoryUsedMB) {
return
true
;
}
int32_t
taosGetCpuCores
()
{
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
...
...
@@ -106,7 +105,7 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
return
0
;
}
else
{
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
@@ -173,12 +172,12 @@ void taosGetSystemInfo() {
}
void
taosKillSystem
()
{
//printf("function taosKillSystem, exit!");
//
printf("function taosKillSystem, exit!");
exit
(
0
);
}
int
taosSystem
(
const
char
*
cmd
)
{
//printf("taosSystem not support");
//
printf("taosSystem not support");
return
-
1
;
}
...
...
@@ -241,9 +240,8 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
#include <errno.h>
#include <libproc.h>
void
taosKillSystem
()
{
//printf("function taosKillSystem, exit!");
//
printf("function taosKillSystem, exit!");
exit
(
0
);
}
...
...
@@ -300,7 +298,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
}
int
taosSystem
(
const
char
*
cmd
)
{
//printf("un support funtion");
//
printf("un support funtion");
return
-
1
;
}
...
...
@@ -309,7 +307,7 @@ void taosSetCoreDump() {}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
struct
statvfs
info
;
if
(
statvfs
(
dataDir
,
&
info
))
{
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
else
{
...
...
@@ -404,12 +402,12 @@ bool taosGetProcMemory(float *memoryUsedMB) {
// FILE *fp = fopen(tsProcMemFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcMemFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcMemFile);
//
printf("open file:%s failed", tsProcMemFile);
return
false
;
}
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
while
(
!
taosEOFFile
(
pFile
))
{
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
...
...
@@ -421,7 +419,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
if
(
line
==
NULL
)
{
//printf("read file:%s failed", tsProcMemFile);
//
printf("read file:%s failed", tsProcMemFile);
taosCloseFile
(
&
pFile
);
return
false
;
}
...
...
@@ -431,7 +429,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
&
memKB
);
*
memoryUsedMB
=
(
float
)((
double
)
memKB
/
1024
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
return
true
;
}
...
...
@@ -440,14 +438,14 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
// FILE *fp = fopen(tsSysCpuFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsSysCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsSysCpuFile);
//
printf("open file:%s failed", tsSysCpuFile);
return
false
;
}
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
//printf("read file:%s failed", tsSysCpuFile);
//
printf("read file:%s failed", tsSysCpuFile);
taosCloseFile
(
&
pFile
);
return
false
;
}
...
...
@@ -456,7 +454,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
return
true
;
}
...
...
@@ -465,14 +463,14 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
// FILE *fp = fopen(tsProcCpuFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcCpuFile);
//
printf("open file:%s failed", tsProcCpuFile);
return
false
;
}
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
//printf("read file:%s failed", tsProcCpuFile);
//
printf("read file:%s failed", tsProcCpuFile);
taosCloseFile
(
&
pFile
);
return
false
;
}
...
...
@@ -486,12 +484,11 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
}
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
return
true
;
}
int32_t
taosGetCpuCores
()
{
return
(
int32_t
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
...
...
@@ -550,12 +547,12 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
// FILE *fp = fopen(tsSysNetFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsSysNetFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsSysNetFile);
//
printf("open file:%s failed", tsSysNetFile);
return
false
;
}
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
while
(
!
taosEOFFile
(
pFile
))
{
int64_t
o_rbytes
=
0
;
...
...
@@ -590,7 +587,7 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
*
bytes
+=
(
o_rbytes
+
o_tbytes
);
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
return
true
;
...
...
@@ -636,12 +633,12 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
// FILE *fp = fopen(tsProcIOFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcIOFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcIOFile);
//
printf("open file:%s failed", tsProcIOFile);
return
false
;
}
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
char
tmp
[
10
];
int
readIndex
=
0
;
...
...
@@ -662,11 +659,11 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if
(
readIndex
>=
2
)
break
;
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
if
(
readIndex
<
2
)
{
//printf("read file:%s failed", tsProcIOFile);
//
printf("read file:%s failed", tsProcIOFile);
return
false
;
}
...
...
@@ -713,12 +710,11 @@ void taosGetSystemInfo() {
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
}
void
taosKillSystem
()
{
// SIGINT
//printf("taosd will shut down soon");
//
printf("taosd will shut down soon");
kill
(
tsProcId
,
2
);
}
...
...
@@ -727,22 +723,22 @@ int taosSystem(const char *cmd) {
int
res
;
char
buf
[
1024
];
if
(
cmd
==
NULL
)
{
//printf("taosSystem cmd is NULL!");
//
printf("taosSystem cmd is NULL!");
return
-
1
;
}
if
((
fp
=
popen
(
cmd
,
"r"
))
==
NULL
)
{
//printf("popen cmd:%s error: %s", cmd, strerror(errno));
//
printf("popen cmd:%s error: %s", cmd, strerror(errno));
return
-
1
;
}
else
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
//printf("popen result:%s", buf);
//
printf("popen result:%s", buf);
}
if
((
res
=
pclose
(
fp
))
==
-
1
)
{
//printf("close popen file pointer fp error!");
//
printf("close popen file pointer fp error!");
}
else
{
//printf("popen res is :%d", res);
//
printf("popen res is :%d", res);
}
return
res
;
...
...
@@ -757,14 +753,14 @@ void taosSetCoreDump(bool enable) {
struct
rlimit
rlim_new
;
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
//printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
//
printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
//printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
//
printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
//printf("set unlimited fail, error: %s", strerror(errno));
//
printf("set unlimited fail, error: %s", strerror(errno));
rlim_new
.
rlim_cur
=
rlim
.
rlim_max
;
rlim_new
.
rlim_max
=
rlim
.
rlim_max
;
(
void
)
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
);
...
...
@@ -773,9 +769,9 @@ void taosSetCoreDump(bool enable) {
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
//printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
//
printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
//printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
//
printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
}
...
...
@@ -801,10 +797,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
//printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
//
printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
//printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
//
printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
old_usespid
=
0
;
old_len
=
0
;
...
...
@@ -817,10 +813,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
//printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
//
printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
//printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
//
printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
}
...
...
@@ -885,7 +881,7 @@ SysNameInfo taosGetSysNameInfo() {
return
info
;
}
bool
taosGetEmail
(
char
*
email
,
int32_t
maxLen
)
{
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
)
{
const
char
*
filepath
=
"/usr/local/taos/email"
;
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_READ
);
...
...
@@ -893,17 +889,17 @@ bool taosGetEmail(char *email, int32_t maxLen) {
if
(
taosReadFile
(
pFile
,
(
void
*
)
email
,
maxLen
)
<
0
)
{
taosCloseFile
(
&
pFile
);
return
false
;
return
-
1
;
}
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
bool
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
bool
ret
=
false
;
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
...
...
@@ -917,21 +913,21 @@ bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
line
[
size
-
2
]
=
0
;
}
tstrncpy
(
releaseName
,
p
,
maxLen
);
ret
=
true
;
code
=
0
;
break
;
}
}
if
(
line
!=
NULL
)
free
(
line
);
taosCloseFile
(
&
pFile
);
return
ret
;
return
code
;
}
bool
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_t
*
numOfCores
)
{
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_t
*
numOfCores
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
int32_t
done
=
0
;
bool
ret
=
false
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/cpuinfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
...
...
@@ -941,7 +937,7 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
tstrncpy
(
cpuModel
,
v
,
maxLen
);
ret
=
true
;
code
=
0
;
done
|=
1
;
}
else
if
(((
done
&
2
)
==
0
)
&&
strncmp
(
line
,
"cpu cores"
,
9
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
...
...
@@ -953,7 +949,7 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if
(
line
!=
NULL
)
free
(
line
);
taosCloseFile
(
&
pFile
);
return
ret
;
return
code
;
}
bool
taosGetTotalSysMemoryKB
(
uint64_t
*
kb
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录