提交 382adfac 编写于 作者: S Shengliang Guan

TD-1413

上级 f17ec44e
......@@ -17,7 +17,6 @@
#include "taosmsg.h"
#include "tcache.h"
#include "trpc.h"
#include "tsystem.h"
#include "ttimer.h"
#include "tutil.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 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();
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
}
......@@ -136,11 +135,11 @@ void taos_init_imp(void) {
}
tscTmr = taosTmrInit(tsMaxConnections * 2, 200, 60000, "TSC");
if(0 == tscEmbedded){
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
if (0 == tscEmbedded) {
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
}
int64_t refreshTime = 10; // 10 seconds by default
int64_t refreshTime = 10; // 10 seconds by default
if (tscMetaCache == NULL) {
tscMetaCache = taosCacheInit(TSDB_DATA_TYPE_BINARY, refreshTime, false, tscFreeTableMetaHelper, "tableMeta");
tscObjCache = taosCacheInit(TSDB_CACHE_PTR_KEY, refreshTime / 2, false, tscFreeRegisteredSqlObj, "sqlObj");
......
/*
* 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) {
struct statvfs dstat;
if (statvfs(pDisk->dir, &dstat) < 0) {
SysDiskSize dstat;
if (taosGetDiskSize(pDisk->dir, &dstat) < 0) {
uError("failed to get dir %s information since %s", pDisk->dir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
pDisk->dmeta.size = dstat.f_bsize * dstat.f_blocks;
pDisk->dmeta.free = dstat.f_bsize * dstat.f_bavail;
pDisk->dmeta.size = dstat.tsize;
pDisk->dmeta.free = dstat.avail;
return 0;
}
......@@ -349,4 +349,25 @@ static int tdAddDisk(SDnodeTier *pDnodeTier, char *dir, int level, int primary)
pDnodeTier->nTiers = MAX(pDnodeTier->nTiers, level + 1);
return 0;
}
\ No newline at end of file
}
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 "taoserror.h"
#include "tsched.h"
#include "tsystem.h"
#include "tutil.h"
#include "tgrant.h"
#include "tbalance.h"
......
......@@ -21,10 +21,16 @@ extern "C" {
#endif
// TAOS_OS_FUNC_SYSINFO
typedef struct {
int64_t tsize;
int64_t avail;
} SysDiskSize;
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize);
void taosGetSystemInfo();
bool taosGetProcIO(float *readKB, float *writeKB);
bool taosGetBandSpeed(float *bandSpeedKb);
bool taosGetDisk();
void taosGetDisk();
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) ;
bool taosGetProcMemory(float *memoryUsedMB) ;
bool taosGetSysMemory(float *memoryUsedMB);
......
......@@ -67,7 +67,7 @@ void taosGetSystemInfo() {
taosGetSystemLocale();
}
bool taosGetDisk() { return true; }
void taosGetDisk() {}
bool taosGetProcIO(float *readKB, float *writeKB) {
*readKB = 0;
......
......@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tconfig.h"
#include "tdisk.h"
#include "tglobal.h"
#include "tulog.h"
......@@ -297,45 +298,16 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
return true;
}
bool taosGetDisk() {
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
struct statvfs info;
const double unit = 1024 * 1024 * 1024;
#if 0
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 {
tsTotalDataDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
tsAvailDataDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
}
}
#endif
if (statvfs(tsLogDir, &info)) {
//tsTotalLogDirGB = 0;
//tsAvailLogDirGB = 0;
uError("failed to get disk size, logDir:%s errno:%s", tsLogDir, strerror(errno));
if (statvfs(tsDataDir, &info)) {
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, 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);
diskSize->tsize = info.f_blocks * info.f_frsize;
diskSize->avail = info.f_bavail * info.f_frsize;
return true;
}
return true;
}
static bool taosGetCardInfo(int64_t *bytes) {
......@@ -508,7 +480,7 @@ void taosGetSystemInfo() {
float tmp1, tmp2;
taosGetSysMemory(&tmp1);
taosGetProcMemory(&tmp2);
taosGetDisk();
// taosGetDisk();
taosGetBandSpeed(&tmp1);
taosGetCpuUsage(&tmp1, &tmp2);
taosGetProcIO(&tmp1, &tmp2);
......
......@@ -80,7 +80,7 @@ void taosGetSystemInfo() {
taosGetSystemLocale();
}
bool taosGetDisk() {
void taosGetDisk() {
const double unit = 1024 * 1024 * 1024;
BOOL fResult;
unsigned _int64 i64FreeBytesToCaller;
......
......@@ -21,7 +21,6 @@
#include "ttimer.h"
#include "tutil.h"
#include "tdisk.h"
#include "tsystem.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "dnode.h"
......@@ -126,10 +125,6 @@ static void *monitorThreadFunc(void *param) {
break;
} else {
taosGetDisk();
tdUpdateTiersInfo(tsDnodeTier);
const double unit = 1024 * 1024 * 1024;
tsTotalDataDirGB = tsDnodeTier->meta.tsize / unit;
tsAvailDataDirGB = tsDnodeTier->meta.avail / unit;
}
if (tsMonitor.start == 0) {
......
......@@ -15,7 +15,6 @@
#include "os.h"
#include "tsocket.h"
#include "tsystem.h"
#include "ttimer.h"
#include "tutil.h"
#include "taosdef.h"
......
......@@ -22,7 +22,6 @@
#include "tkey.h"
#include "tulog.h"
#include "tsocket.h"
#include "tsystem.h"
#include "tutil.h"
SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册