2023-02-21 09:58:31 +08:00
|
|
|
#ifndef _GLOBAL_METRICS_H
|
|
|
|
|
#define _GLOBAL_METRICS_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include <MESA/field_stat2.h>
|
|
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
struct throughput_metrics
|
2023-02-21 09:58:31 +08:00
|
|
|
{
|
2023-11-24 15:17:18 +08:00
|
|
|
uint64_t n_pkts;
|
|
|
|
|
uint64_t n_bytes;
|
2023-02-21 09:58:31 +08:00
|
|
|
};
|
|
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
#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
|
2023-02-21 09:58:31 +08:00
|
|
|
{
|
2023-11-24 15:17:18 +08:00
|
|
|
// 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
|
2023-03-14 16:10:44 +08:00
|
|
|
struct throughput_metrics nf_rx; // 累计值
|
|
|
|
|
struct throughput_metrics nf_tx; // 累计值
|
2023-02-21 09:58:31 +08:00
|
|
|
|
2024-03-06 11:56:07 +08:00
|
|
|
struct throughput_metrics raw_rx; // 累计值
|
|
|
|
|
struct throughput_metrics raw_tx; // 累计值
|
|
|
|
|
|
|
|
|
|
struct throughput_metrics dec_rx; // 累计值
|
|
|
|
|
struct throughput_metrics dec_tx; // 累计值
|
|
|
|
|
|
2023-10-18 10:08:10 +08:00
|
|
|
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; // 累计值
|
2023-02-21 09:58:31 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
// data packet metrics 不包含 vxlan frame / vlan header 所占的字节
|
2023-03-14 16:10:44 +08:00
|
|
|
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; // 累计值
|
2023-02-23 18:15:21 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
// control packet metrics
|
|
|
|
|
struct throughput_metrics ctrl_rx; // 累计值
|
|
|
|
|
struct throughput_metrics ctrl_tx; // 累计值
|
2023-02-23 18:15:21 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
uint64_t ctrl_opening; // 累计值
|
|
|
|
|
uint64_t ctrl_active; // 累计值
|
|
|
|
|
uint64_t ctrl_closing; // 累计值
|
|
|
|
|
uint64_t ctrl_resetall; // 累计值
|
|
|
|
|
uint64_t ctrl_error; // 累计值
|
2023-02-23 18:15:21 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
// sf status metrics
|
|
|
|
|
uint64_t sf_active; // 累计值
|
|
|
|
|
uint64_t sf_inactive; // 累计值
|
2023-02-21 09:58:31 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
// sf session metrics
|
|
|
|
|
uint64_t session_num; // 当前值
|
|
|
|
|
uint64_t session_log; // 累计值
|
2024-03-07 10:38:05 +08:00
|
|
|
|
|
|
|
|
uint64_t session_new; // 累计值
|
|
|
|
|
uint64_t session_free; // 累计值
|
2024-04-20 11:40:00 +08:00
|
|
|
|
|
|
|
|
// stateless inject
|
|
|
|
|
struct throughput_metrics stateless_inject; // 累计值
|
2023-03-14 16:10:44 +08:00
|
|
|
};
|
|
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
struct metrics_config
|
2023-10-12 16:31:53 +08:00
|
|
|
{
|
2023-11-24 15:17:18 +08:00
|
|
|
char output_file[256];
|
|
|
|
|
char statsd_server[32];
|
|
|
|
|
int statsd_port;
|
|
|
|
|
int statsd_format;
|
|
|
|
|
int statsd_cycle;
|
2023-10-12 16:31:53 +08:00
|
|
|
|
2023-11-24 15:17:18 +08:00
|
|
|
int prometheus_listen_port;
|
|
|
|
|
char prometheus_listen_url[256];
|
2023-10-12 16:31:53 +08:00
|
|
|
};
|
|
|
|
|
|
2023-03-14 16:10:44 +08:00
|
|
|
struct global_metrics
|
|
|
|
|
{
|
2023-11-24 15:17:18 +08:00
|
|
|
struct thread_metrics sum;
|
2023-02-21 09:58:31 +08:00
|
|
|
|
2023-03-14 16:10:44 +08:00
|
|
|
struct metrics_config config;
|
2023-02-21 09:58:31 +08:00
|
|
|
screen_stat_handle_t fs_handle;
|
2023-02-27 14:37:31 +08:00
|
|
|
int fs_id[128];
|
2023-10-12 16:31:53 +08:00
|
|
|
|
|
|
|
|
int thread_num;
|
|
|
|
|
int *thread_metrics_flag;
|
|
|
|
|
struct thread_metrics *thread_metrics_cache;
|
2023-02-21 09:58:31 +08:00
|
|
|
};
|
|
|
|
|
|
2023-10-12 16:31:53 +08:00
|
|
|
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);
|
2023-02-21 09:58:31 +08:00
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|