TSG-21854 TFE使用fieldstat4序列化Manipulation Policy的metric并输出到kafka
This commit is contained in:
@@ -23,7 +23,7 @@ void kafka_destroy(struct kafka *handle);
|
||||
// return 0: if success
|
||||
// return -1: if failed
|
||||
int kafka_send(struct kafka *handle, enum topic_idx idx, const char *data, int len);
|
||||
|
||||
int kafka_send2(struct kafka *handle, enum topic_idx idx, const char *data, int len);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef _METRICS_H
|
||||
#define _METRICS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "kafka.h"
|
||||
#include "tfe_packet_io.h"
|
||||
|
||||
struct metrics *metrics_create(const char *profile, struct kafka *kfk);
|
||||
void metrics_destory(struct metrics *handle);
|
||||
|
||||
void metrics_single_session_output(struct session_node *node, void *ctx);
|
||||
void metrics_all_session_output(struct packet_io_thread_ctx *thread_ctx);
|
||||
int metrics_get_interval(struct metrics *handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,9 @@ extern "C"
|
||||
#include <tfe_utils.h>
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
|
||||
#define FIELDSTAT_TAG_INIT(ptr, index, _key, _type, _value) \
|
||||
do { ptr[index].key = _key; ptr[index].type = _type; ptr[index].value_longlong = _value; } while(0)
|
||||
|
||||
enum metric_columns_index
|
||||
{
|
||||
COLUMN_HIT_COUNT = 0,
|
||||
@@ -29,18 +32,45 @@ enum metric_tags_index
|
||||
TAG_MAX
|
||||
};
|
||||
|
||||
struct tfe_fieldstat_easy_t
|
||||
struct fieldstat_easy_intercept
|
||||
{
|
||||
int table_id;
|
||||
int max_thread;
|
||||
int hit_count_idx;
|
||||
int in_bytes_idx;
|
||||
int out_bytes_idx;
|
||||
int in_pkts_idx;
|
||||
int out_pkts_idx;
|
||||
int output_fs_interval_ms;
|
||||
struct fieldstat_easy *fs;
|
||||
};
|
||||
|
||||
struct filedstat_easy_manipulation
|
||||
{
|
||||
int table_id;
|
||||
int max_thread;
|
||||
struct fieldstat_tag **tags;
|
||||
int counter_array[COLUMN_MAX];
|
||||
struct fieldstat_easy *fseasy;
|
||||
struct fieldstat_easy *fs;
|
||||
};
|
||||
|
||||
struct tfe_fieldstat_easy_t *tfe_fieldstat_easy_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger);
|
||||
struct tfe_fieldstat_easy_t
|
||||
{
|
||||
pthread_t tid;
|
||||
int thr_is_runing;
|
||||
int thr_need_exit;
|
||||
int output_kafka_interval_ms;
|
||||
struct fieldstat_easy_intercept *intercept;
|
||||
struct filedstat_easy_manipulation *manipulation;
|
||||
};
|
||||
|
||||
int tfe_fieldstat_get_output_interval(struct fieldstat_easy_intercept *fieldstat);
|
||||
int tfe_fieldstat_intercept_incrby(struct fieldstat_easy_intercept *fieldstat, void *val_data, int thread_index);
|
||||
int tfe_fieldstat_manipulation_incrby(struct filedstat_easy_manipulation *fieldstat, unsigned int counter_id, long long value, const struct fieldstat_tag tags[], int n_tags, int thread_id);
|
||||
|
||||
struct tfe_fieldstat_easy_t *tfe_fieldstat_easy_create(int output_kafka_interval_ms);
|
||||
struct fieldstat_easy_intercept *tfe_fieldstat_easy_intercept_create(char *app_name, int max_thread, int output_fs_interval_ms, void *local_logger);
|
||||
struct filedstat_easy_manipulation *tfe_fieldstat_easy_manipulation_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger);
|
||||
void tfe_fieldstat_easy_destroy(struct tfe_fieldstat_easy_t *fieldstat);
|
||||
int tfe_fieldstat_easy_incrby(struct tfe_fieldstat_easy_t *fieldstat, unsigned int counter_id, long long value, const struct fieldstat_tag tags[], int n_tags, int thread_id);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ struct acceptor_kni_v4
|
||||
|
||||
struct packet_io *io;
|
||||
struct packet_io_fs *packet_io_fs;
|
||||
struct metrics *metrics;
|
||||
struct fieldstat_easy_intercept *metrics;
|
||||
struct packet_io_thread_ctx work_threads[TFE_THREAD_MAX];
|
||||
|
||||
struct tfe_proxy *ref_proxy;
|
||||
|
||||
@@ -51,7 +51,7 @@ int session_table_delete_by_addr(struct session_table *table, const struct tuple
|
||||
struct session_node *session_table_search_by_id(struct session_table *table, uint64_t session_id);
|
||||
struct session_node *session_table_search_by_addr(struct session_table *table, const struct tuple4 *session_addr);
|
||||
|
||||
void session_foreach(struct session_table *table, void (*func)(struct session_node *, void *), void *ctx);
|
||||
void session_foreach(struct session_table *table, struct fieldstat_easy_intercept *metrics, int (*func)(struct fieldstat_easy_intercept *, void *, int), int thread_index);
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user