优化fieldstat3句柄创建
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <MESA/maat.h>
|
||||
#include <cjson/cJSON.h>
|
||||
#include <tfe_kafka_logger.h>
|
||||
#include <tfe_fieldstat.h>
|
||||
#include <tfe_proxy.h>
|
||||
#include <tfe_resource.h>
|
||||
|
||||
@@ -17,9 +18,37 @@ struct maat_table_info
|
||||
|
||||
static struct maat *static_maat = NULL;
|
||||
static tfe_kafka_logger_t *kafka_logger = NULL;
|
||||
static struct tfe_fieldstat_metric_t *dynamic_fieldstat = NULL;
|
||||
static char *device_id = NULL;
|
||||
static char *effective_device_tag=NULL;
|
||||
|
||||
static struct tfe_fieldstat_metric_t *create_fieldstat_instance(const char *profile, const char *section, int max_thread, void *logger)
|
||||
{
|
||||
int cycle=0;
|
||||
unsigned short telegraf_port=0;
|
||||
char telegraf_ip[TFE_STRING_MAX]={0};
|
||||
char app_name[TFE_STRING_MAX]={0};
|
||||
struct tfe_fieldstat_metric_t *dynamic_fieldstat=NULL;
|
||||
|
||||
MESA_load_profile_short_nodef(profile, section, "telegraf_port", (short *)&(telegraf_port));
|
||||
MESA_load_profile_string_nodef(profile, section, "telegraf_ip", telegraf_ip, sizeof(telegraf_ip));
|
||||
MESA_load_profile_string_def(profile, section, "app_name", app_name, sizeof(app_name), "metric");
|
||||
MESA_load_profile_int_def(profile, section, "cycle", &cycle, 1000);
|
||||
|
||||
dynamic_fieldstat = tfe_fieldstat_metric_create(telegraf_ip, telegraf_port, app_name, cycle, max_thread, logger);
|
||||
if (dynamic_fieldstat == NULL)
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "tfe fieldstat init failed, error to create fieldstat metric.");
|
||||
return NULL;
|
||||
}
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat telegraf_ip : %s", telegraf_ip);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat telegraf_port : %d", telegraf_port);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat app_name : %s", app_name);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat cycle : %d", cycle);
|
||||
|
||||
return dynamic_fieldstat;
|
||||
}
|
||||
|
||||
static struct maat *create_maat_feather(const char *instance_name, const char *profile, const char *section, int max_thread, void *logger)
|
||||
{
|
||||
struct maat *target=NULL;
|
||||
@@ -311,8 +340,14 @@ int tfe_bussiness_resouce_init()
|
||||
return -1;
|
||||
}
|
||||
|
||||
device_id = cerate_device_id(profile_path, "kafka", g_default_logger);
|
||||
dynamic_fieldstat = create_fieldstat_instance(profile_path, "proxy_hits", thread_num, g_default_logger);
|
||||
if(!dynamic_fieldstat)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
device_id = cerate_device_id(profile_path, "kafka", g_default_logger);
|
||||
|
||||
effective_device_tag = create_effective_device_tag(profile_path, "MAAT", g_default_logger);
|
||||
|
||||
if (register_maat_table())
|
||||
@@ -335,6 +370,8 @@ void *tfe_bussiness_resouce_get(enum RESOURCE_TYPE type)
|
||||
return device_id;
|
||||
case EFFECTIVE_DEVICE_TAG:
|
||||
return effective_device_tag;
|
||||
case DYNAMIC_FIELDSTAT:
|
||||
return dynamic_fieldstat;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user