TD-1207
This commit is contained in:
parent
ac49a78d42
commit
8a9ed8e2ef
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -303,8 +322,6 @@ bool taosGetDisk() {
|
|||
|
||||
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,7 +357,6 @@ static bool taosGetCardInfo(int64_t *bytes) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
size_t len = 2048;
|
||||
char * line = calloc(1, len);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -604,6 +608,7 @@ void taosSetCoreDump() {
|
|||
#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;
|
||||
|
@ -627,7 +632,6 @@ void taosSetCoreDump() {
|
|||
|
||||
uInfo("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
|
||||
|
||||
|
||||
old_usespid = 0;
|
||||
old_len = 0;
|
||||
memset(&args, 0, sizeof(struct __sysctl_args));
|
||||
|
@ -644,7 +648,6 @@ void taosSetCoreDump() {
|
|||
|
||||
uInfo("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
bool taosGetSystemUid(char *uid) {
|
||||
|
|
Loading…
Reference in New Issue