minor changes
This commit is contained in:
parent
6cfff92b21
commit
c018e91859
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -80,7 +80,6 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
int32_t taosGetCpuCores() {
|
||||
SYSTEM_INFO info;
|
||||
GetSystemInfo(&info);
|
||||
|
@ -241,7 +240,6 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
|
|||
#include <errno.h>
|
||||
#include <libproc.h>
|
||||
|
||||
|
||||
void taosKillSystem() {
|
||||
// printf("function taosKillSystem, exit!");
|
||||
exit(0);
|
||||
|
@ -491,7 +489,6 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
int32_t taosGetCpuCores() { return (int32_t)sysconf(_SC_NPROCESSORS_ONLN); }
|
||||
|
||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
||||
|
@ -713,7 +710,6 @@ void taosGetSystemInfo() {
|
|||
taosGetBandSpeed(&tmp1);
|
||||
taosGetCpuUsage(&tmp1, &tmp2);
|
||||
taosGetProcIO(&tmp1, &tmp2);
|
||||
|
||||
}
|
||||
|
||||
void taosKillSystem() {
|
||||
|
@ -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) {
|
||||
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
||||
char *line = NULL;
|
||||
size_t size = 0;
|
||||
bool ret = false;
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue