提交 2054cdce 编写于 作者: D dmchen

clusterid

上级 04d97168
......@@ -23,6 +23,7 @@
#include "tjson.h"
#include "tmsgcb.h"
#include "trpc.h"
#include "mnode.h"
#ifdef __cplusplus
extern "C" {
......@@ -36,7 +37,7 @@ typedef struct {
int32_t auditInit(const SAuditCfg *pCfg);
void auditSend(SJson *pJson);
void auditRecord(SRpcMsg *pReq, char *operation, char *target1, char *target2, int32_t len, char *detail);
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail);
#ifdef __cplusplus
}
......
......@@ -736,7 +736,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
code = mndCreateDb(pMnode, pReq, &createReq, pUser);
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "createDB", createReq.db, "", createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createDB", createReq.db, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -980,7 +980,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
}
auditRecord(pReq, "alterDB", alterReq.db, "", alterReq.sqlLen, alterReq.sql);
auditRecord(pReq, pMnode->clusterId, "alterDB", alterReq.db, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -1271,7 +1271,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
code = TSDB_CODE_ACTION_IN_PROGRESS;
}
auditRecord(pReq, "dropDB", dropReq.db, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropDB", dropReq.db, "", "");
_OVER:
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -913,7 +913,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
sprintf(detail, "%s:%d",
createReq.fqdn, createReq.port);
auditRecord(pReq, "createDnode", detail, "", createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createDnode", detail, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -1068,7 +1068,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
char obj2[10] = {0};
sprintf(obj2, "%d", dropReq.dnodeId);
auditRecord(pReq, "dropDnode", obj1, obj2, dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropDnode", obj1, obj2, "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -1206,7 +1206,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
char detail[50] = {0};
sprintf(detail, "%d", cfgReq.dnodeId);
auditRecord(pReq, "alterDnode", detail, "", cfgReq.sqlLen, cfgReq.sql);
auditRecord(pReq, pMnode->clusterId, "alterDnode", detail, "", "");
int32_t code = -1;
SSdb *pSdb = pMnode->pSdb;
......
......@@ -660,7 +660,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
sprintf(detail, "dnodeId:%d", createReq.dnodeId);
auditRecord(pReq, "createMnode", obj, detail, createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createMnode", obj, detail, "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -801,7 +801,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
char obj[20] = {0};
sprintf(obj, "%d", dropReq.dnodeId);
auditRecord(pReq, "dropMnode", obj, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropMnode", obj, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -317,7 +317,7 @@ _CONNECT:
sprintf(detail, "user:%s, from:%s, connType%d",
connReq.user, obj, connReq.connType);
auditRecord(pReq, "login", connReq.app, obj, strlen(detail), detail);
auditRecord(pReq, pMnode->clusterId, "login", connReq.app, obj, detail);
_OVER:
......
......@@ -310,7 +310,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
char obj[33] = {0};
sprintf(obj, "%d", createReq.dnodeId);
auditRecord(pReq, "createQnode", obj, "", createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createQnode", obj, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("qnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
......@@ -423,7 +423,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
char obj[33] = {0};
sprintf(obj, "%d", dropReq.dnodeId);
auditRecord(pReq, "createQnode", obj, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "createQnode", obj, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -1134,7 +1134,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
}
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "createStb", pDb->name, createReq.name, createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createStb", pDb->name, createReq.name, "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -2204,7 +2204,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
code = mndAlterStb(pMnode, pReq, &alterReq, pDb, pStb);
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "alterStb", pDb->name, alterReq.name, alterReq.sqlLen, alterReq.sql);
auditRecord(pReq, pMnode->clusterId, "alterStb", pDb->name, alterReq.name, "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -2466,7 +2466,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
code = mndDropStb(pMnode, pReq, pDb, pStb);
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "dropStb", pDb->name, dropReq.name, dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropStb", pDb->name, dropReq.name, "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -829,7 +829,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "createStream", createStreamReq.name, "", createStreamReq.sqlLen, createStreamReq.sql);
auditRecord(pReq, pMnode->clusterId, "createStream", createStreamReq.name, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -1076,7 +1076,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
return -1;
}
auditRecord(pReq, "dropStream", dropReq.name, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropStream", dropReq.name, "", "");
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
......
......@@ -622,8 +622,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
code = TSDB_CODE_ACTION_IN_PROGRESS;
}
auditRecord(pReq, "crateTopic", createTopicReq.name, createTopicReq.subDbName,
createTopicReq.sqlLen, createTopicReq.sql);
auditRecord(pReq, pMnode->clusterId, "crateTopic", createTopicReq.name, createTopicReq.subDbName, createTopicReq.sql);
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -816,7 +815,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
return -1;
}
auditRecord(pReq, "dropTopic", dropReq.name, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropTopic", dropReq.name, "", dropReq.sql);
return TSDB_CODE_ACTION_IN_PROGRESS;
}
......
......@@ -656,7 +656,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
code = mndCreateUser(pMnode, pOperUser->acct, &createReq, pReq);
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "createUser", createReq.user, "", createReq.sqlLen, createReq.sql);
auditRecord(pReq, pMnode->clusterId, "createUser", createReq.user, "", "");
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -974,12 +974,12 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
if(alterReq.alterType == TSDB_ALTER_USER_PASSWD){
auditRecord(pReq, "changePassword", alterReq.user, alterReq.objname, 0, "");
auditRecord(pReq, pMnode->clusterId, "changePassword", alterReq.user, alterReq.objname, "");
}
else if(alterReq.alterType == TSDB_ALTER_USER_SUPERUSER ||
alterReq.alterType == TSDB_ALTER_USER_ENABLE ||
alterReq.alterType == TSDB_ALTER_USER_SYSINFO){
auditRecord(pReq, "alterUser", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql);
auditRecord(pReq, pMnode->clusterId, "alterUser", alterReq.user, alterReq.objname, "");
}
else if(alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB||
alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB||
......@@ -988,10 +988,10 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
alterReq.alterType == TSDB_ALTER_USER_ADD_READ_TABLE||
alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_TABLE||
alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_TABLE){
auditRecord(pReq, "GrantPrivileges", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql);
auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", alterReq.user, alterReq.objname, "");
}
else{
auditRecord(pReq, "RevokePrivileges", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql);
auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", alterReq.user, alterReq.objname, "");
}
_OVER:
......@@ -1063,7 +1063,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
code = mndDropUser(pMnode, pReq, pUser);
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
auditRecord(pReq, "dropUser", dropReq.user, "", dropReq.sqlLen, dropReq.sql);
auditRecord(pReq, pMnode->clusterId, "dropUser", dropReq.user, "", dropReq.sql);
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -2175,7 +2175,7 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
char obj[33] = {0};
sprintf(obj, "%d", req.vgId);
auditRecord(pReq, "RedistributeVgroup", obj, "", req.sqlLen, req.sql);
auditRecord(pReq, pMnode->clusterId, "RedistributeVgroup", obj, "", req.sql);
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......@@ -2987,7 +2987,7 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
code = mndBalanceVgroup(pMnode, pReq, pArray);
}
auditRecord(pReq, "BalanceVgroup", "", "", req.sqlLen, req.sql);
auditRecord(pReq, pMnode->clusterId, "balanceVgroup", "", "", req.sql);
_OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
......
......@@ -860,7 +860,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
taosArrayPush(rsp.pArray, &cRsp);
auditRecord(pReq, "createTable", pVnode->config.dbname, pCreateReq->name, pCreateReq->sqlLen, pCreateReq->sql);
int32_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId;
auditRecord(pReq, clusterId, "createTable", pVnode->config.dbname, pCreateReq->name, "");
}
vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids));
......
......@@ -10,4 +10,4 @@ target_include_directories(
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
target_link_libraries(audit os util common transport)
target_link_libraries(audit os util common transport mnode)
......@@ -20,6 +20,7 @@
#include "ttime.h"
#include "tjson.h"
#include "tglobal.h"
#include "mnode.h"
SAudit tsAudit = {0};
char* tsAuditUri = "/audit";
......@@ -29,14 +30,14 @@ int32_t auditInit(const SAuditCfg *pCfg) {
return 0;
}
extern void auditRecordImp(SRpcMsg *pReq, char *operation, char *target1, char *target2, int32_t len, char *detail);
extern void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail);
void auditRecord(SRpcMsg *pReq, char *operation, char *target1, char *target2, int32_t len, char *detail) {
auditRecordImp(pReq, operation, target1, target2, len, detail);
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail) {
auditRecordImp(pReq, clusterId, operation, target1, target2, detail);
}
#ifndef TD_ENTERPRISE
void auditRecordImp(SRpcMsg *pReq, char *operation, char *target1, char *target2, int32_t len, char *detail) {
void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail) {
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册