summaryrefslogtreecommitdiff
path: root/accel-pptpd/cli
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/cli')
-rw-r--r--accel-pptpd/cli/std_cmd.c13
-rw-r--r--accel-pptpd/cli/telnet.c3
2 files changed, 16 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);
diff --git a/accel-pptpd/cli/telnet.c b/accel-pptpd/cli/telnet.c
index 256f236b..89512ad8 100644
--- a/accel-pptpd/cli/telnet.c
+++ b/accel-pptpd/cli/telnet.c
@@ -69,6 +69,8 @@ static void disconnect(struct telnet_client_t *cln)
log_debug("cli: disconnect\n");
+ triton_stop_collect_cpu_usage();
+
list_del(&cln->entry);
triton_md_unregister_handler(&cln->hnd);
@@ -567,6 +569,7 @@ static int serv_read(struct triton_md_handler_t *h)
conn->auth = 1;
send_prompt(conn);
}
+ triton_collect_cpu_usage();
}
return 0;
}