enh/TD-31977-monitor-qid
This commit is contained in:
parent
3768675d16
commit
f01d166b3c
|
@ -49,6 +49,7 @@ typedef struct {
|
||||||
} SAuditRecord;
|
} SAuditRecord;
|
||||||
|
|
||||||
int32_t auditInit(const SAuditCfg *pCfg);
|
int32_t auditInit(const SAuditCfg *pCfg);
|
||||||
|
void auditOpen(int32_t dnodeId);
|
||||||
void auditCleanup();
|
void auditCleanup();
|
||||||
int32_t auditSend(SJson *pJson);
|
int32_t auditSend(SJson *pJson);
|
||||||
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||||
|
|
|
@ -218,6 +218,7 @@ typedef struct {
|
||||||
} SDmNotifyHandle;
|
} SDmNotifyHandle;
|
||||||
|
|
||||||
int32_t monInit(const SMonCfg *pCfg);
|
int32_t monInit(const SMonCfg *pCfg);
|
||||||
|
void monOpen(int32_t dnodeId);
|
||||||
void monInitVnode();
|
void monInitVnode();
|
||||||
void monCleanup();
|
void monCleanup();
|
||||||
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
||||||
|
|
|
@ -37,3 +37,14 @@ int32_t tGenIdPI32(void);
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int64_t tGenIdPI64(void);
|
int64_t tGenIdPI64(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an qid
|
||||||
|
*+------------+-----+-----------+---------------+
|
||||||
|
*| nodeid| 0| serial number | 0 |
|
||||||
|
*+------------+-----+-----------+---------------+
|
||||||
|
*| 8bit | 16bit|32bit |8bit |
|
||||||
|
*+------------+-----+-----------+---------------+
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int64_t tGenQid64(int8_t dnodeId);
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
|
#include "dmUtil.h"
|
||||||
|
#include "monitor.h"
|
||||||
|
#include "audit.h"
|
||||||
|
|
||||||
int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -98,6 +101,9 @@ static int32_t dmOpenNodes(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auditOpen(dmGetDnodeId(&pDnode->data));
|
||||||
|
monOpen(dmGetDnodeId(&pDnode->data));
|
||||||
|
|
||||||
dmSetStatus(pDnode, DND_STAT_RUNNING);
|
dmSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,6 +217,7 @@ int32_t dmInitDndInfo(SDnodeData *pData);
|
||||||
|
|
||||||
// dmEps.c
|
// dmEps.c
|
||||||
int32_t dmGetDnodeSize(SDnodeData *pData);
|
int32_t dmGetDnodeSize(SDnodeData *pData);
|
||||||
|
int32_t dmGetDnodeId(SDnodeData *pData);
|
||||||
int32_t dmReadEps(SDnodeData *pData);
|
int32_t dmReadEps(SDnodeData *pData);
|
||||||
int32_t dmWriteEps(SDnodeData *pData);
|
int32_t dmWriteEps(SDnodeData *pData);
|
||||||
void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps);
|
void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps);
|
||||||
|
|
|
@ -66,3 +66,5 @@ void dmGetMonitorSystemInfo(SMonSysInfo *pInfo) {
|
||||||
taosGetCardInfoDelta(&pInfo->net_in, &pInfo->net_out);
|
taosGetCardInfoDelta(&pInfo->net_in, &pInfo->net_out);
|
||||||
taosGetProcIODelta(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
taosGetProcIODelta(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dmGetDnodeId(SDnodeData *pData) { return pData->dnodeId; }
|
|
@ -23,6 +23,7 @@ typedef struct {
|
||||||
SAuditCfg cfg;
|
SAuditCfg cfg;
|
||||||
SArray *records;
|
SArray *records;
|
||||||
TdThreadMutex lock;
|
TdThreadMutex lock;
|
||||||
|
int32_t dnodeId;
|
||||||
} SAudit;
|
} SAudit;
|
||||||
|
|
||||||
#endif /*_TD_AUDIT_INT_H_*/
|
#endif /*_TD_AUDIT_INT_H_*/
|
||||||
|
|
|
@ -36,6 +36,8 @@ int32_t auditInit(const SAuditCfg *pCfg) {
|
||||||
return taosThreadMutexInit(&tsAudit.lock, NULL);
|
return taosThreadMutexInit(&tsAudit.lock, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void auditOpen(int32_t dnodeId) { tsAudit.dnodeId = dnodeId; }
|
||||||
|
|
||||||
static FORCE_INLINE void auditDeleteRecord(SAuditRecord * record) {
|
static FORCE_INLINE void auditDeleteRecord(SAuditRecord * record) {
|
||||||
if (record) {
|
if (record) {
|
||||||
taosMemoryFree(record->detail);
|
taosMemoryFree(record->detail);
|
||||||
|
|
|
@ -47,6 +47,7 @@ typedef struct {
|
||||||
SMonQmInfo qmInfo;
|
SMonQmInfo qmInfo;
|
||||||
SMonBmInfo bmInfo;
|
SMonBmInfo bmInfo;
|
||||||
SHashObj *metrics;
|
SHashObj *metrics;
|
||||||
|
int32_t dnodeId;
|
||||||
} SMonitor;
|
} SMonitor;
|
||||||
|
|
||||||
void monGenClusterInfoTable(SMonInfo *pMonitor);
|
void monGenClusterInfoTable(SMonInfo *pMonitor);
|
||||||
|
|
|
@ -767,9 +767,12 @@ void monSendPromReport() {
|
||||||
}
|
}
|
||||||
if (pCont != NULL) {
|
if (pCont != NULL) {
|
||||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
char tmp[100] = {0};
|
||||||
|
(void)sprintf(tmp, "%s?qid=%" PRId64, tsMonFwUri, tGenQid64(tsMonitor.dnodeId));
|
||||||
|
uDebug("report cont to %s", tmp);
|
||||||
|
if (taosSendHttpReport(tsMonitor.cfg.server, tmp, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg");
|
uError("failed to send monitor msg");
|
||||||
}else{
|
} else {
|
||||||
(void)taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
(void)taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pCont);
|
taosMemoryFreeClear(pCont);
|
||||||
|
|
|
@ -131,6 +131,8 @@ int32_t monInit(const SMonCfg *pCfg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void monOpen(int32_t dnodeId) { tsMonitor.dnodeId = dnodeId; }
|
||||||
|
|
||||||
void monInitVnode() {
|
void monInitVnode() {
|
||||||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||||
if (tsInsertCounter == NULL) {
|
if (tsInsertCounter == NULL) {
|
||||||
|
@ -599,7 +601,10 @@ void monSendReport(SMonInfo *pMonitor) {
|
||||||
}
|
}
|
||||||
if (pCont != NULL) {
|
if (pCont != NULL) {
|
||||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
char tmp[100] = {0};
|
||||||
|
(void)sprintf(tmp, "%s?qid=%" PRId64, tsMonUri, tGenQid64(tsMonitor.dnodeId));
|
||||||
|
uDebug("report cont to %s", tmp);
|
||||||
|
if (taosSendHttpReport(tsMonitor.cfg.server, tmp, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg");
|
uError("failed to send monitor msg");
|
||||||
}
|
}
|
||||||
taosMemoryFree(pCont);
|
taosMemoryFree(pCont);
|
||||||
|
@ -617,8 +622,10 @@ void monSendReportBasic(SMonInfo *pMonitor) {
|
||||||
}
|
}
|
||||||
if (pCont != NULL) {
|
if (pCont != NULL) {
|
||||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwBasicUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) !=
|
char tmp[100] = {0};
|
||||||
0) {
|
(void)sprintf(tmp, "%s?qid=%" PRId64, tsMonFwBasicUri, tGenQid64(tsMonitor.dnodeId));
|
||||||
|
uDebug("report cont basic to %s", tmp);
|
||||||
|
if (taosSendHttpReport(tsMonitor.cfg.server, tmp, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg");
|
uError("failed to send monitor msg");
|
||||||
}
|
}
|
||||||
taosMemoryFree(pCont);
|
taosMemoryFree(pCont);
|
||||||
|
@ -669,8 +676,11 @@ void monSendContent(char *pCont, const char *uri) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pCont != NULL) {
|
if (pCont != NULL) {
|
||||||
|
char tmp[100] = {0};
|
||||||
|
(void)sprintf(tmp, "%s?qid=%" PRId64, uri, tGenQid64(tsMonitor.dnodeId));
|
||||||
|
uInfoL("report client cont to %s", tmp);
|
||||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, uri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
if (taosSendHttpReport(tsMonitor.cfg.server, tmp, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg");
|
uError("failed to send monitor msg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,3 +65,18 @@ int64_t tGenIdPI64(void) {
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t tGenQid64(int8_t dnodeId) {
|
||||||
|
int64_t id = dnodeId;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1);
|
||||||
|
|
||||||
|
id = (id << 56) | (val & 0xFFFFF) << 8;
|
||||||
|
if (id) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
Loading…
Reference in New Issue