forward client directly
This commit is contained in:
parent
cd80560c94
commit
e5dcef0794
|
@ -225,6 +225,7 @@ void monSetSmInfo(SMonSmInfo *pInfo);
|
||||||
void monSetBmInfo(SMonBmInfo *pInfo);
|
void monSetBmInfo(SMonBmInfo *pInfo);
|
||||||
void monGenAndSendReport();
|
void monGenAndSendReport();
|
||||||
void monGenAndSendReportBasic();
|
void monGenAndSendReportBasic();
|
||||||
|
void monSendContent(char *pCont);
|
||||||
|
|
||||||
void tFreeSMonMmInfo(SMonMmInfo *pInfo);
|
void tFreeSMonMmInfo(SMonMmInfo *pInfo);
|
||||||
void tFreeSMonVmInfo(SMonVmInfo *pInfo);
|
void tFreeSMonVmInfo(SMonVmInfo *pInfo);
|
||||||
|
|
|
@ -103,6 +103,7 @@ char* tjsonToUnformattedString(const SJson* pJson);
|
||||||
SJson* tjsonParse(const char* pStr);
|
SJson* tjsonParse(const char* pStr);
|
||||||
bool tjsonValidateJson(const char* pJson);
|
bool tjsonValidateJson(const char* pJson);
|
||||||
const char* tjsonGetError();
|
const char* tjsonGetError();
|
||||||
|
void tjsonDeleteItemFromObject(const SJson* pJson, const char* pName);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,7 +506,7 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsMonitorLogProtocol){
|
if(tsMonitorLogProtocol){
|
||||||
|
@ -517,6 +517,63 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
int32_t ts_size = tjsonGetArraySize(pJson);
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < ts_size; i++){
|
||||||
|
SJson* item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
|
SJson* tables = tjsonGetObjectItem(item, "tables");
|
||||||
|
|
||||||
|
int32_t tableSize = tjsonGetArraySize(tables);
|
||||||
|
for(int32_t i = 0; i < tableSize; i++){
|
||||||
|
SJson* table = tjsonGetArrayItem(tables, i);
|
||||||
|
|
||||||
|
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
||||||
|
tjsonGetStringValue(table, "name", tableName);
|
||||||
|
|
||||||
|
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
||||||
|
|
||||||
|
int32_t size = tjsonGetArraySize(metricGroups);
|
||||||
|
for(int32_t i = 0; i < size; i++){
|
||||||
|
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
||||||
|
|
||||||
|
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
||||||
|
|
||||||
|
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
||||||
|
for(int32_t j = 0; j < tagSize; j++){
|
||||||
|
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
||||||
|
|
||||||
|
char tagName[MONITOR_TAG_NAME_LEN] = {0};
|
||||||
|
tjsonGetStringValue(item, "name", tagName);
|
||||||
|
|
||||||
|
if(strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
||||||
|
tjsonDeleteItemFromObject(item, "value");
|
||||||
|
tjsonAddStringToObject(item, "value", strClusterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pCont = tjsonToString(pJson);
|
||||||
|
monSendContent(pCont);
|
||||||
|
|
||||||
|
if(pJson != NULL){
|
||||||
|
tjsonDelete(pJson);
|
||||||
|
pJson = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pCont != NULL){
|
||||||
|
taosMemoryFree(pCont);
|
||||||
|
pCont = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tFreeSStatisReq(&statisReq);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
SJson* pJson = tjsonParse(statisReq.pCont);
|
||||||
|
|
||||||
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
for(int32_t i = 0; i < ts_size; i++){
|
for(int32_t i = 0; i < ts_size; i++){
|
||||||
SJson* item = tjsonGetArrayItem(pJson, i);
|
SJson* item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
|
@ -555,16 +612,6 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*(labels + tagSize) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN);
|
|
||||||
strncpy(*(labels + tagSize), "cluster_id", MONITOR_TAG_NAME_LEN);
|
|
||||||
|
|
||||||
*(sample_labels + tagSize) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
|
|
||||||
strncpy(*(sample_labels + tagSize), strClusterId, MONITOR_TAG_VALUE_LEN);
|
|
||||||
|
|
||||||
tagSize++;
|
|
||||||
*/
|
|
||||||
|
|
||||||
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
||||||
|
|
||||||
int32_t metricLen = tjsonGetArraySize(metrics);
|
int32_t metricLen = tjsonGetArraySize(metrics);
|
||||||
|
@ -647,6 +694,7 @@ _OVER:
|
||||||
|
|
||||||
tFreeSStatisReq(&statisReq);
|
tFreeSStatisReq(&statisReq);
|
||||||
return code;
|
return code;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ typedef struct SQueryNode SQueryNode;
|
||||||
#define VND_INFO_FNAME "vnode.json"
|
#define VND_INFO_FNAME "vnode.json"
|
||||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||||
|
|
||||||
#define VNODE_METRIC_SQL_COUNT "taos_sql_req:inserted_rows"
|
#define VNODE_METRIC_SQL_COUNT "taos_sql_req:count"
|
||||||
|
|
||||||
#define VNODE_METRIC_TAG_NAME_SQL_TYPE "sql_type"
|
#define VNODE_METRIC_TAG_NAME_SQL_TYPE "sql_type"
|
||||||
#define VNODE_METRIC_TAG_NAME_CLUSTER_ID "cluster_id"
|
#define VNODE_METRIC_TAG_NAME_CLUSTER_ID "cluster_id"
|
||||||
|
|
|
@ -628,4 +628,19 @@ void monGenAndSendReportBasic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
monCleanupMonitorInfo(pMonitor);
|
monCleanupMonitorInfo(pMonitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void monSendContent(char *pCont) {
|
||||||
|
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||||
|
if(tsMonitorLogProtocol){
|
||||||
|
if (pCont != NULL){
|
||||||
|
uInfoL("report client cont:\n%s\n", pCont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pCont != NULL) {
|
||||||
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
|
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
|
uError("failed to send monitor msg");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -375,4 +375,8 @@ bool tjsonValidateJson(const char* jIn) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tjsonGetError() { return cJSON_GetErrorPtr(); }
|
const char* tjsonGetError() { return cJSON_GetErrorPtr(); }
|
||||||
|
|
||||||
|
void tjsonDeleteItemFromObject(const SJson* pJson, const char* pName) {
|
||||||
|
cJSON_DeleteItemFromObject((cJSON*)pJson, pName);
|
||||||
|
}
|
Loading…
Reference in New Issue