Merge branch 'feature/TD-1413' of https://github.com/taosdata/TDengine into feature/TD-1413
This commit is contained in:
commit
cdd74abd3f
|
@ -17,7 +17,6 @@
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "tsystem.h"
|
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
|
@ -43,7 +42,7 @@ static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||||
//void tscUpdateEpSet(void *ahandle, SRpcEpSet *pEpSet);
|
//void tscUpdateEpSet(void *ahandle, SRpcEpSet *pEpSet);
|
||||||
|
|
||||||
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
|
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void *UNUSED_PARAM(param)) {
|
||||||
taosGetDisk();
|
taosGetDisk();
|
||||||
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ void taos_init_imp(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTmr = taosTmrInit(tsMaxConnections * 2, 200, 60000, "TSC");
|
tscTmr = taosTmrInit(tsMaxConnections * 2, 200, 60000, "TSC");
|
||||||
if(0 == tscEmbedded){
|
if (0 == tscEmbedded) {
|
||||||
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TDENGINE_TSYSTEM_H
|
|
||||||
#define TDENGINE_TSYSTEM_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool taosGetSysMemory(float *memoryUsedMB);
|
|
||||||
bool taosGetProcMemory(float *memoryUsedMB);
|
|
||||||
bool taosGetDisk();
|
|
||||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
|
|
||||||
bool taosGetBandSpeed(float *bandSpeedKb);
|
|
||||||
bool taosGetProcIO(float *readKB, float *writeKB);
|
|
||||||
void taosGetSystemInfo();
|
|
||||||
void taosPrintOsInfo();
|
|
||||||
void taosKillSystem();
|
|
||||||
void taosSetCoreDump();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -244,15 +244,15 @@ static int tdCheckDisk(char *dirName, int level, int primary) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdUpdateDiskMeta(SDisk *pDisk) {
|
static int tdUpdateDiskMeta(SDisk *pDisk) {
|
||||||
struct statvfs dstat;
|
SysDiskSize dstat;
|
||||||
if (statvfs(pDisk->dir, &dstat) < 0) {
|
if (taosGetDiskSize(pDisk->dir, &dstat) < 0) {
|
||||||
uError("failed to get dir %s information since %s", pDisk->dir, strerror(errno));
|
uError("failed to get dir %s information since %s", pDisk->dir, strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDisk->dmeta.size = dstat.f_bsize * dstat.f_blocks;
|
pDisk->dmeta.size = dstat.tsize;
|
||||||
pDisk->dmeta.free = dstat.f_bsize * dstat.f_bavail;
|
pDisk->dmeta.free = dstat.avail;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -350,3 +350,24 @@ static int tdAddDisk(SDnodeTier *pDnodeTier, char *dir, int level, int primary)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taosGetDisk() {
|
||||||
|
const double unit = 1024 * 1024 * 1024;
|
||||||
|
SysDiskSize diskSize;
|
||||||
|
|
||||||
|
if (tscEmbedded) {
|
||||||
|
tdUpdateTiersInfo(tsDnodeTier);
|
||||||
|
tsTotalDataDirGB = (float)tsDnodeTier->meta.tsize / unit;
|
||||||
|
tsAvailDataDirGB = (float)tsDnodeTier->meta.avail / unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosGetDiskSize(tsLogDir, &diskSize)) {
|
||||||
|
tsTotalLogDirGB = (float)diskSize.tsize / unit;
|
||||||
|
tsAvailLogDirGB = (float)diskSize.avail / unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosGetDiskSize("/tmp", &diskSize)) {
|
||||||
|
tsTotalTmpDirGB = (float)diskSize.tsize / unit;
|
||||||
|
tsAvailTmpDirectorySpace = (float)diskSize.avail / unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
#include "tsystem.h"
|
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tgrant.h"
|
#include "tgrant.h"
|
||||||
#include "tbalance.h"
|
#include "tbalance.h"
|
||||||
|
|
|
@ -21,10 +21,16 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TAOS_OS_FUNC_SYSINFO
|
// TAOS_OS_FUNC_SYSINFO
|
||||||
|
typedef struct {
|
||||||
|
int64_t tsize;
|
||||||
|
int64_t avail;
|
||||||
|
} SysDiskSize;
|
||||||
|
|
||||||
|
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize);
|
||||||
void taosGetSystemInfo();
|
void taosGetSystemInfo();
|
||||||
bool taosGetProcIO(float *readKB, float *writeKB);
|
bool taosGetProcIO(float *readKB, float *writeKB);
|
||||||
bool taosGetBandSpeed(float *bandSpeedKb);
|
bool taosGetBandSpeed(float *bandSpeedKb);
|
||||||
bool taosGetDisk();
|
void taosGetDisk();
|
||||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) ;
|
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) ;
|
||||||
bool taosGetProcMemory(float *memoryUsedMB) ;
|
bool taosGetProcMemory(float *memoryUsedMB) ;
|
||||||
bool taosGetSysMemory(float *memoryUsedMB);
|
bool taosGetSysMemory(float *memoryUsedMB);
|
||||||
|
|
|
@ -67,7 +67,7 @@ void taosGetSystemInfo() {
|
||||||
taosGetSystemLocale();
|
taosGetSystemLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetDisk() { return true; }
|
void taosGetDisk() {}
|
||||||
|
|
||||||
bool taosGetProcIO(float *readKB, float *writeKB) {
|
bool taosGetProcIO(float *readKB, float *writeKB) {
|
||||||
*readKB = 0;
|
*readKB = 0;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
#include "tdisk.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
|
|
||||||
|
@ -297,45 +298,16 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetDisk() {
|
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
|
||||||
struct statvfs info;
|
struct statvfs info;
|
||||||
const double unit = 1024 * 1024 * 1024;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (tscEmbedded) {
|
|
||||||
if (statvfs(tsDataDir, &info)) {
|
if (statvfs(tsDataDir, &info)) {
|
||||||
//tsTotalDataDirGB = 0;
|
|
||||||
//tsAvailDataDirGB = 0;
|
|
||||||
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tsTotalDataDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
|
diskSize->tsize = info.f_blocks * info.f_frsize;
|
||||||
tsAvailDataDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
|
diskSize->avail = info.f_bavail * info.f_frsize;
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (statvfs(tsLogDir, &info)) {
|
|
||||||
//tsTotalLogDirGB = 0;
|
|
||||||
//tsAvailLogDirGB = 0;
|
|
||||||
uError("failed to get disk size, logDir:%s errno:%s", tsLogDir, strerror(errno));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
tsTotalLogDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
|
|
||||||
tsAvailLogDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statvfs("/tmp", &info)) {
|
|
||||||
//tsTotalTmpDirGB = 0;
|
|
||||||
//tsAvailTmpDirectorySpace = 0;
|
|
||||||
uError("failed to get disk size, tmpDir:/tmp errno:%s", strerror(errno));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
tsTotalTmpDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
|
|
||||||
tsAvailTmpDirectorySpace = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taosGetCardInfo(int64_t *bytes) {
|
static bool taosGetCardInfo(int64_t *bytes) {
|
||||||
|
@ -508,7 +480,7 @@ void taosGetSystemInfo() {
|
||||||
float tmp1, tmp2;
|
float tmp1, tmp2;
|
||||||
taosGetSysMemory(&tmp1);
|
taosGetSysMemory(&tmp1);
|
||||||
taosGetProcMemory(&tmp2);
|
taosGetProcMemory(&tmp2);
|
||||||
taosGetDisk();
|
// taosGetDisk();
|
||||||
taosGetBandSpeed(&tmp1);
|
taosGetBandSpeed(&tmp1);
|
||||||
taosGetCpuUsage(&tmp1, &tmp2);
|
taosGetCpuUsage(&tmp1, &tmp2);
|
||||||
taosGetProcIO(&tmp1, &tmp2);
|
taosGetProcIO(&tmp1, &tmp2);
|
||||||
|
|
|
@ -80,7 +80,7 @@ void taosGetSystemInfo() {
|
||||||
taosGetSystemLocale();
|
taosGetSystemLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetDisk() {
|
void taosGetDisk() {
|
||||||
const double unit = 1024 * 1024 * 1024;
|
const double unit = 1024 * 1024 * 1024;
|
||||||
BOOL fResult;
|
BOOL fResult;
|
||||||
unsigned _int64 i64FreeBytesToCaller;
|
unsigned _int64 i64FreeBytesToCaller;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tdisk.h"
|
#include "tdisk.h"
|
||||||
#include "tsystem.h"
|
|
||||||
#include "tscUtil.h"
|
#include "tscUtil.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
|
@ -126,10 +125,6 @@ static void *monitorThreadFunc(void *param) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
taosGetDisk();
|
taosGetDisk();
|
||||||
tdUpdateTiersInfo(tsDnodeTier);
|
|
||||||
const double unit = 1024 * 1024 * 1024;
|
|
||||||
tsTotalDataDirGB = tsDnodeTier->meta.tsize / unit;
|
|
||||||
tsAvailDataDirGB = tsDnodeTier->meta.avail / unit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsMonitor.start == 0) {
|
if (tsMonitor.start == 0) {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
#include "tsystem.h"
|
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "tkey.h"
|
#include "tkey.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
#include "tsystem.h"
|
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}};
|
SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}};
|
||||||
|
|
Loading…
Reference in New Issue