适配输出prometheus

This commit is contained in:
liuxueli
2020-11-12 20:50:31 +06:00
parent 39335c9543
commit b339d74ecb
2 changed files with 11 additions and 1 deletions

View File

@@ -1154,6 +1154,7 @@ extern "C" int TSG_MASTER_INIT()
{ {
int i=0,ret=0; int i=0,ret=0;
int value=0,cycle=0; int value=0,cycle=0;
int output_prometheus=0;
unsigned short fs_server_port=0; unsigned short fs_server_port=0;
char app_name[MAX_STRING_LEN]={0}; char app_name[MAX_STRING_LEN]={0};
char label_buff[MAX_STRING_LEN*4]={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_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","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_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(); 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, 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); 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) 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); FS_set_para(g_tsg_para.fs2_handle, STATS_SERVER_IP,fs_server_ip, strlen(fs_server_ip)+1);

View File

@@ -342,6 +342,7 @@ static void *tsg_statistic_thread(void *arg)
int tsg_statistic_init(const char *conffile, void *logger) int tsg_statistic_init(const char *conffile, void *logger)
{ {
int output_prometheus=0;
int i=0,value=0,thread_num=0; int i=0,value=0,thread_num=0;
unsigned short fs_server_port=0; unsigned short fs_server_port=0;
char app_name[MAX_STRING_LEN]={0}; char app_name[MAX_STRING_LEN]={0};
@@ -367,6 +368,7 @@ 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_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", "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_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(); g_tsg_statis_para.fs2_handle=FS_create_handle();
@@ -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, 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); 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) 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); FS_set_para(g_tsg_statis_para.fs2_handle, STATS_SERVER_IP,fs_server_ip, strlen(fs_server_ip)+1);