Update timeout and timestamp

* Timeout using CLOCK_MONOTONIC
    * Session start/last timestamps use CLOCK_REALTIME
    * Session ID generator uses CLOCK_REALTIME
This commit is contained in:
luwenpeng
2024-04-16 18:34:41 +08:00
parent d878849c3a
commit f5f09e5e23
15 changed files with 259 additions and 112 deletions

View File

@@ -94,7 +94,7 @@ struct stellar_stat
// python3 -m pip install prettytable
// python3 -m pip install jinja2
// /opt/MESA/bin/fieldstat_exporter.py local -j log/stellar.fs4 -e -l --clear-screen
// /opt/MESA/bin/fieldstat_exporter.py local -j log/stellar_fs4.json -e -l --clear-screen
struct stellar_stat *stellar_stat_new(uint16_t nr_thread)
{
struct stellar_stat *stat = (struct stellar_stat *)calloc(1, sizeof(struct stellar_stat));
@@ -135,19 +135,19 @@ struct stellar_stat *stellar_stat_new(uint16_t nr_thread)
stat->ids.ctrl_tx_pkts = fieldstat_easy_register_counter(stat->fs, "ctrl_tx_pkts");
stat->ids.ctrl_tx_bytes = fieldstat_easy_register_counter(stat->fs, "ctrl_tx_bytes");
// TCP session
stat->ids.nr_tcp_sess_used = fieldstat_easy_register_counter(stat->fs, "tcp_sess_used");
stat->ids.nr_tcp_sess_opening = fieldstat_easy_register_counter(stat->fs, "tcp_sess_opening");
stat->ids.nr_tcp_sess_active = fieldstat_easy_register_counter(stat->fs, "tcp_sess_active");
stat->ids.nr_tcp_sess_closing = fieldstat_easy_register_counter(stat->fs, "tcp_sess_closing");
stat->ids.nr_tcp_sess_discard = fieldstat_easy_register_counter(stat->fs, "tcp_sess_discard");
stat->ids.nr_tcp_sess_closed = fieldstat_easy_register_counter(stat->fs, "tcp_sess_closed");
stat->ids.nr_tcp_sess_used = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_used");
stat->ids.nr_tcp_sess_opening = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_opening");
stat->ids.nr_tcp_sess_active = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_active");
stat->ids.nr_tcp_sess_closing = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_closing");
stat->ids.nr_tcp_sess_discard = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_discard");
stat->ids.nr_tcp_sess_closed = fieldstat_easy_register_counter(stat->fs, "curr_tcp_sess_closed");
// UDP session
stat->ids.nr_udp_sess_used = fieldstat_easy_register_counter(stat->fs, "udp_sess_used");
stat->ids.nr_udp_sess_opening = fieldstat_easy_register_counter(stat->fs, "udp_sess_opening");
stat->ids.nr_udp_sess_active = fieldstat_easy_register_counter(stat->fs, "udp_sess_active");
stat->ids.nr_udp_sess_closing = fieldstat_easy_register_counter(stat->fs, "udp_sess_closing");
stat->ids.nr_udp_sess_discard = fieldstat_easy_register_counter(stat->fs, "udp_sess_discard");
stat->ids.nr_udp_sess_closed = fieldstat_easy_register_counter(stat->fs, "udp_sess_closed");
stat->ids.nr_udp_sess_used = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_used");
stat->ids.nr_udp_sess_opening = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_opening");
stat->ids.nr_udp_sess_active = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_active");
stat->ids.nr_udp_sess_closing = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_closing");
stat->ids.nr_udp_sess_discard = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_discard");
stat->ids.nr_udp_sess_closed = fieldstat_easy_register_counter(stat->fs, "curr_udp_sess_closed");
// Evicted session
stat->ids.nr_tcp_sess_evicted = fieldstat_easy_register_counter(stat->fs, "tcp_sess_evicted");
stat->ids.nr_udp_sess_evicted = fieldstat_easy_register_counter(stat->fs, "udp_sess_evicted");
@@ -320,10 +320,10 @@ void stellar_stat_output(struct stellar_stat *stat)
fieldstat_easy_output(stat->fs, &buff, &len);
if (buff)
{
FILE *fp = fopen("/opt/tsg/stellar/log/stellar.fs4", "w+");
FILE *fp = fopen("/opt/tsg/stellar/log/stellar_fs4.json", "w+");
if (fp == NULL)
{
STAT_LOG_ERROR("failed to open file: %s, %s", "/opt/tsg/stellar/log/stellar.fs4", strerror(errno));
STAT_LOG_ERROR("failed to open file: %s, %s", "/opt/tsg/stellar/log/stellar_fs4.json", strerror(errno));
}
else
{