diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2010-12-24 20:31:28 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2010-12-24 20:31:28 +0300 |
commit | 88db624127e11d4a1d1000a5ebcfb6757a05f3a4 (patch) | |
tree | 27c4d606175d36bda0f323fd8bc090a667132244 /accel-pptpd/cli/std_cmd.c | |
parent | 59f691793e9270026214abffceb06f64d365fee3 (diff) | |
download | accel-ppp-88db624127e11d4a1d1000a5ebcfb6757a05f3a4.tar.gz accel-ppp-88db624127e11d4a1d1000a5ebcfb6757a05f3a4.zip |
cli: show cpu and memory utilization in statistics
Diffstat (limited to 'accel-pptpd/cli/std_cmd.c')
-rw-r--r-- | accel-pptpd/cli/std_cmd.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/accel-pptpd/cli/std_cmd.c b/accel-pptpd/cli/std_cmd.c index 127e7a27..0d168e58 100644 --- a/accel-pptpd/cli/std_cmd.c +++ b/accel-pptpd/cli/std_cmd.c @@ -16,6 +16,17 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, { time_t dt; int day,hour; + char statm_fname[128]; + FILE *f; + unsigned long vmsize = 0, vmrss = 0; + unsigned long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; + + sprintf(statm_fname, "/proc/%i/statm", getpid()); + f = fopen(statm_fname, "r"); + if (f) { + fscanf(f, "%lu %lu", &vmsize, &vmrss); + fclose(f); + } time(&dt); dt -= triton_stat.start_time; @@ -25,6 +36,8 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, dt %= 60 * 60; cli_sendv(client, "uptime: %i.%02i:%02i:%02i\r\n", day, hour, dt / 60, dt % 60); + cli_sendv(client, "cpu: %i%% (%i/%i)\r\n", triton_stat.ru_utime + triton_stat.ru_stime, triton_stat.ru_utime, triton_stat.ru_stime); + cli_sendv(client, "mem: %lu/%lu kB\r\n", vmrss / page_size_kb, vmsize / page_size_kb); cli_send(client, "core:\r\n"); cli_sendv(client, " mempool_allocated: %u\r\n", triton_stat.mempool_allocated); cli_sendv(client, " mempool_available: %u\r\n", triton_stat.mempool_available); |