Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a9ed8e2
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看板
提交
8a9ed8e2
编写于
1月 15, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1207
上级
ac49a78d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
59 deletion
+62
-59
src/balance/src/bnThread.c
src/balance/src/bnThread.c
+2
-2
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+60
-57
未找到文件。
src/balance/src/bnThread.c
浏览文件 @
8a9ed8e2
...
...
@@ -124,8 +124,8 @@ void bnStartTimer(int32_t mseconds) {
bool
updateSoon
=
(
mseconds
!=
-
1
);
if
(
updateSoon
)
{
mTrace
(
"balance function will be called after %
"
PRId64
"
ms"
,
mseconds
);
taosTmrReset
(
bnProcessTimer
,
mseconds
,
(
void
*
)
mseconds
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
mTrace
(
"balance function will be called after %
d
ms"
,
mseconds
);
taosTmrReset
(
bnProcessTimer
,
mseconds
,
(
void
*
)
(
int64_t
)
mseconds
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
}
else
{
taosTmrReset
(
bnProcessTimer
,
tsStatusInterval
*
1000
,
NULL
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
}
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
8a9ed8e2
...
...
@@ -45,6 +45,21 @@ static char tsProcMemFile[25] = {0};
static
char
tsProcIOFile
[
25
]
=
{
0
};
static
float
tsPageSizeKB
=
0
;
static
void
taosGetProcInfos
()
{
tsPageSize
=
sysconf
(
_SC_PAGESIZE
);
tsOpenMax
=
sysconf
(
_SC_OPEN_MAX
);
tsStreamMax
=
sysconf
(
_SC_STREAM_MAX
);
tsProcId
=
(
pid_t
)
syscall
(
SYS_gettid
);
tsPageSizeKB
=
(
float
)(
sysconf
(
_SC_PAGESIZE
))
/
1024
;
snprintf
(
tsProcMemFile
,
25
,
"/proc/%d/status"
,
tsProcId
);
snprintf
(
tsProcCpuFile
,
25
,
"/proc/%d/stat"
,
tsProcId
);
snprintf
(
tsProcIOFile
,
25
,
"/proc/%d/io"
,
tsProcId
);
}
static
int32_t
taosGetTotalMemory
()
{
return
(
int32_t
)((
float
)
sysconf
(
_SC_PHYS_PAGES
)
*
tsPageSizeKB
/
1024
);
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
float
memoryAvailMB
=
(
float
)
sysconf
(
_SC_AVPHYS_PAGES
)
*
tsPageSizeKB
/
1024
;
*
memoryUsedMB
=
(
float
)
tsTotalMemoryMB
-
memoryAvailMB
;
...
...
@@ -105,7 +120,8 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
}
char
cpu
[
10
]
=
{
0
};
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
tfree
(
line
);
fclose
(
fp
);
...
...
@@ -131,7 +147,8 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
for
(
int
i
=
0
,
blank
=
0
;
line
[
i
]
!=
0
;
++
i
)
{
if
(
line
[
i
]
==
' '
)
blank
++
;
if
(
blank
==
PROCESS_ITEM
)
{
sscanf
(
line
+
i
+
1
,
"%"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
&
cpuInfo
->
utime
,
&
cpuInfo
->
stime
,
&
cpuInfo
->
cutime
,
&
cpuInfo
->
cstime
);
sscanf
(
line
+
i
+
1
,
"%"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
&
cpuInfo
->
utime
,
&
cpuInfo
->
stime
,
&
cpuInfo
->
cutime
,
&
cpuInfo
->
cstime
);
break
;
}
}
...
...
@@ -162,12 +179,12 @@ static void taosGetSystemTimezone() {
char
buf
[
68
]
=
{
0
};
if
(
f
!=
NULL
)
{
int
len
=
fread
(
buf
,
64
,
1
,
f
);
if
(
len
<
64
&&
ferror
(
f
))
{
if
(
len
<
64
&&
ferror
(
f
))
{
fclose
(
f
);
uError
(
"read /etc/timezone error, reason:%s"
,
strerror
(
errno
));
return
;
}
fclose
(
f
);
buf
[
sizeof
(
buf
)
-
1
]
=
0
;
...
...
@@ -258,6 +275,8 @@ static void taosGetSystemLocale() { // get and set default locale
}
}
static
int32_t
taosGetCpuCores
()
{
return
(
int32_t
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
static
uint64_t
lastSysUsed
=
0
;
static
uint64_t
lastSysTotal
=
0
;
...
...
@@ -300,11 +319,9 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
bool
taosGetDisk
()
{
struct
statvfs
info
;
const
double
unit
=
1024
*
1024
*
1024
;
if
(
tscEmbedded
)
{
if
(
statvfs
(
tsDataDir
,
&
info
))
{
//tsTotalDataDirGB = 0;
//tsAvailDataDirGB = 0;
uError
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
return
false
;
}
else
{
...
...
@@ -314,8 +331,6 @@ bool taosGetDisk() {
}
if
(
statvfs
(
tsLogDir
,
&
info
))
{
//tsTotalLogDirGB = 0;
//tsAvailLogDirGB = 0;
uError
(
"failed to get disk size, logDir:%s errno:%s"
,
tsLogDir
,
strerror
(
errno
));
return
false
;
}
else
{
...
...
@@ -324,8 +339,6 @@ bool taosGetDisk() {
}
if
(
statvfs
(
"/tmp"
,
&
info
))
{
//tsTotalTmpDirGB = 0;
//tsAvailTmpDirectorySpace = 0;
uError
(
"failed to get disk size, tmpDir:/tmp errno:%s"
,
strerror
(
errno
));
return
false
;
}
else
{
...
...
@@ -344,13 +357,12 @@ static bool taosGetCardInfo(int64_t *bytes) {
return
false
;
}
size_t
len
=
2048
;
char
*
line
=
calloc
(
1
,
len
);
while
(
!
feof
(
fp
))
{
memset
(
line
,
0
,
len
);
int64_t
rbytes
=
0
;
int64_t
rpackts
=
0
;
int64_t
tbytes
=
0
;
...
...
@@ -465,7 +477,7 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
!
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
))
{
...
...
@@ -490,18 +502,10 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
}
void
taosGetSystemInfo
()
{
tsNumOfCores
=
(
int32_t
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
tsPageSize
=
sysconf
(
_SC_PAGESIZE
);
tsOpenMax
=
sysconf
(
_SC_OPEN_MAX
);
tsStreamMax
=
sysconf
(
_SC_STREAM_MAX
);
taosGetProcInfos
();
tsProcId
=
(
pid_t
)
syscall
(
SYS_gettid
);
tsPageSizeKB
=
(
float
)(
sysconf
(
_SC_PAGESIZE
))
/
1024
;
tsTotalMemoryMB
=
(
int32_t
)((
float
)
sysconf
(
_SC_PHYS_PAGES
)
*
tsPageSizeKB
/
1024
);
snprintf
(
tsProcMemFile
,
25
,
"/proc/%d/status"
,
tsProcId
);
snprintf
(
tsProcCpuFile
,
25
,
"/proc/%d/stat"
,
tsProcId
);
snprintf
(
tsProcIOFile
,
25
,
"/proc/%d/io"
,
tsProcId
);
tsNumOfCores
=
taosGetCpuCores
();
tsTotalMemoryMB
=
taosGetTotalMemory
();
float
tmp1
,
tmp2
;
taosGetSysMemory
(
&
tmp1
);
...
...
@@ -573,16 +577,16 @@ void taosSetCoreDump() {
if
(
0
==
tsEnableCoreFile
)
{
return
;
}
// 1. set ulimit -c unlimited
struct
rlimit
rlim
;
struct
rlimit
rlim_new
;
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
uInfo
(
"the old unlimited para: rlim_cur=%"
PRIu64
", rlim_max=%"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
#else
#else
uInfo
(
"the old unlimited para: rlim_cur=%llu, rlim_max=%llu"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
#endif
#endif
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
...
...
@@ -594,57 +598,56 @@ void taosSetCoreDump() {
}
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
uInfo
(
"the new unlimited para: rlim_cur=%"
PRIu64
", rlim_max=%"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
#else
#else
uInfo
(
"the new unlimited para: rlim_cur=%llu, rlim_max=%llu"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
#endif
#endif
}
#ifndef _TD_ARM_
// 2. set the path for saving core file
struct
__sysctl_args
args
;
int
old_usespid
=
0
;
size_t
old_len
=
0
;
int
new_usespid
=
1
;
size_t
new_len
=
sizeof
(
new_usespid
);
int
old_usespid
=
0
;
size_t
old_len
=
0
;
int
new_usespid
=
1
;
size_t
new_len
=
sizeof
(
new_usespid
);
int
name
[]
=
{
CTL_KERN
,
KERN_CORE_USES_PID
};
memset
(
&
args
,
0
,
sizeof
(
struct
__sysctl_args
));
args
.
name
=
name
;
args
.
nlen
=
sizeof
(
name
)
/
sizeof
(
name
[
0
]);
args
.
oldval
=
&
old_usespid
;
args
.
name
=
name
;
args
.
nlen
=
sizeof
(
name
)
/
sizeof
(
name
[
0
]);
args
.
oldval
=
&
old_usespid
;
args
.
oldlenp
=
&
old_len
;
args
.
newval
=
&
new_usespid
;
args
.
newlen
=
new_len
;
args
.
newval
=
&
new_usespid
;
args
.
newlen
=
new_len
;
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
uInfo
(
"_sysctl(kern_core_uses_pid) set fail: %s"
,
strerror
(
errno
));
uInfo
(
"_sysctl(kern_core_uses_pid) set fail: %s"
,
strerror
(
errno
));
}
uInfo
(
"The old core_uses_pid[%"
PRIu64
"]: %d"
,
old_len
,
old_usespid
);
uInfo
(
"The old core_uses_pid[%"
PRIu64
"]: %d"
,
old_len
,
old_usespid
);
old_usespid
=
0
;
old_len
=
0
;
old_len
=
0
;
memset
(
&
args
,
0
,
sizeof
(
struct
__sysctl_args
));
args
.
name
=
name
;
args
.
nlen
=
sizeof
(
name
)
/
sizeof
(
name
[
0
]);
args
.
oldval
=
&
old_usespid
;
args
.
name
=
name
;
args
.
nlen
=
sizeof
(
name
)
/
sizeof
(
name
[
0
]);
args
.
oldval
=
&
old_usespid
;
args
.
oldlenp
=
&
old_len
;
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
uInfo
(
"_sysctl(kern_core_uses_pid) get fail: %s"
,
strerror
(
errno
));
uInfo
(
"_sysctl(kern_core_uses_pid) get fail: %s"
,
strerror
(
errno
));
}
uInfo
(
"The new core_uses_pid[%"
PRIu64
"]: %d"
,
old_len
,
old_usespid
);
#endif
}
bool
taosGetSystemUid
(
char
*
uid
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录