diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 1cbb3ead9cee61c44f4b311f730f8f23458e72af..aedfb0a6834afbf3c0c8c822b056ea5705f8d2ff 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -272,6 +272,29 @@ function install_config() { break fi done + + # user email + #EMAIL_PATTERN='^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$' + #EMAIL_PATTERN='^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$' + #EMAIL_PATTERN="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" + echo + echo -e -n "${GREEN}Enter your email address for priority support or enter empty to skip${NC}: " + read emailAddr + while true; do + if [ ! -z "$emailAddr" ]; then + # check the format of the emailAddr + #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then + # Write the email address to temp file + email_file="${install_main_dir}/email" + ${csudo} bash -c "echo $emailAddr > ${email_file}" + break + #else + # read -p "Please enter the correct email address: " emailAddr + #fi + else + break + fi + done } diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 798e2654555c9e7ed9ff88c6da10b4a20841b718..515115c323294a67318b5eb1dd17660e651d09f8 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -34,6 +34,7 @@ extern int32_t tsStatusInterval; extern int32_t tsNumOfMnodes; extern int32_t tsEnableVnodeBak; extern int32_t tsEnableTelemetryReporting; +extern char tsEmail[]; // common extern int tsRpcTimer; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 2630e3c468bd43a4c23b2f391e8e25254cbe8672..b34b0e0b086afa10d2ca9e6f49c56f204baf4c37 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -42,6 +42,7 @@ int32_t tsStatusInterval = 1; // second int32_t tsNumOfMnodes = 3; int32_t tsEnableVnodeBak = 1; int32_t tsEnableTelemetryReporting = 1; +char tsEmail[TSDB_FQDN_LEN] = {0}; // common int32_t tsRpcTimer = 1000; diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 8ed4a9518b6c8a80bf79e0c7f326da54fa7d9e83..306e9593e1db513bd152603fd6b8ed8fd1c90eb6 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -41,7 +41,7 @@ static pthread_t tsTelemetryThread; #define TELEMETRY_SERVER "telemetry.taosdata.com" #define TELEMETRY_PORT 80 -#define REPORT_INTERVAL 86400 +#define REPORT_INTERVAL 100 // 86400 static void beginObject(SBufferWriter* bw) { tbufWriteChar(bw, '{'); @@ -177,7 +177,8 @@ static void addMemoryInfo(SBufferWriter* bw) { static void addVersionInfo(SBufferWriter* bw) { addStringField(bw, "version", version); addStringField(bw, "buildInfo", buildinfo); - addStringField(bw, "gitInfo", gitinfo); + addStringField(bw, "gitInfo", gitinfo); + addStringField(bw, "email", tsEmail); } static void addRuntimeInfo(SBufferWriter* bw) { @@ -243,7 +244,7 @@ static void sendTelemetryReport() { static void* telemetryThread(void* param) { struct timespec end = {0}; clock_gettime(CLOCK_REALTIME, &end); - end.tv_sec += 300; // wait 5 minutes before send first report + end.tv_sec += 10; //300; // wait 5 minutes before send first report while (1) { if (sem_timedwait(&tsExitSem, &end) == 0) { @@ -261,11 +262,25 @@ static void* telemetryThread(void* param) { return NULL; } +static void dnodeGetEmail(char* filepath) { + int fd = open(filepath, O_RDONLY); + if (fd < 0) { + return; + } + + if (taosTRead(fd, (void *)tsEmail, TSDB_FQDN_LEN) < 0) { + dError("failed to read %d bytes from file %s since %s", TSDB_FQDN_LEN, filepath, strerror(errno)); + } +} + + int32_t dnodeInitTelemetry() { if (!tsEnableTelemetryReporting) { return 0; } + dnodeGetEmail("/usr/local/taos/email"); + if (tsem_init(&tsExitSem, 0, 0) == -1) { // just log the error, it is ok for telemetry to fail dTrace("failed to create semaphore for telemetry, reason:%s", strerror(errno));