summaryrefslogtreecommitdiff
path: root/src/extensions/sapp_assistant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/extensions/sapp_assistant.cpp')
-rw-r--r--src/extensions/sapp_assistant.cpp432
1 files changed, 2 insertions, 430 deletions
diff --git a/src/extensions/sapp_assistant.cpp b/src/extensions/sapp_assistant.cpp
index 666605e..4ad351a 100644
--- a/src/extensions/sapp_assistant.cpp
+++ b/src/extensions/sapp_assistant.cpp
@@ -6,13 +6,11 @@
#include "sapp_api.h"
#include "sapp_private_api.h"
#include "sapp_declaration.h"
-#include "field_stat2.h"
-#include "fieldstat.h"
+
#include "marsio.h"
-static int sapp_fs2_init(sapp_global_t *global_parameters);
-static int sapp_fs3_init(sapp_global_t *global_parameters);
+
//extern time_t g_CurrentTime;//add by lqy 20070606
//extern int g_packet_io_thread_num;
@@ -25,7 +23,6 @@ static pthread_t *g_plug_Independent_thread_pid;
static const unsigned char G_BROADCAST_ADDR[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
-int sapp_assistant_version_VERSION_20181024;
extern "C" int MESA_get_dev_ipv4(const char *device, int *ip_add);
extern "C" int MESA_get_dev_mac(const char *device, unsigned char mac[6]);
@@ -872,136 +869,6 @@ extern "C" int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_
return ret;
}
-void sapp_fs2_update_count(int field_index, unsigned long long value)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_id_count_array[field_index],
- 0, FS_OP_SET, (long long)value);
- }
-}
-
-void sapp_fs2_update_length(int field_index, unsigned long long value)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_id_length_array[field_index],
- 0, FS_OP_SET, (long long)value);
- }
-}
-
-
-void sapp_fs2_set_latency(int thead_seq, long long time_cost)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_latency_id_array[thead_seq],
- 0, FS_OP_SET, time_cost);
- }
-}
-
-
-void sapp_fs2_set_plug_entry_latency(int entry_id, long long time_cost)
-{
- if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
- return;
- }
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_latency_plug_entrg_id_array[entry_id],
- 0, FS_OP_SET, time_cost);
- }
-}
-
-/*
- ģ�������������ʱ, ����ÿ����������һ��FS_operate(),
- ��sapp timer�߳�ÿ��һ��ʱ�����sapp_fuzzy_latency_update(), ����filed_stat2����.
-*/
-extern "C" void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost)
-{
- sapp_fuzzy_latency_stat_t *this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_thread;
-
- if(time_cost < this_thread_stat->min_time_cost){
- this_thread_stat->min_time_cost = time_cost;
- }
-
- if(time_cost > this_thread_stat->max_time_cost){
- this_thread_stat->max_time_cost = time_cost;
- }
-
- this_thread_stat->time_cost_sum += time_cost;
- this_thread_stat->stat_count++;
-}
-
-extern "C" void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost)
-{
- sapp_fuzzy_latency_stat_t *this_thread_stat;
- if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
- return;
- }
-
- this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
-
- if(time_cost < this_thread_stat->min_time_cost){
- this_thread_stat->min_time_cost = time_cost;
- }
-
- if(time_cost > this_thread_stat->max_time_cost){
- this_thread_stat->max_time_cost = time_cost;
- }
-
- this_thread_stat->time_cost_sum += time_cost;
- this_thread_stat->stat_count++;
-
-}
-
-
-/*
- ��sapp timer�����̵߳���, ÿ��һ��ʱ��, �����۵İ�������ʱ����ˢ�¸�field_stat2.
-*/
-void sapp_fuzzy_latency_update(void)
-{
- int tid, entry_id, this_stat_count;
- long long min_latency, max_latency;
- double avg_latency;
- sapp_fuzzy_latency_stat_t *this_thread_stat, *this_entry_stat;
-
- for(tid = 0; tid < g_packet_io_thread_num; tid++){
- this_thread_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_thread;
- avg_latency = (double)this_thread_stat->time_cost_sum/(double)this_thread_stat->stat_count;
- min_latency = this_thread_stat->min_time_cost;
- max_latency = this_thread_stat->max_time_cost;
- this_stat_count = this_thread_stat->stat_count;
-
- if(this_stat_count > 0){
- memset(this_thread_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
- this_thread_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
-
- /* ÿ�θ�������ֵ, ���,��С��ƽ��ֵ */
- sapp_fs2_set_latency(tid, min_latency);
- sapp_fs2_set_latency(tid, max_latency);
- sapp_fs2_set_latency(tid, (long long)avg_latency);
- }
-
- for(entry_id = 1; entry_id < g_plug_global_entry_index; entry_id++){
- this_entry_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
- avg_latency = (double)this_entry_stat->time_cost_sum/(double)this_entry_stat->stat_count;
- min_latency = this_entry_stat->min_time_cost;
- max_latency = this_entry_stat->max_time_cost;
- this_stat_count = this_entry_stat->stat_count;
- if(this_stat_count > 0){
- memset(this_entry_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
- this_entry_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
-
- sapp_fs2_set_latency(tid, min_latency);
- sapp_fs2_set_latency(tid, max_latency);
- sapp_fs2_set_plug_entry_latency(entry_id, (long long)avg_latency);
- }
- }
- }
-}
-
-
int sapp_independent_thread_init(void)
{
pthread_mutex_init(&g_plug_Independent_thread_mutex, NULL);
@@ -1012,298 +879,3 @@ int sapp_independent_thread_init(void)
return 0;
}
-
-int sapp_metric_init(void)
-{
- int ret = 0;
- if( sapp_global_val->config.profiling.fs2.enabled == 1)
- {
- sapp_fs2_init(sapp_global_val);
- }
- if( sapp_global_val->config.profiling.fs3.enabled == 1)
- {
- sapp_fs3_init(sapp_global_val);
- }
-
- return ret;
-}
-
-
-static int fs2_plug_entry_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
-{
- int i;
- /* 0������sapp���ò��, index��1��ʼ */
- for(i = 1; i < g_plug_global_entry_index; i++){
- fs_rt->fs_latency_plug_entrg_id_array[i] = FS_register_histogram(fs_rt->fs_metric_handle, //Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- g_plug_global_entry[i].plug_entry_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 1000000, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- if(fs_rt->fs_latency_plug_entrg_id_array[i] < 0){
- sapp_runtime_log(RLOG_LV_FATAL, "FS_register_histogram() error, plug name:%s", g_plug_global_entry[i].plug_entry_name);
- return -1;
- }
- }
-
- return 0;
-}
-
-void sapp_fs2_set_tcp_unorder_historgram(int thead_seq, long long unorder_num)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_tcp_unorder_id_array[thead_seq],
- 0, FS_OP_SET, unorder_num);
- }
-}
-
-static int fs2_tcp_unorder_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
-{
- int i;
- char histogram_name[16];
- /* 0������sapp���ò��, index��1��ʼ */
- for (i = 1; i < g_packet_io_thread_num; i++)
- {
- sprintf(histogram_name, "OoO_num(tid_%d)", i);
- fs_rt->fs_tcp_unorder_id_array[i] =
- FS_register_histogram(fs_rt->fs_metric_handle, // Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- histogram_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 65536, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- if (fs_rt->fs_tcp_unorder_id_array[i] < 0)
- {
- sapp_runtime_log(RLOG_LV_FATAL, "FS_fs2_tcp_unorder_historgram_init() error, name:%s",
- histogram_name);
- return -1;
- }
- }
-
- return 0;
-}
-
-/************************ C++ compiler **************************************/
-static int sapp_fs2_init(sapp_global_t *global_paramters)
-{
- void *fs2_handle=NULL;
- int fs2_opt;
- sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
- sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
- int fs2_local_enabled = 0;
- int fs2_prometheus_enabled = 0;
-
- if(strlen(p_fs2_para->local_file) > 0)
- {
- fs2_local_enabled = 1;
- }
- if(strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
- {
- fs2_prometheus_enabled = 1;
- }
-
- p_fs2_rt->fs_metric_handle = FS_create_handle();
- if(NULL == p_fs2_rt->fs_metric_handle){
- sapp_log(RLOG_LV_FATAL, 30, 30, "FS_create_handle() error: %s!\n", strerror(errno));
- return -1;
- }
- fs2_handle = p_fs2_rt->fs_metric_handle;
- if(fs2_prometheus_enabled){
- FS_library_set_prometheus_port((unsigned short)p_fs2_para->prometheus_service_port);
- FS_library_set_prometheus_url_path(p_fs2_para->prometheus_service_uri);
- if(FS_library_init() < 0){
- sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n",
- p_fs2_para->prometheus_service_port,
- p_fs2_para->prometheus_service_uri);
- return -1;
- }
- fs2_opt = 1;
- FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int));
- }
-
- FS_set_para(fs2_handle, STAT_CYCLE, &p_fs2_para->refresh_interval_s, sizeof(int));
-
- fs2_opt = 1; /* 1:Rewrite ,2: Append. */
- FS_set_para(fs2_handle, PRINT_MODE, &fs2_opt, sizeof(int));
-
- fs2_opt = 1;
- FS_set_para(fs2_handle, PRINT_TRIGGER, &fs2_opt, sizeof(int));
-
- fs2_opt = 1;
- FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &fs2_opt, sizeof(int));
-
- if(fs2_local_enabled){
- FS_set_para(fs2_handle, OUTPUT_DEVICE, ABBR_FS2_LOG_DATA_FILE, strlen(ABBR_FS2_LOG_DATA_FILE)+1);
- }else{
- sapp_log(RLOG_LV_INFO, 10, 10, "profiling.log.local.enabled is 0, not save local stat log file.\n");
- FS_set_para(fs2_handle, OUTPUT_DEVICE, "/dev/null", strlen("/dev/null") + 1);
- }
- FS_set_para(fs2_handle, APP_NAME, sapp_global_val->config.system.instance_name, strlen(sapp_global_val->config.system.instance_name)+1);
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit");
-
- if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin)
- || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){
- p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound");
- }
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Pkt");
- //pfs_para->fs_id_length_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Bit");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup�ظ���ʶ������key������� */
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DATA] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Concurrent");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_New");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_Del");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_MORE] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Concurrent");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C_ALL");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C_ALL");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit");
-
- if (unlikely(g_timestamp_record_sw))
- {
- if (fs2_tcp_unorder_historgram_init(p_fs2_rt) < 0)
- {
- return -1;
- }
- for (int i = 0; i < g_packet_io_thread_num; i++)
- {
- char histogram_name[16];
- sprintf(histogram_name, "TD_ns(tid_%d)", i);
- p_fs2_rt->fs_latency_id_array[i] = FS_register_histogram(fs2_handle, // Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- histogram_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 1000000, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_latency_id_array[i], sizeof(int));
- }
-
- if (fs2_plug_entry_historgram_init(p_fs2_rt) < 0)
- {
- return -1;
- }
- }
- FS_start(fs2_handle);
-
- return 0;
-}
-
-static void sapp_fs2_destroy(sapp_global_t *global_paramters)
-{
- sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
- sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
- if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
- {
- FS_library_destroy();
- }
-
- if (p_fs2_rt->fs_metric_handle)
- {
- FS_stop(&p_fs2_rt->fs_metric_handle);
- }
-}
-
-static int sapp_fs3_init(sapp_global_t *global_paramters)
-{
- sapp_config_profiling_metric_t *p_fs3_para = &global_paramters->config.profiling.fs3;
- sapp_gval_individual_fixed_fs_t *p_fs3_rt = &global_paramters->individual_fixed.fs3_runtime;
- return 0;
-}
-
-static void sapp_fs3_destroy(sapp_global_t *global_paramters)
-{
- return;
-}
-
-void sapp_metric_destroy(void)
-{
-
- if( sapp_global_val->config.profiling.fs2.enabled == 1)
- {
- sapp_fs2_destroy(sapp_global_val);
- }
- if( sapp_global_val->config.profiling.fs3.enabled == 1)
- {
- sapp_fs3_destroy(sapp_global_val);
- }
-}
-
-