提交 64cc76ca 编写于 作者: G Ganlin Zhao

add enable button

上级 00c3be67
...@@ -148,10 +148,13 @@ extern int32_t tsHttpKeepAlive; ...@@ -148,10 +148,13 @@ extern int32_t tsHttpKeepAlive;
extern int8_t tsEnableMonitorModule; extern int8_t tsEnableMonitorModule;
extern int8_t tsMonitorReplica; extern int8_t tsMonitorReplica;
extern char tsMonitorDbName[]; extern char tsMonitorDbName[];
extern char tsAuditDbName[];
extern char tsInternalPass[]; extern char tsInternalPass[];
extern int32_t tsMonitorInterval; extern int32_t tsMonitorInterval;
// audit
extern int8_t tsEnableAudit;
extern char tsAuditDbName[];
// stream // stream
extern int8_t tsEnableStream; extern int8_t tsEnableStream;
......
...@@ -197,10 +197,13 @@ int32_t tsHttpKeepAlive = 30000; ...@@ -197,10 +197,13 @@ int32_t tsHttpKeepAlive = 30000;
int8_t tsEnableMonitorModule = 1; int8_t tsEnableMonitorModule = 1;
int8_t tsMonitorReplica = 1; int8_t tsMonitorReplica = 1;
char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log"; char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log";
char tsAuditDbName[TSDB_DB_NAME_LEN] = "audit";
char tsInternalPass[] = "secretkey"; char tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30; // seconds int32_t tsMonitorInterval = 30; // seconds
// audit
int8_t tsEnableAudit = 1;
char tsAuditDbName[TSDB_DB_NAME_LEN] = "audit";
// stream // stream
int8_t tsEnableStream = 1; int8_t tsEnableStream = 1;
...@@ -1288,6 +1291,16 @@ static void doInitGlobalConfig(void) { ...@@ -1288,6 +1291,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); 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.option = "stream";
cfg.ptr = &tsEnableStream; cfg.ptr = &tsEnableStream;
cfg.valType = TAOS_CFG_VTYPE_INT8; cfg.valType = TAOS_CFG_VTYPE_INT8;
......
...@@ -1476,6 +1476,10 @@ static bool monConvDDLType2Str(int8_t type, char *buf, int32_t len) { ...@@ -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) { 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 sql[1024] = {0};
char typeStr[64] = {0}; char typeStr[64] = {0};
...@@ -1502,9 +1506,9 @@ void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result ...@@ -1502,9 +1506,9 @@ void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result
taos_free_result(res); taos_free_result(res);
if (code != 0) { 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 { } else {
monDebug("successfully save audit info, sql:%s", sql); monDebug("successfully save audit ddl info, sql:%s", sql);
} }
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
extern "C" { extern "C" {
#endif #endif
#define TSDB_CFG_MAX_NUM 137 #define TSDB_CFG_MAX_NUM 138
#define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41 #define TSDB_CFG_VALUE_LEN 41
......
...@@ -32,20 +32,20 @@ int32_t tsGlobalConfigNum = 0; ...@@ -32,20 +32,20 @@ int32_t tsGlobalConfigNum = 0;
} }
static char *tsGlobalUnit[] = { static char *tsGlobalUnit[] = {
" ", " ",
"(%)", "(%)",
"(GB)", "(GB)",
"(Mb)", "(Mb)",
"(byte)", "(byte)",
"(s)", "(s)",
"(ms)" "(ms)"
}; };
char *tsCfgStatusStr[] = { char *tsCfgStatusStr[] = {
"none", "none",
"system default", "system default",
"config file", "config file",
"taos_options", "taos_options",
"program argument list" "program argument list"
}; };
...@@ -335,7 +335,7 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v ...@@ -335,7 +335,7 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v
taosReadDataDirCfg(value, value2, value3); taosReadDataDirCfg(value, value2, value3);
ret = true; ret = true;
} else { } else {
ret = false; ret = false;
} }
break; break;
default: default:
...@@ -365,8 +365,8 @@ void taosReadGlobalLogCfg() { ...@@ -365,8 +365,8 @@ void taosReadGlobalLogCfg() {
wordfree(&full_path); wordfree(&full_path);
return; 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) { 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); 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); wordfree(&full_path);
...@@ -380,7 +380,7 @@ void taosReadGlobalLogCfg() { ...@@ -380,7 +380,7 @@ void taosReadGlobalLogCfg() {
wordfree(&full_path); wordfree(&full_path);
taosReadLogOption("logDir", tsLogDir); taosReadLogOption("logDir", tsLogDir);
sprintf(fileName, "%s/taos.cfg", configDir); sprintf(fileName, "%s/taos.cfg", configDir);
fp = fopen(fileName, "r"); fp = fopen(fileName, "r");
if (fp == NULL) { if (fp == NULL) {
...@@ -391,10 +391,10 @@ void taosReadGlobalLogCfg() { ...@@ -391,10 +391,10 @@ void taosReadGlobalLogCfg() {
ssize_t _bytes = 0; ssize_t _bytes = 0;
size_t len = 1024; size_t len = 1024;
line = calloc(1, len); line = calloc(1, len);
while (!feof(fp)) { while (!feof(fp)) {
memset(line, 0, len); memset(line, 0, len);
option = value = NULL; option = value = NULL;
olen = vlen = 0; olen = vlen = 0;
...@@ -443,7 +443,7 @@ bool taosReadGlobalCfg() { ...@@ -443,7 +443,7 @@ bool taosReadGlobalCfg() {
ssize_t _bytes = 0; ssize_t _bytes = 0;
size_t len = 1024; size_t len = 1024;
line = calloc(1, len); line = calloc(1, len);
while (!feof(fp)) { while (!feof(fp)) {
memset(line, 0, len); memset(line, 0, len);
...@@ -457,7 +457,7 @@ bool taosReadGlobalCfg() { ...@@ -457,7 +457,7 @@ bool taosReadGlobalCfg() {
} }
line[len - 1] = 0; line[len - 1] = 0;
paGetToken(line, &option, &olen); paGetToken(line, &option, &olen);
if (olen == 0) continue; if (olen == 0) continue;
option[olen] = 0; option[olen] = 0;
...@@ -495,7 +495,7 @@ void taosPrintGlobalCfg() { ...@@ -495,7 +495,7 @@ void taosPrintGlobalCfg() {
SGlobalCfg *cfg = tsGlobalConfig + i; SGlobalCfg *cfg = tsGlobalConfig + i;
if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue; if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue; if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
int optionLen = (int)strlen(cfg->option); int optionLen = (int)strlen(cfg->option);
int blankLen = TSDB_CFG_PRINT_LEN - optionLen; int blankLen = TSDB_CFG_PRINT_LEN - optionLen;
blankLen = blankLen < 0 ? 0 : blankLen; blankLen = blankLen < 0 ? 0 : blankLen;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册