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