monitor
This commit is contained in:
parent
3fbb78a951
commit
2bf46ddc54
|
@ -94,12 +94,12 @@ typedef struct {
|
|||
float disk_engine; // GB
|
||||
float disk_used; // GB
|
||||
float disk_total; // GB
|
||||
float net_in; // Kb/s
|
||||
float net_out; // Kb/s
|
||||
float io_read; // Mb/s
|
||||
float io_write; // Mb/s
|
||||
float io_read_disk; // Mb/s
|
||||
float io_write_disk; // Mb/s
|
||||
int64_t net_in;
|
||||
int64_t net_out;
|
||||
float io_read;
|
||||
float io_write;
|
||||
float io_read_disk;
|
||||
float io_write_disk;
|
||||
int32_t req_select;
|
||||
float req_select_rate;
|
||||
int32_t req_insert;
|
||||
|
|
|
@ -45,8 +45,8 @@ int32_t taosGetSysMemory(int64_t *usedKB);
|
|||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
||||
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);
|
||||
int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes);
|
||||
int32_t taosGetBandSpeed(float *bandSpeedKb);
|
||||
|
||||
int32_t taosSystem(const char *cmd);
|
||||
void taosKillSystem();
|
||||
|
|
|
@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
|||
|
||||
int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||
SMonGrantInfo *pGrantInfo);
|
||||
int8_t dndIsMnode(SDnode *pDnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -486,26 +486,25 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
|||
taosGetProcMemory(&pInfo->mem_engine);
|
||||
taosGetSysMemory(&pInfo->mem_system);
|
||||
pInfo->mem_total = tsTotalMemoryKB;
|
||||
pInfo->disk_engine = 4.1;
|
||||
pInfo->disk_used = 4.2;
|
||||
pInfo->disk_total = 4.3;
|
||||
pInfo->net_in = 5.1;
|
||||
pInfo->net_out = 5.2;
|
||||
pInfo->disk_engine = 0;
|
||||
pInfo->disk_used = tsDataSpace.size.used / (1024 * 1024 * 1024.0);
|
||||
pInfo->disk_total = tsDataSpace.size.avail / (1024 * 1024 * 1024.0);
|
||||
taosGetCardInfo(NULL, &pInfo->net_in, &pInfo->net_out);
|
||||
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;
|
||||
pInfo->req_insert_success = 10;
|
||||
pInfo->req_insert_rate = 10.1;
|
||||
pInfo->req_insert_batch = 11;
|
||||
pInfo->req_insert_batch_success = 12;
|
||||
pInfo->req_insert_batch_rate = 12.3;
|
||||
pInfo->errors = 4;
|
||||
pInfo->vnodes_num = 5;
|
||||
pInfo->masters = 6;
|
||||
pInfo->has_mnode = 1;
|
||||
pInfo->req_select = 0;
|
||||
pInfo->req_select_rate = 0;
|
||||
pInfo->req_insert = 0;
|
||||
pInfo->req_insert_success = 0;
|
||||
pInfo->req_insert_rate = 0;
|
||||
pInfo->req_insert_batch = 0;
|
||||
pInfo->req_insert_batch_success = 0;
|
||||
pInfo->req_insert_batch_rate = 0;
|
||||
pInfo->errors = 0;
|
||||
pInfo->vnodes_num = 0;
|
||||
pInfo->masters = 0;
|
||||
pInfo->has_mnode = dndIsMnode(pDnode);
|
||||
}
|
||||
|
||||
static void dndSendMonitorReport(SDnode *pDnode) {
|
||||
|
|
|
@ -639,4 +639,11 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
|
|||
int32_t code = mndGetMonitorInfo(pMnode, pClusterInfo, pVgroupInfo, pGrantInfo);
|
||||
dndReleaseMnode(pDnode, pMnode);
|
||||
return code;
|
||||
}
|
||||
|
||||
int8_t dndIsMnode(SDnode *pDnode) {
|
||||
SMnode *pMnode = dndAcquireMnode(pDnode);
|
||||
if (pMnode == NULL) return 0;
|
||||
dndReleaseMnode(pDnode, pMnode);
|
||||
return 1;
|
||||
}
|
|
@ -112,16 +112,16 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
|||
}
|
||||
}
|
||||
|
||||
bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
if (bytes) *bytes = 0;
|
||||
if (rbytes) *rbytes = 0;
|
||||
if (tbytes) *tbytes = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool taosGetBandSpeed(float *bandSpeedKb) {
|
||||
int32_t taosGetBandSpeed(float *bandSpeedKb) {
|
||||
*bandSpeedKb = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
|
||||
|
@ -271,16 +271,16 @@ int32_t taosGetProcIO(float *readKB, float *writeKB) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
if (bytes) *bytes = 0;
|
||||
if (rbytes) *rbytes = 0;
|
||||
if (tbytes) *tbytes = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool taosGetBandSpeed(float *bandSpeedKb) {
|
||||
int32_t taosGetBandSpeed(float *bandSpeedKb) {
|
||||
*bandSpeedKb = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
||||
|
@ -544,13 +544,13 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
|||
}
|
||||
}
|
||||
|
||||
bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
*bytes = 0;
|
||||
int32_t taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
||||
if (bytes) *bytes = 0;
|
||||
// FILE *fp = fopen(tsSysNetFile, "r");
|
||||
TdFilePtr pFile = taosOpenFile(tsSysNetFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (pFile == NULL) {
|
||||
// printf("open file:%s failed", tsSysNetFile);
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t _bytes = 0;
|
||||
|
@ -586,37 +586,37 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
|
|||
nouse0, &o_rbytes, &rpackts, &nouse1, &nouse2, &nouse3, &nouse4, &nouse5, &nouse6, &o_tbytes, &tpackets);
|
||||
if (rbytes) *rbytes = o_rbytes;
|
||||
if (tbytes) *tbytes = o_tbytes;
|
||||
*bytes += (o_rbytes + o_tbytes);
|
||||
if (bytes) *bytes += (o_rbytes + o_tbytes);
|
||||
}
|
||||
|
||||
if (line != NULL) tfree(line);
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool taosGetBandSpeed(float *bandSpeedKb) {
|
||||
int32_t taosGetBandSpeed(float *bandSpeedKb) {
|
||||
static int64_t lastBytes = 0;
|
||||
static time_t lastTime = 0;
|
||||
int64_t curBytes = 0;
|
||||
time_t curTime = time(NULL);
|
||||
|
||||
if (!taosGetCardInfo(&curBytes, NULL, NULL)) {
|
||||
return false;
|
||||
if (taosGetCardInfo(&curBytes, NULL, NULL) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lastTime == 0 || lastBytes == 0) {
|
||||
lastTime = curTime;
|
||||
lastBytes = curBytes;
|
||||
*bandSpeedKb = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lastTime >= curTime || lastBytes > curBytes) {
|
||||
lastTime = curTime;
|
||||
lastBytes = curBytes;
|
||||
*bandSpeedKb = 0;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double totalBytes = (double)(curBytes - lastBytes) / 1024 * 8; // Kb
|
||||
|
@ -628,7 +628,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
|
|||
lastTime = curTime;
|
||||
lastBytes = curBytes;
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t taosReadProcIO(int64_t *rchars, int64_t *wchars) {
|
||||
|
|
Loading…
Reference in New Issue