td-1033: add more infomation to report
This commit is contained in:
parent
b2cd98231a
commit
b0186d1c33
|
@ -22,8 +22,16 @@
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
#include "tbuffer.h"
|
#include "tbuffer.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
#include "mnodeDef.h"
|
||||||
|
#include "mnodeDb.h"
|
||||||
|
#include "mnodeDnode.h"
|
||||||
#include "mnodeCluster.h"
|
#include "mnodeCluster.h"
|
||||||
|
#include "mnodeDnode.h"
|
||||||
|
#include "mnodeVgroup.h"
|
||||||
|
#include "mnodeMnode.h"
|
||||||
|
#include "mnodeTable.h"
|
||||||
#include "mnodeSdb.h"
|
#include "mnodeSdb.h"
|
||||||
|
#include "mnodeAcct.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "dnodeInt.h"
|
#include "dnodeInt.h"
|
||||||
#include "dnodeTelemetry.h"
|
#include "dnodeTelemetry.h"
|
||||||
|
@ -170,18 +178,23 @@ static void addVersionInfo(SBufferWriter* bw) {
|
||||||
addStringField(bw, "version", version);
|
addStringField(bw, "version", version);
|
||||||
addStringField(bw, "buildInfo", buildinfo);
|
addStringField(bw, "buildInfo", buildinfo);
|
||||||
addStringField(bw, "gitInfo", gitinfo);
|
addStringField(bw, "gitInfo", gitinfo);
|
||||||
//addStringField(&bw, "installAt", "2020-08-01T00:00:00Z");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRuntimeInfo(SBufferWriter* bw) {
|
static void addRuntimeInfo(SBufferWriter* bw) {
|
||||||
// addIntField(&bw, "numOfDnode", 1);
|
addIntField(bw, "numOfDnode", mnodeGetDnodesNum());
|
||||||
// addIntField(&bw, "numOfVnode", 1);
|
addIntField(bw, "numOfMnode", mnodeGetMnodesNum());
|
||||||
// addIntField(&bw, "numOfStable", 1);
|
addIntField(bw, "numOfVgroup", mnodeGetVgroupNum());
|
||||||
// addIntField(&bw, "numOfTable", 1);
|
addIntField(bw, "numOfDatabase", mnodeGetDbNum());
|
||||||
// addIntField(&bw, "numOfRows", 1);
|
addIntField(bw, "numOfSuperTable", mnodeGetSuperTableNum());
|
||||||
// addStringField(&bw, "startAt", "2020-08-01T00:00:00Z");
|
addIntField(bw, "numOfChildTable", mnodeGetChildTableNum());
|
||||||
// addStringField(&bw, "memoryUsage", "10240 kB");
|
|
||||||
// addStringField(&bw, "diskUsage", "10240 MB");
|
SAcctInfo info;
|
||||||
|
mnodeGetStatOfAllAcct(&info);
|
||||||
|
addIntField(bw, "numOfColumn", info.numOfTimeSeries);
|
||||||
|
addIntField(bw, "numOfPoint", info.totalPoints);
|
||||||
|
addIntField(bw, "totalStorage", info.totalStorage);
|
||||||
|
addIntField(bw, "compStorage", info.compStorage);
|
||||||
|
// addStringField(bw, "installTime", "2020-08-01T00:00:00Z");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendTelemetryReport() {
|
static void sendTelemetryReport() {
|
||||||
|
@ -230,18 +243,13 @@ static void sendTelemetryReport() {
|
||||||
static void* telemetryThread(void* param) {
|
static void* telemetryThread(void* param) {
|
||||||
struct timespec end = {0};
|
struct timespec end = {0};
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
end.tv_sec += 300; // wait 5 minutes to send first report
|
end.tv_sec += 300; // wait 5 minutes before send first report
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while (1) {
|
if (sem_timedwait(&tsExitSem, &end) == 0) {
|
||||||
if (sem_timedwait(&tsExitSem, &end) == 0) {
|
break;
|
||||||
return NULL;
|
} else if (errno != ETIMEDOUT) {
|
||||||
}
|
continue;
|
||||||
struct timespec now = {0};
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
|
||||||
if (now.tv_sec > end.tv_sec || (now.tv_sec == end.tv_sec && now.tv_nsec >= end.tv_nsec)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdbIsMaster()) {
|
if (sdbIsMaster()) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mnodeInitAccts();
|
int32_t mnodeInitAccts();
|
||||||
void mnodeCleanupAccts();
|
void mnodeCleanupAccts();
|
||||||
|
void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo);
|
||||||
void * mnodeGetAcct(char *acctName);
|
void * mnodeGetAcct(char *acctName);
|
||||||
void * mnodeGetNextAcct(void *pIter, SAcctObj **pAcct);
|
void * mnodeGetNextAcct(void *pIter, SAcctObj **pAcct);
|
||||||
void mnodeIncAcctRef(SAcctObj *pAcct);
|
void mnodeIncAcctRef(SAcctObj *pAcct);
|
||||||
|
|
|
@ -30,6 +30,7 @@ enum _TSDB_DB_STATUS {
|
||||||
// api
|
// api
|
||||||
int32_t mnodeInitDbs();
|
int32_t mnodeInitDbs();
|
||||||
void mnodeCleanupDbs();
|
void mnodeCleanupDbs();
|
||||||
|
int64_t mnodeGetDbNum();
|
||||||
SDbObj *mnodeGetDb(char *db);
|
SDbObj *mnodeGetDb(char *db);
|
||||||
SDbObj *mnodeGetDbByTableId(char *db);
|
SDbObj *mnodeGetDbByTableId(char *db);
|
||||||
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
||||||
|
|
|
@ -24,6 +24,8 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mnodeInitTables();
|
int32_t mnodeInitTables();
|
||||||
void mnodeCleanupTables();
|
void mnodeCleanupTables();
|
||||||
|
int64_t mnodeGetSuperTableNum();
|
||||||
|
int64_t mnodeGetChildTableNum();
|
||||||
void * mnodeGetTable(char *tableId);
|
void * mnodeGetTable(char *tableId);
|
||||||
void mnodeIncTableRef(void *pTable);
|
void mnodeIncTableRef(void *pTable);
|
||||||
void mnodeDecTableRef(void *pTable);
|
void mnodeDecTableRef(void *pTable);
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct SMnodeMsg;
|
||||||
|
|
||||||
int32_t mnodeInitVgroups();
|
int32_t mnodeInitVgroups();
|
||||||
void mnodeCleanupVgroups();
|
void mnodeCleanupVgroups();
|
||||||
|
int64_t mnodeGetVgroupNum();
|
||||||
SVgObj *mnodeGetVgroup(int32_t vgId);
|
SVgObj *mnodeGetVgroup(int32_t vgId);
|
||||||
void mnodeIncVgroupRef(SVgObj *pVgroup);
|
void mnodeIncVgroupRef(SVgObj *pVgroup);
|
||||||
void mnodeDecVgroupRef(SVgObj *pVgroup);
|
void mnodeDecVgroupRef(SVgObj *pVgroup);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "mnodeDb.h"
|
#include "mnodeDb.h"
|
||||||
#include "mnodeSdb.h"
|
#include "mnodeSdb.h"
|
||||||
#include "mnodeUser.h"
|
#include "mnodeUser.h"
|
||||||
|
#include "mnodeVgroup.h"
|
||||||
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
|
||||||
|
@ -130,6 +131,37 @@ void mnodeCleanupAccts() {
|
||||||
tsAcctSdb = NULL;
|
tsAcctSdb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
|
||||||
|
memset(pAcctInfo, 0, sizeof(*pAcctInfo));
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
SAcctObj *pAcct = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = mnodeGetNextAcct(pIter, &pAcct);
|
||||||
|
if (pAcct == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pAcctInfo->numOfDbs += pAcct->acctInfo.numOfDbs;
|
||||||
|
pAcctInfo->numOfTimeSeries += pAcct->acctInfo.numOfTimeSeries;
|
||||||
|
mnodeDecAcctRef(pAcct);
|
||||||
|
}
|
||||||
|
sdbFreeIter(pIter);
|
||||||
|
|
||||||
|
SVgObj *pVgroup = NULL;
|
||||||
|
pIter = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
|
||||||
|
if (pVgroup == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pAcctInfo->totalStorage += pVgroup->totalStorage;
|
||||||
|
pAcctInfo->compStorage += pVgroup->compStorage;
|
||||||
|
pAcctInfo->totalPoints += pVgroup->pointsWritten;
|
||||||
|
mnodeDecVgroupRef(pVgroup);
|
||||||
|
}
|
||||||
|
sdbFreeIter(pIter);
|
||||||
|
}
|
||||||
|
|
||||||
void *mnodeGetAcct(char *name) {
|
void *mnodeGetAcct(char *name) {
|
||||||
return sdbGetRow(tsAcctSdb, name);
|
return sdbGetRow(tsAcctSdb, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@ static int32_t mnodeDbActionDestroy(SSdbOper *pOper) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t mnodeGetDbNum() {
|
||||||
|
return sdbGetNumOfRows(tsDbSdb);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
|
static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
|
||||||
SDbObj *pDb = pOper->pObj;
|
SDbObj *pDb = pOper->pObj;
|
||||||
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
SAcctObj *pAcct = mnodeGetAcct(pDb->acct);
|
||||||
|
|
|
@ -375,6 +375,14 @@ static void mnodeCleanupChildTables() {
|
||||||
tsChildTableSdb = NULL;
|
tsChildTableSdb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t mnodeGetSuperTableNum() {
|
||||||
|
return sdbGetNumOfRows(tsSuperTableSdb);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t mnodeGetChildTableNum() {
|
||||||
|
return sdbGetNumOfRows(tsChildTableSdb);
|
||||||
|
}
|
||||||
|
|
||||||
static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
|
static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
|
||||||
atomic_add_fetch_32(&pStable->numOfTables, 1);
|
atomic_add_fetch_32(&pStable->numOfTables, 1);
|
||||||
|
|
||||||
|
|
|
@ -605,6 +605,10 @@ void mnodeCleanupVgroups() {
|
||||||
tsVgroupSdb = NULL;
|
tsVgroupSdb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t mnodeGetVgroupNum() {
|
||||||
|
return sdbGetNumOfRows(tsVgroupSdb);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
|
static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
SDbObj *pDb = mnodeGetDb(pShow->db);
|
SDbObj *pDb = mnodeGetDb(pShow->db);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue