summaryrefslogtreecommitdiff
path: root/accel-pppd/cli/std_cmd.c
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-05-13 21:43:13 +0300
committerGitHub <noreply@github.com>2026-05-13 21:43:13 +0300
commitd611c3240863f79029ab48d492659a67f82465d9 (patch)
tree8171a65c511849b941fbf492514cb5c89918b4e4 /accel-pppd/cli/std_cmd.c
parent5b78328068085a8dc530978fd0b51f5c187a6aff (diff)
parente5fe0eaa1fc6b1109db784e818e360159d8dd2ac (diff)
downloadaccel-ppp-d611c3240863f79029ab48d492659a67f82465d9.tar.gz
accel-ppp-d611c3240863f79029ab48d492659a67f82465d9.zip
Merge pull request #308 from nuclearcat/stats-rework
stats: improve how we handle statistics in the code
Diffstat (limited to 'accel-pppd/cli/std_cmd.c')
-rw-r--r--accel-pppd/cli/std_cmd.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c
index c37777b1..951b10da 100644
--- a/accel-pppd/cli/std_cmd.c
+++ b/accel-pppd/cli/std_cmd.c
@@ -30,6 +30,9 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
#ifdef MEMDEBUG
struct mallinfo mi = mallinfo();
#endif
+ struct triton_stat_t stat;
+
+ triton_stat_get(&stat);
sprintf(statm_fname, "/proc/%i/statm", getpid());
f = fopen(statm_fname, "r");
@@ -39,14 +42,14 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
}
clock_gettime(CLOCK_MONOTONIC, &ts);
- dt = ts.tv_sec - triton_stat.start_time;
+ dt = ts.tv_sec - stat.start_time;
day = dt / (60 * 60 * 24);
dt %= 60 * 60 * 24;
hour = dt / (60 * 60);
dt %= 60 * 60;
cli_sendv(client, "uptime: %i.%02i:%02lu:%02lu\r\n", day, hour, dt / 60, dt % 60);
- cli_sendv(client, "cpu: %i%%\r\n", triton_stat.cpu);
+ cli_sendv(client, "cpu: %i%%\r\n", stat.cpu);
#ifdef MEMDEBUG
cli_send(client, "memory:\r\n");
cli_sendv(client, " rss/virt: %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb);
@@ -58,23 +61,29 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
cli_sendv(client, "mem(rss/virt): %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb);
#endif
cli_send(client, "core:\r\n");
- cli_sendv(client, " mempool_allocated: %" PRIu64 "\r\n", triton_stat.mempool_allocated);
- cli_sendv(client, " mempool_available: %" PRIu64 "\r\n", triton_stat.mempool_available);
- cli_sendv(client, " thread_count: %u\r\n", triton_stat.thread_count);
- cli_sendv(client, " thread_active: %u\r\n", triton_stat.thread_active);
- cli_sendv(client, " context_count: %u\r\n", triton_stat.context_count);
- cli_sendv(client, " context_sleeping: %u\r\n", triton_stat.context_sleeping);
- cli_sendv(client, " context_pending: %u\r\n", triton_stat.context_pending);
- cli_sendv(client, " md_handler_count: %u\r\n", triton_stat.md_handler_count);
- cli_sendv(client, " md_handler_pending: %u\r\n", triton_stat.md_handler_pending);
- cli_sendv(client, " timer_count: %u\r\n", triton_stat.timer_count);
- cli_sendv(client, " timer_pending: %u\r\n", triton_stat.timer_pending);
+ cli_sendv(client, " mempool_allocated: %" PRIu64 "\r\n", stat.mempool_allocated);
+ cli_sendv(client, " mempool_available: %" PRIu64 "\r\n", stat.mempool_available);
+ cli_sendv(client, " thread_count: %u\r\n", stat.thread_count);
+ cli_sendv(client, " thread_active: %u\r\n", stat.thread_active);
+ cli_sendv(client, " context_count: %u\r\n", stat.context_count);
+ cli_sendv(client, " context_sleeping: %u\r\n", stat.context_sleeping);
+ cli_sendv(client, " context_pending: %u\r\n", stat.context_pending);
+ cli_sendv(client, " md_handler_count: %u\r\n", stat.md_handler_count);
+ cli_sendv(client, " md_handler_pending: %u\r\n", stat.md_handler_pending);
+ cli_sendv(client, " timer_count: %u\r\n", stat.timer_count);
+ cli_sendv(client, " timer_pending: %u\r\n", stat.timer_pending);
//===========
- cli_send(client, "sessions:\r\n");
- cli_sendv(client, " starting: %u\r\n", ap_session_stat.starting);
- cli_sendv(client, " active: %u\r\n", ap_session_stat.active);
- cli_sendv(client, " finishing: %u\r\n", ap_session_stat.finishing);
+ {
+ struct ap_session_stat ses_stat;
+
+ ap_session_stat_get(&ses_stat);
+
+ cli_send(client, "sessions:\r\n");
+ cli_sendv(client, " starting: %u\r\n", ses_stat.starting);
+ cli_sendv(client, " active: %u\r\n", ses_stat.active);
+ cli_sendv(client, " finishing: %u\r\n", ses_stat.finishing);
+ }
return CLI_CMD_OK;
}