diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp index cd8b738..7bb3a77 100644 --- a/src/tsg_entry.cpp +++ b/src/tsg_entry.cpp @@ -1154,6 +1154,7 @@ extern "C" int TSG_MASTER_INIT() { int i=0,ret=0; int value=0,cycle=0; + int output_prometheus=0; unsigned short fs_server_port=0; char app_name[MAX_STRING_LEN]={0}; char label_buff[MAX_STRING_LEN*4]={0}; @@ -1243,6 +1244,7 @@ extern "C" int TSG_MASTER_INIT() MESA_load_profile_string_nodef(tsg_conffile,"FIELD_STAT","TELEGRAF_IP",fs_server_ip, sizeof(fs_server_ip)); MESA_load_profile_string_def(tsg_conffile,"FIELD_STAT","OUTPUT_PATH",fs_output_path, sizeof(fs_output_path), "tsg_stat.log"); MESA_load_profile_string_def(tsg_conffile,"FIELD_STAT","APP_NAME", app_name, sizeof(app_name), "tsg_master"); + MESA_load_profile_int_def(tsg_conffile, "FIELD_STAT", "PROMETHEUS", &output_prometheus, 1); g_tsg_para.fs2_handle=FS_create_handle(); @@ -1255,6 +1257,9 @@ extern "C" int TSG_MASTER_INIT() FS_set_para(g_tsg_para.fs2_handle, APP_NAME, app_name, strlen(app_name)+1); FS_set_para(g_tsg_para.fs2_handle, OUTPUT_DEVICE, fs_output_path, strlen(fs_output_path)+1); + value=1; + FS_set_para(g_tsg_para.fs2_handle, OUTPUT_PROMETHEUS, &output_prometheus, sizeof(output_prometheus)); + if(fs_server_port > 0 && strlen(fs_server_ip) > 0) { FS_set_para(g_tsg_para.fs2_handle, STATS_SERVER_IP,fs_server_ip, strlen(fs_server_ip)+1); diff --git a/src/tsg_statistic.cpp b/src/tsg_statistic.cpp index 38dce15..5f2c798 100644 --- a/src/tsg_statistic.cpp +++ b/src/tsg_statistic.cpp @@ -342,6 +342,7 @@ static void *tsg_statistic_thread(void *arg) int tsg_statistic_init(const char *conffile, void *logger) { + int output_prometheus=0; int i=0,value=0,thread_num=0; unsigned short fs_server_port=0; char app_name[MAX_STRING_LEN]={0}; @@ -367,7 +368,8 @@ int tsg_statistic_init(const char *conffile, void *logger) MESA_load_profile_string_nodef(conffile,"STATISTIC", "TELEGRAF_IP",fs_server_ip, sizeof(fs_server_ip)); MESA_load_profile_string_def(conffile,"STATISTIC", "OUTPUT_PATH",fs_output_path, sizeof(fs_output_path), "statistic.log"); MESA_load_profile_string_def(conffile,"STATISTIC", "APP_NAME", app_name, sizeof(app_name), "statistic"); - + MESA_load_profile_int_def(conffile, "STATISTIC", "PROMETHEUS", &output_prometheus, 1); + g_tsg_statis_para.fs2_handle=FS_create_handle(); value=1;//Rewrite @@ -379,6 +381,9 @@ int tsg_statistic_init(const char *conffile, void *logger) FS_set_para(g_tsg_statis_para.fs2_handle, APP_NAME, app_name, strlen(app_name)+1); FS_set_para(g_tsg_statis_para.fs2_handle, OUTPUT_DEVICE, fs_output_path, strlen(fs_output_path)+1); + value=1; + FS_set_para(g_tsg_statis_para.fs2_handle, OUTPUT_PROMETHEUS, &output_prometheus, sizeof(output_prometheus)); + if(fs_server_port > 0 && strlen(fs_server_ip) > 0) { FS_set_para(g_tsg_statis_para.fs2_handle, STATS_SERVER_IP,fs_server_ip, strlen(fs_server_ip)+1);