minor changes
This commit is contained in:
parent
6cfff92b21
commit
c018e91859
|
@ -34,9 +34,9 @@ typedef struct {
|
||||||
} SDiskSpace;
|
} SDiskSpace;
|
||||||
|
|
||||||
void taosGetSystemInfo();
|
void taosGetSystemInfo();
|
||||||
bool taosGetEmail(char *email, int32_t maxLen);
|
int32_t taosGetEmail(char *email, int32_t maxLen);
|
||||||
bool taosGetOsReleaseName(char *releaseName, int32_t maxLen);
|
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen);
|
||||||
bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores);
|
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores);
|
||||||
int32_t taosGetCpuCores();
|
int32_t taosGetCpuCores();
|
||||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
|
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
|
||||||
bool taosGetTotalSysMemoryKB(uint64_t *kb);
|
bool taosGetTotalSysMemoryKB(uint64_t *kb);
|
||||||
|
|
|
@ -52,12 +52,12 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
|
||||||
tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||||
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||||
|
|
||||||
if (taosGetOsReleaseName(tmp, sizeof(tmp))) {
|
if (taosGetOsReleaseName(tmp, sizeof(tmp)) == 0) {
|
||||||
tjsonAddStringToObject(pJson, "os", tmp);
|
tjsonAddStringToObject(pJson, "os", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfCores = 0;
|
int32_t numOfCores = 0;
|
||||||
if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores)) {
|
if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) {
|
||||||
tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
||||||
tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -80,7 +80,6 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t taosGetCpuCores() {
|
int32_t taosGetCpuCores() {
|
||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
GetSystemInfo(&info);
|
GetSystemInfo(&info);
|
||||||
|
@ -106,7 +105,7 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
||||||
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
|
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} 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);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -173,12 +172,12 @@ void taosGetSystemInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosKillSystem() {
|
void taosKillSystem() {
|
||||||
//printf("function taosKillSystem, exit!");
|
// printf("function taosKillSystem, exit!");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosSystem(const char *cmd) {
|
int taosSystem(const char *cmd) {
|
||||||
//printf("taosSystem not support");
|
// printf("taosSystem not support");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,9 +240,8 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libproc.h>
|
#include <libproc.h>
|
||||||
|
|
||||||
|
|
||||||
void taosKillSystem() {
|
void taosKillSystem() {
|
||||||
//printf("function taosKillSystem, exit!");
|
// printf("function taosKillSystem, exit!");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +298,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taosSystem(const char *cmd) {
|
int taosSystem(const char *cmd) {
|
||||||
//printf("un support funtion");
|
// printf("un support funtion");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +307,7 @@ void taosSetCoreDump() {}
|
||||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
||||||
struct statvfs info;
|
struct statvfs info;
|
||||||
if (statvfs(dataDir, &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);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -404,12 +402,12 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
// FILE *fp = fopen(tsProcMemFile, "r");
|
// FILE *fp = fopen(tsProcMemFile, "r");
|
||||||
TdFilePtr pFile = taosOpenFile(tsProcMemFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsProcMemFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
//printf("open file:%s failed", tsProcMemFile);
|
// printf("open file:%s failed", tsProcMemFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t _bytes = 0;
|
ssize_t _bytes = 0;
|
||||||
char * line = NULL;
|
char *line = NULL;
|
||||||
while (!taosEOFFile(pFile)) {
|
while (!taosEOFFile(pFile)) {
|
||||||
_bytes = taosGetLineFile(pFile, &line);
|
_bytes = taosGetLineFile(pFile, &line);
|
||||||
if ((_bytes < 0) || (line == NULL)) {
|
if ((_bytes < 0) || (line == NULL)) {
|
||||||
|
@ -421,7 +419,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line == NULL) {
|
if (line == NULL) {
|
||||||
//printf("read file:%s failed", tsProcMemFile);
|
// printf("read file:%s failed", tsProcMemFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +429,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
sscanf(line, "%s %" PRId64, tmp, &memKB);
|
sscanf(line, "%s %" PRId64, tmp, &memKB);
|
||||||
*memoryUsedMB = (float)((double)memKB / 1024);
|
*memoryUsedMB = (float)((double)memKB / 1024);
|
||||||
|
|
||||||
if(line != NULL) tfree(line);
|
if (line != NULL) tfree(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -440,14 +438,14 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||||
// FILE *fp = fopen(tsSysCpuFile, "r");
|
// FILE *fp = fopen(tsSysCpuFile, "r");
|
||||||
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
//printf("open file:%s failed", tsSysCpuFile);
|
// printf("open file:%s failed", tsSysCpuFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * line = NULL;
|
char *line = NULL;
|
||||||
ssize_t _bytes = taosGetLineFile(pFile, &line);
|
ssize_t _bytes = taosGetLineFile(pFile, &line);
|
||||||
if ((_bytes < 0) || (line == NULL)) {
|
if ((_bytes < 0) || (line == NULL)) {
|
||||||
//printf("read file:%s failed", tsSysCpuFile);
|
// printf("read file:%s failed", tsSysCpuFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return false;
|
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,
|
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system,
|
||||||
&cpuInfo->idle);
|
&cpuInfo->idle);
|
||||||
|
|
||||||
if(line != NULL) tfree(line);
|
if (line != NULL) tfree(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -465,14 +463,14 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||||
// FILE *fp = fopen(tsProcCpuFile, "r");
|
// FILE *fp = fopen(tsProcCpuFile, "r");
|
||||||
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
//printf("open file:%s failed", tsProcCpuFile);
|
// printf("open file:%s failed", tsProcCpuFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * line = NULL;
|
char *line = NULL;
|
||||||
ssize_t _bytes = taosGetLineFile(pFile, &line);
|
ssize_t _bytes = taosGetLineFile(pFile, &line);
|
||||||
if ((_bytes < 0) || (line == NULL)) {
|
if ((_bytes < 0) || (line == NULL)) {
|
||||||
//printf("read file:%s failed", tsProcCpuFile);
|
// printf("read file:%s failed", tsProcCpuFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -486,12 +484,11 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line != NULL) tfree(line);
|
if (line != NULL) tfree(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t taosGetCpuCores() { return (int32_t)sysconf(_SC_NPROCESSORS_ONLN); }
|
int32_t taosGetCpuCores() { return (int32_t)sysconf(_SC_NPROCESSORS_ONLN); }
|
||||||
|
|
||||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
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");
|
// FILE *fp = fopen(tsSysNetFile, "r");
|
||||||
TdFilePtr pFile = taosOpenFile(tsSysNetFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsSysNetFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
//printf("open file:%s failed", tsSysNetFile);
|
// printf("open file:%s failed", tsSysNetFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t _bytes = 0;
|
ssize_t _bytes = 0;
|
||||||
char * line = NULL;
|
char *line = NULL;
|
||||||
|
|
||||||
while (!taosEOFFile(pFile)) {
|
while (!taosEOFFile(pFile)) {
|
||||||
int64_t o_rbytes = 0;
|
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);
|
*bytes += (o_rbytes + o_tbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line != NULL) tfree(line);
|
if (line != NULL) tfree(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -636,12 +633,12 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
|
||||||
// FILE *fp = fopen(tsProcIOFile, "r");
|
// FILE *fp = fopen(tsProcIOFile, "r");
|
||||||
TdFilePtr pFile = taosOpenFile(tsProcIOFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsProcIOFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
//printf("open file:%s failed", tsProcIOFile);
|
// printf("open file:%s failed", tsProcIOFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t _bytes = 0;
|
ssize_t _bytes = 0;
|
||||||
char * line = NULL;
|
char *line = NULL;
|
||||||
char tmp[10];
|
char tmp[10];
|
||||||
int readIndex = 0;
|
int readIndex = 0;
|
||||||
|
|
||||||
|
@ -662,11 +659,11 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
|
||||||
if (readIndex >= 2) break;
|
if (readIndex >= 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line != NULL) tfree(line);
|
if (line != NULL) tfree(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
if (readIndex < 2) {
|
if (readIndex < 2) {
|
||||||
//printf("read file:%s failed", tsProcIOFile);
|
// printf("read file:%s failed", tsProcIOFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,12 +710,11 @@ void taosGetSystemInfo() {
|
||||||
taosGetBandSpeed(&tmp1);
|
taosGetBandSpeed(&tmp1);
|
||||||
taosGetCpuUsage(&tmp1, &tmp2);
|
taosGetCpuUsage(&tmp1, &tmp2);
|
||||||
taosGetProcIO(&tmp1, &tmp2);
|
taosGetProcIO(&tmp1, &tmp2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosKillSystem() {
|
void taosKillSystem() {
|
||||||
// SIGINT
|
// SIGINT
|
||||||
//printf("taosd will shut down soon");
|
// printf("taosd will shut down soon");
|
||||||
kill(tsProcId, 2);
|
kill(tsProcId, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,22 +723,22 @@ int taosSystem(const char *cmd) {
|
||||||
int res;
|
int res;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
//printf("taosSystem cmd is NULL!");
|
// printf("taosSystem cmd is NULL!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fp = popen(cmd, "r")) == NULL) {
|
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;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
while (fgets(buf, sizeof(buf), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
//printf("popen result:%s", buf);
|
// printf("popen result:%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = pclose(fp)) == -1) {
|
if ((res = pclose(fp)) == -1) {
|
||||||
//printf("close popen file pointer fp error!");
|
// printf("close popen file pointer fp error!");
|
||||||
} else {
|
} else {
|
||||||
//printf("popen res is :%d", res);
|
// printf("popen res is :%d", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -757,14 +753,14 @@ void taosSetCoreDump(bool enable) {
|
||||||
struct rlimit rlim_new;
|
struct rlimit rlim_new;
|
||||||
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
||||||
#ifndef _ALPINE
|
#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
|
#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
|
#endif
|
||||||
rlim_new.rlim_cur = RLIM_INFINITY;
|
rlim_new.rlim_cur = RLIM_INFINITY;
|
||||||
rlim_new.rlim_max = RLIM_INFINITY;
|
rlim_new.rlim_max = RLIM_INFINITY;
|
||||||
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
|
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_cur = rlim.rlim_max;
|
||||||
rlim_new.rlim_max = rlim.rlim_max;
|
rlim_new.rlim_max = rlim.rlim_max;
|
||||||
(void)setrlimit(RLIMIT_CORE, &rlim_new);
|
(void)setrlimit(RLIMIT_CORE, &rlim_new);
|
||||||
|
@ -773,9 +769,9 @@ void taosSetCoreDump(bool enable) {
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
||||||
#ifndef _ALPINE
|
#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
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,10 +797,10 @@ void taosSetCoreDump(bool enable) {
|
||||||
old_len = sizeof(old_usespid);
|
old_len = sizeof(old_usespid);
|
||||||
|
|
||||||
if (syscall(SYS__sysctl, &args) == -1) {
|
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_usespid = 0;
|
||||||
old_len = 0;
|
old_len = 0;
|
||||||
|
@ -817,10 +813,10 @@ void taosSetCoreDump(bool enable) {
|
||||||
old_len = sizeof(old_usespid);
|
old_len = sizeof(old_usespid);
|
||||||
|
|
||||||
if (syscall(SYS__sysctl, &args) == -1) {
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +881,7 @@ SysNameInfo taosGetSysNameInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetEmail(char *email, int32_t maxLen) {
|
int32_t taosGetEmail(char *email, int32_t maxLen) {
|
||||||
const char *filepath = "/usr/local/taos/email";
|
const char *filepath = "/usr/local/taos/email";
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ);
|
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) {
|
if (taosReadFile(pFile, (void *)email, maxLen) < 0) {
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
bool ret = false;
|
int32_t code = -1;
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) return false;
|
if (pFile == NULL) return false;
|
||||||
|
@ -917,21 +913,21 @@ bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
||||||
line[size - 2] = 0;
|
line[size - 2] = 0;
|
||||||
}
|
}
|
||||||
tstrncpy(releaseName, p, maxLen);
|
tstrncpy(releaseName, p, maxLen);
|
||||||
ret = true;
|
code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line != NULL) free(line);
|
if (line != NULL) free(line);
|
||||||
taosCloseFile(&pFile);
|
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;
|
char *line = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
int32_t done = 0;
|
int32_t done = 0;
|
||||||
bool ret = false;
|
int32_t code = -1;
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) return false;
|
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) {
|
if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) {
|
||||||
const char *v = strchr(line, ':') + 2;
|
const char *v = strchr(line, ':') + 2;
|
||||||
tstrncpy(cpuModel, v, maxLen);
|
tstrncpy(cpuModel, v, maxLen);
|
||||||
ret = true;
|
code = 0;
|
||||||
done |= 1;
|
done |= 1;
|
||||||
} else if (((done & 2) == 0) && strncmp(line, "cpu cores", 9) == 0) {
|
} else if (((done & 2) == 0) && strncmp(line, "cpu cores", 9) == 0) {
|
||||||
const char *v = strchr(line, ':') + 2;
|
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);
|
if (line != NULL) free(line);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetTotalSysMemoryKB(uint64_t *kb) {
|
bool taosGetTotalSysMemoryKB(uint64_t *kb) {
|
||||||
|
|
Loading…
Reference in New Issue