diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index f1f4db726527b71128d637406fae305272a2513d..5462e2f468d1b2b5f0d7d67f17b202e118b56f3b 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -199,6 +199,9 @@ int32_t sDebugFlag = 135; int32_t wDebugFlag = 135; int32_t tsdbDebugFlag = 131; +int32_t (*monitorStartSystemFp)() = NULL; +void (*monitorStopSystemFp)() = NULL; + static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; void taosSetAllDebugFlag() { @@ -248,11 +251,17 @@ bool taosCfgDynamicOptions(char *msg) { *((int32_t *)cfg->ptr) = vint; if (strncasecmp(cfg->option, "monitor", olen) == 0) { - // if (0 == vint) { - // monitorStartSystem(); - // } else { - // monitorStopSystem(); - // } + if (1 == vint) { + if (monitorStartSystemFp) { + (*monitorStartSystemFp)(); + uInfo("monitor is enabled"); + } + } else { + if (monitorStopSystemFp) { + (*monitorStopSystemFp)(); + uInfo("monitor is disabled"); + } + } return true; } diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index 22cb111b83dc55b7abc46b301c423ded5a9155b9..e6e8cf982b0c5b7912742e4603f065d6ac404c31 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -76,6 +76,8 @@ static void monitorInitDatabase(); static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code); static void monitorStartTimer(); static void monitorSaveSystemInfo(); +extern int32_t (*monitorStartSystemFp)(); +extern void (*monitorStopSystemFp)(); static void monitorCheckDiskUsage(void *para, void *unused) { taosGetDisk(); @@ -85,6 +87,8 @@ static void monitorCheckDiskUsage(void *para, void *unused) { int32_t monitorInitSystem() { taos_init(); taosTmrReset(monitorCheckDiskUsage, CHECK_INTERVAL, NULL, tscTmr, &tsMonitorConn.diskTimer); + monitorStartSystemFp = monitorStartSystem; + monitorStopSystemFp = monitorStopSystem; return 0; }