diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 6d544bb52564d78fc30ad33f3f68744f6b8c7579..20153e76ea4af28996f32778fadf9191e5ccf9d9 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -148,10 +148,13 @@ extern int32_t tsHttpKeepAlive; extern int8_t tsEnableMonitorModule; extern int8_t tsMonitorReplica; extern char tsMonitorDbName[]; -extern char tsAuditDbName[]; extern char tsInternalPass[]; extern int32_t tsMonitorInterval; +// audit +extern int8_t tsEnableAudit; +extern char tsAuditDbName[]; + // stream extern int8_t tsEnableStream; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index de852b885d0160bda70747669ad608e10498769a..57b77d32b09adf99e159405652ffd382f1cf6eae 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -197,10 +197,13 @@ int32_t tsHttpKeepAlive = 30000; int8_t tsEnableMonitorModule = 1; int8_t tsMonitorReplica = 1; char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log"; -char tsAuditDbName[TSDB_DB_NAME_LEN] = "audit"; char tsInternalPass[] = "secretkey"; int32_t tsMonitorInterval = 30; // seconds +// audit +int8_t tsEnableAudit = 1; +char tsAuditDbName[TSDB_DB_NAME_LEN] = "audit"; + // stream int8_t tsEnableStream = 1; @@ -1288,6 +1291,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "audit"; + cfg.ptr = &tsEnableAudit; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "stream"; cfg.ptr = &tsEnableStream; cfg.valType = TAOS_CFG_VTYPE_INT8; diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index acbe7f7f9efe8b36f18da41a81fe8506b83ce540..8ef0031530b50d25fc037feaa68c446e1cb17389 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -1476,6 +1476,10 @@ static bool monConvDDLType2Str(int8_t type, char *buf, int32_t len) { } void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result) { + if (tsEnableAudit == 0) { //audit not enabled + return; + } + char sql[1024] = {0}; char typeStr[64] = {0}; @@ -1502,9 +1506,9 @@ void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result taos_free_result(res); if (code != 0) { - monError("failed to save audit info, reason:%s, sql:%s", tstrerror(code), sql); + monError("failed to save audit ddl info, reason:%s, sql:%s", tstrerror(code), sql); } else { - monDebug("successfully save audit info, sql:%s", sql); + monDebug("successfully save audit ddl info, sql:%s", sql); } } diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index cd46d51de1c595107deb7096b46db64fbf248150..f207b9b5c4dd270cc4364e548449edcbee43ae4a 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 137 +#define TSDB_CFG_MAX_NUM 138 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 11fa0691a41efafdded6d76ee31631f4b631171f..4acaa1111ad81e52ca1da9b4f86bf08b0a00ee34 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -32,20 +32,20 @@ int32_t tsGlobalConfigNum = 0; } static char *tsGlobalUnit[] = { - " ", - "(%)", - "(GB)", - "(Mb)", - "(byte)", - "(s)", + " ", + "(%)", + "(GB)", + "(Mb)", + "(byte)", + "(s)", "(ms)" }; char *tsCfgStatusStr[] = { - "none", - "system default", - "config file", - "taos_options", + "none", + "system default", + "config file", + "taos_options", "program argument list" }; @@ -335,7 +335,7 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v taosReadDataDirCfg(value, value2, value3); ret = true; } else { - ret = false; + ret = false; } break; default: @@ -365,8 +365,8 @@ void taosReadGlobalLogCfg() { wordfree(&full_path); return; } - - if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { + + if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) { printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1); wordfree(&full_path); @@ -380,7 +380,7 @@ void taosReadGlobalLogCfg() { wordfree(&full_path); taosReadLogOption("logDir", tsLogDir); - + sprintf(fileName, "%s/taos.cfg", configDir); fp = fopen(fileName, "r"); if (fp == NULL) { @@ -391,10 +391,10 @@ void taosReadGlobalLogCfg() { ssize_t _bytes = 0; size_t len = 1024; line = calloc(1, len); - + while (!feof(fp)) { memset(line, 0, len); - + option = value = NULL; olen = vlen = 0; @@ -443,7 +443,7 @@ bool taosReadGlobalCfg() { ssize_t _bytes = 0; size_t len = 1024; line = calloc(1, len); - + while (!feof(fp)) { memset(line, 0, len); @@ -457,7 +457,7 @@ bool taosReadGlobalCfg() { } line[len - 1] = 0; - + paGetToken(line, &option, &olen); if (olen == 0) continue; option[olen] = 0; @@ -495,7 +495,7 @@ void taosPrintGlobalCfg() { SGlobalCfg *cfg = tsGlobalConfig + i; if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue; if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue; - + int optionLen = (int)strlen(cfg->option); int blankLen = TSDB_CFG_PRINT_LEN - optionLen; blankLen = blankLen < 0 ? 0 : blankLen;