#ifndef _GLOBAL_METRICS_H #define _GLOBAL_METRICS_H #ifdef __cplusplus extern "C" { #endif #include "utils.h" #include struct throughput_metrics { uint64_t n_pkts; uint64_t n_bytes; }; #define THROUGHPUT_METRICS_INC(iterm, _n_pkts, _n_bytes) \ do \ { \ (iterm)->n_pkts += (_n_pkts); \ (iterm)->n_bytes += (_n_bytes); \ } while (0) struct thread_metrics { // keepalived packet metrics struct throughput_metrics downlink_rx; // 累计值 struct throughput_metrics downlink_tx; // 累计值 struct throughput_metrics uplink_rx; // 累计值 struct throughput_metrics uplink_tx_drop; // 累计值 // device packet metrics struct throughput_metrics nf_rx; // 累计值 struct throughput_metrics nf_tx; // 累计值 struct throughput_metrics raw_rx; // 累计值 struct throughput_metrics raw_tx; // 累计值 struct throughput_metrics dec_rx; // 累计值 struct throughput_metrics dec_tx; // 累计值 struct throughput_metrics endpoint_vxlan_rx; // 累计值 struct throughput_metrics endpoint_vxlan_tx; // 累计值 struct throughput_metrics endpoint_vxlan_drop; // 累计值 struct throughput_metrics endpoint_vlan_rx; // 累计值 struct throughput_metrics endpoint_vlan_tx; // 累计值 struct throughput_metrics endpoint_vlan_drop; // 累计值 // data packet metrics 不包含 vxlan frame / vlan header 所占的字节 struct throughput_metrics mirr_bypass; // 累计值 struct throughput_metrics mirr_block; // 累计值 struct throughput_metrics mirr_rx_drop; // 累计值 struct throughput_metrics mirr_tx; // 累计值 struct throughput_metrics stee_bypass; // 累计值 struct throughput_metrics stee_block; // 累计值 struct throughput_metrics stee_rx; // 累计值 struct throughput_metrics stee_tx; // 累计值 struct throughput_metrics miss_sess; // 累计值 struct throughput_metrics error_bypass; // 累计值 struct throughput_metrics error_block; // 累计值 // control packet metrics struct throughput_metrics ctrl_rx; // 累计值 struct throughput_metrics ctrl_tx; // 累计值 uint64_t ctrl_opening; // 累计值 uint64_t ctrl_active; // 累计值 uint64_t ctrl_closing; // 累计值 uint64_t ctrl_resetall; // 累计值 uint64_t ctrl_error; // 累计值 // sf status metrics uint64_t sf_active; // 累计值 uint64_t sf_inactive; // 累计值 // sf session metrics uint64_t session_num; // 当前值 uint64_t session_log; // 累计值 uint64_t session_new; // 累计值 uint64_t session_free; // 累计值 // stateless inject struct throughput_metrics stateless_inject; // 累计值 }; struct metrics_config { char output_file[256]; char statsd_server[32]; int statsd_port; int statsd_format; int statsd_cycle; int prometheus_listen_port; char prometheus_listen_url[256]; }; struct global_metrics { struct thread_metrics sum; struct metrics_config config; screen_stat_handle_t fs_handle; int fs_id[128]; int thread_num; int *thread_metrics_flag; struct thread_metrics *thread_metrics_cache; }; struct global_metrics *global_metrics_create(const char *profile, int thread_num); void global_metrics_destory(struct global_metrics *global_metrics); void global_metrics_update(struct global_metrics *global_metrics, struct thread_metrics *thread_metrics, int thread_id); void global_metrics_dump(struct global_metrics *global_metrics); #ifdef __cplusplus } #endif #endif