summaryrefslogtreecommitdiff
path: root/platform/src
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2024-03-07 10:38:05 +0800
committerluwenpeng <[email protected]>2024-03-07 10:38:05 +0800
commite1146eab2e5f9db77c36b4b38cf841596d75b538 (patch)
treeb1399c1fd7ed38121a130aa7dd6f18b0c1e30339 /platform/src
parentd9aa9e50793ac1839d56ddc9d5d216216c220f3c (diff)
SCE增加session new & free的监控指标v1.2.10-20240307
Diffstat (limited to 'platform/src')
-rw-r--r--platform/src/global_metrics.cpp11
-rw-r--r--platform/src/main.cpp2
-rw-r--r--platform/src/packet_io.cpp2
3 files changed, 15 insertions, 0 deletions
diff --git a/platform/src/global_metrics.cpp b/platform/src/global_metrics.cpp
index f4ed3d8..3a935e2 100644
--- a/platform/src/global_metrics.cpp
+++ b/platform/src/global_metrics.cpp
@@ -116,6 +116,9 @@ enum SCE_STAT_FIELD
STAT_SF_SESSION_NUM,
STAT_SF_SESSION_LOG,
+ STAT_SESSION_NEW,
+ STAT_SESSION_FREE,
+
// max
STAT_MAX,
};
@@ -230,6 +233,9 @@ static const char *stat_map[] =
[STAT_SF_SESSION_NUM] = "curr_sessions",
[STAT_SF_SESSION_LOG] = "session_logs",
+ [STAT_SESSION_NEW] = "session_new",
+ [STAT_SESSION_FREE] = "session_free",
+
[STAT_MAX] = NULL};
static void global_metrics_parse_config(const char *profile, struct metrics_config *config)
@@ -426,6 +432,8 @@ void global_metrics_dump(struct global_metrics *global_metrics)
sum->sf_inactive += thread->sf_inactive;
sum->session_num += thread->session_num;
sum->session_log += thread->session_log;
+ sum->session_new += thread->session_new;
+ sum->session_free += thread->session_free;
memset(thread, 0, sizeof(struct thread_metrics));
ATOMIC_SET(&(global_metrics->thread_metrics_flag[i]), THREAD_METRICS_CACHE_IS_FREE);
@@ -537,5 +545,8 @@ void global_metrics_dump(struct global_metrics *global_metrics)
FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SF_SESSION_NUM], 0, FS_OP_SET, sum->session_num);
FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SF_SESSION_LOG], 0, FS_OP_SET, sum->session_log);
+ FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SESSION_NEW], 0, FS_OP_SET, sum->session_new);
+ FS_operate(global_metrics->fs_handle, global_metrics->fs_id[STAT_SESSION_FREE], 0, FS_OP_SET, sum->session_free);
+
FS_passive_output(global_metrics->fs_handle);
}
diff --git a/platform/src/main.cpp b/platform/src/main.cpp
index ae532b2..f963ebf 100644
--- a/platform/src/main.cpp
+++ b/platform/src/main.cpp
@@ -108,8 +108,10 @@ static void *worker_thread_cycle(void *arg)
if (ATOMIC_READ(&thread_ctx->session_table_need_reset) > 0)
{
+ int n_session = session_table_count(session_table);
session_table_reset(session_table);
ATOMIC_ZERO(&thread_ctx->session_table_need_reset);
+ ATOMIC_ADD(&(thread_metrics->session_free), n_session);
}
if (timestamp_get_msec(ts) - sf_metrics_last_send_ts >= sf_metrics_send_interval)
diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp
index cd40cc9..88f19b1 100644
--- a/platform/src/packet_io.cpp
+++ b/platform/src/packet_io.cpp
@@ -979,6 +979,7 @@ static void handle_session_closing(struct metadata *meta, struct control_packet
session_table_delete_by_id(session_table, meta->session_id);
ATOMIC_DEC(&(thread_metrics->session_num));
+ ATOMIC_INC(&(thread_metrics->session_free));
}
}
@@ -1037,6 +1038,7 @@ static void handle_session_active(struct metadata *meta, struct control_packet *
LOG_INFO("%s: session %lu %s active first", LOG_TAG_PKTIO, session_ctx->session_id, session_ctx->session_addr);
session_table_insert(session_table, session_ctx->session_id, &session_ctx->inner_tuple4, session_ctx, session_value_free_cb);
ATOMIC_INC(&(thread_metrics->session_num));
+ ATOMIC_INC(&(thread_metrics->session_new));
}
handle_policy_mutil_hits(session_ctx, ctrl_pkt, &data_pkt, meta->direction, thread_ctx);