SCE增加session new & free的监控指标

This commit is contained in:
luwenpeng
2024-03-07 10:38:05 +08:00
parent d9aa9e5079
commit e1146eab2e
16 changed files with 66 additions and 48 deletions

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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);