#ifndef _TFE_FIELDSTAT_METRIC_H #define _TFE_FIELDSTAT_METRIC_H #ifdef __cpluscplus extern "C" { #endif #include #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) #define FIELDSTAT_TAG_STR(ptr, index, _key, _type, _value) \ do { ptr[index].key = _key; ptr[index].type = _type; ptr[index].value_str = _value; } while(0) enum metric_columns_index { COLUMN_HIT_COUNT = 0, COLUMN_IN_BYTES, COLUMN_OUT_BYTES, COLUMN_IN_PKTS, COLUMN_OUT_PKTS, COLUMN_MAX }; enum metric_tags_index { TAG_VSYS_ID = 0, TAG_RULE_ID, TAG_ACTION, TAG_SUB_ACTION, TAG_PINNING_STATUS, TAG_MAX }; struct fieldstat_easy_intercept { 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 field **tags; int counter_array[COLUMN_MAX]; struct fieldstat_easy *fs; }; 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 field 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); #ifdef __cpluscplus } #endif #endif