提交 3fbb78a9 编写于 作者: S Shengliang Guan

io

上级 c890b0b5
......@@ -43,8 +43,8 @@ int32_t taosGetTotalMemory(int64_t *totalKB);
int32_t taosGetProcMemory(int64_t *usedKB);
int32_t taosGetSysMemory(int64_t *usedKB);
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
bool taosReadProcIO(int64_t *rchars, int64_t *wchars);
bool taosGetProcIO(float *readKB, float *writeKB);
int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars);
int32_t taosGetProcIO(float *readKB, float *writeKB);
bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes);
bool taosGetBandSpeed(float *bandSpeedKb);
......
......@@ -491,10 +491,9 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
pInfo->disk_total = 4.3;
pInfo->net_in = 5.1;
pInfo->net_out = 5.2;
pInfo->io_read = 6.1;
pInfo->io_write = 6.2;
pInfo->io_read_disk = 7.1;
pInfo->io_write_disk = 7.2;
taosGetProcIO(&pInfo->io_read, &pInfo->io_write);
pInfo->io_read_disk = 0;
pInfo->io_write_disk = 0;
pInfo->req_select = 8;
pInfo->req_select_rate = 8.1;
pInfo->req_insert = 9;
......
......@@ -124,31 +124,31 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
return true;
}
bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
int32_t taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
IO_COUNTERS io_counter;
if (GetProcessIoCounters(GetCurrentProcess(), &io_counter)) {
if (readbyte) *readbyte = io_counter.ReadTransferCount;
if (writebyte) *writebyte = io_counter.WriteTransferCount;
return true;
return 0;
}
return false;
return -1;
}
bool taosGetProcIO(float *readKB, float *writeKB) {
int32_t taosGetProcIO(float *readKB, float *writeKB) {
static int64_t lastReadbyte = -1;
static int64_t lastWritebyte = -1;
int64_t curReadbyte = 0;
int64_t curWritebyte = 0;
if (!taosReadProcIO(&curReadbyte, &curWritebyte)) {
return false;
if (taosReadProcIO(&curReadbyte, &curWritebyte) != 0) {
return -1;
}
if (lastReadbyte == -1 || lastWritebyte == -1) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
return false;
return -1;
}
*readKB = (float)((double)(curReadbyte - lastReadbyte) / 1024);
......@@ -159,7 +159,7 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
return true;
return 0;
}
void taosGetSystemInfo() {
......@@ -259,16 +259,16 @@ void taosGetSystemInfo() {
tsNumOfCores = sysconf(_SC_NPROCESSORS_ONLN);
}
bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if (rchars) *rchars = 0;
if (wchars) *wchars = 0;
return true;
return 0;
}
bool taosGetProcIO(float *readKB, float *writeKB) {
int32_t taosGetProcIO(float *readKB, float *writeKB) {
*readKB = 0;
*writeKB = 0;
return true;
return 0;
}
bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
......@@ -631,12 +631,12 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
return true;
}
bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
// FILE *fp = fopen(tsProcIOFile, "r");
TdFilePtr pFile = taosOpenFile(tsProcIOFile, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
// printf("open file:%s failed", tsProcIOFile);
return false;
return -1;
}
ssize_t _bytes = 0;
......@@ -666,27 +666,27 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if (readIndex < 2) {
// printf("read file:%s failed", tsProcIOFile);
return false;
return -1;
}
return true;
return 0;
}
bool taosGetProcIO(float *readKB, float *writeKB) {
int32_t taosGetProcIO(float *readKB, float *writeKB) {
static int64_t lastReadbyte = -1;
static int64_t lastWritebyte = -1;
int64_t curReadbyte = 0;
int64_t curWritebyte = 0;
if (!taosReadProcIO(&curReadbyte, &curWritebyte)) {
return false;
if (taosReadProcIO(&curReadbyte, &curWritebyte) != 0) {
return -1;
}
if (lastReadbyte == -1 || lastWritebyte == -1) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
return false;
return -1;
}
*readKB = (float)((double)(curReadbyte - lastReadbyte) / 1024);
......@@ -697,7 +697,7 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte = curReadbyte;
lastWritebyte = curWritebyte;
return true;
return 0;
}
void taosGetSystemInfo() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册