2023-04-25 10:13:38 +08:00
|
|
|
#ifndef _TFE_FIELDSTAT_METRIC_H
|
|
|
|
|
#define _TFE_FIELDSTAT_METRIC_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <tfe_utils.h>
|
2024-07-22 17:22:45 +08:00
|
|
|
#include "fieldstat/fieldstat_easy.h"
|
2023-04-25 10:13:38 +08:00
|
|
|
|
2024-07-26 16:50:51 +08:00
|
|
|
#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)
|
2024-09-23 18:35:47 +08:00
|
|
|
#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)
|
2024-07-26 16:50:51 +08:00
|
|
|
|
2023-04-25 10:13:38 +08:00
|
|
|
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
|
|
|
|
|
{
|
2023-04-26 16:12:29 +08:00
|
|
|
TAG_VSYS_ID = 0,
|
|
|
|
|
TAG_RULE_ID,
|
2023-04-25 10:13:38 +08:00
|
|
|
TAG_ACTION,
|
|
|
|
|
TAG_SUB_ACTION,
|
2023-05-10 17:51:57 +08:00
|
|
|
TAG_PINNING_STATUS,
|
2023-04-25 10:13:38 +08:00
|
|
|
TAG_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-26 16:50:51 +08:00
|
|
|
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
|
2023-04-25 10:13:38 +08:00
|
|
|
{
|
2024-07-26 16:50:51 +08:00
|
|
|
int table_id;
|
2023-04-25 10:13:38 +08:00
|
|
|
int max_thread;
|
2024-07-30 14:51:52 +08:00
|
|
|
struct field **tags;
|
2024-07-22 17:22:45 +08:00
|
|
|
int counter_array[COLUMN_MAX];
|
2024-07-26 16:50:51 +08:00
|
|
|
struct fieldstat_easy *fs;
|
2023-04-25 10:13:38 +08:00
|
|
|
};
|
|
|
|
|
|
2024-07-26 16:50:51 +08:00
|
|
|
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);
|
2024-07-30 14:51:52 +08:00
|
|
|
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);
|
2024-07-26 16:50:51 +08:00
|
|
|
|
|
|
|
|
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);
|
2024-07-22 17:22:45 +08:00
|
|
|
void tfe_fieldstat_easy_destroy(struct tfe_fieldstat_easy_t *fieldstat);
|
2023-04-25 10:13:38 +08:00
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|