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

add enable button

上级 00c3be67
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册