diff options
author | Kozlov Dmitry <dima@server> | 2010-12-27 16:03:35 +0300 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-12-27 16:03:35 +0300 |
commit | 453e170879f599dfe4a82f7880929a7040b8b724 (patch) | |
tree | 1e76a7c618aede3dda85d341bf1be16dca9e988c | |
parent | 2b34d862111f1fd84cdb9d744ac34c1c933f34da (diff) | |
download | accel-ppp-453e170879f599dfe4a82f7880929a7040b8b724.tar.gz accel-ppp-453e170879f599dfe4a82f7880929a7040b8b724.zip |
cli: changed terminate syntax
cli: fixed cpu/mem utilization statistics
-rw-r--r-- | accel-pptpd/cli/std_cmd.c | 18 | ||||
-rw-r--r-- | accel-pptpd/log.c | 1 | ||||
-rw-r--r-- | accel-pptpd/triton/triton.c | 11 | ||||
-rw-r--r-- | accel-pptpd/triton/triton.h | 3 |
4 files changed, 20 insertions, 13 deletions
diff --git a/accel-pptpd/cli/std_cmd.c b/accel-pptpd/cli/std_cmd.c index 3563db9..50f3459 100644 --- a/accel-pptpd/cli/std_cmd.c +++ b/accel-pptpd/cli/std_cmd.c @@ -37,8 +37,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_sendv(client, "cpu: %i%%\r\n", triton_stat.cpu); + 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); @@ -273,7 +273,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) hard = 1; else if (strcmp(f[4], "soft")) return CLI_CMD_SYNTAX; - } else if (f_cnt != 4 || f_cnt > 5) + } else if (f_cnt != 4) return CLI_CMD_SYNTAX; re = pcre_compile2(f[3], 0, NULL, &pcre_err, &pcre_offset, NULL); @@ -309,7 +309,7 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli) hard = 1; else if (strcmp(f[3], "soft")) return CLI_CMD_SYNTAX; - } else if (f_cnt != 3 || f_cnt > 4) + } else if (f_cnt != 3) return CLI_CMD_SYNTAX; if (key == 1) @@ -334,6 +334,10 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli) if (strcmp(ppp->sessionid, f[2])) continue; break; + case 4: + if (strcmp(ppp->ifname, f[2])) + continue; + break; } if (hard) triton_context_call(ppp->ctrl->ctx, (triton_event_func)ppp_terminate_hard, ppp); @@ -364,6 +368,8 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt, return terminate_exec2(2, fields, fields_cnt, client); else if (!strcmp(fields[1], "sid")) return terminate_exec2(3, fields, fields_cnt, client); + else if (!strcmp(fields[1], "if")) + return terminate_exec2(4, fields, fields_cnt, client); else if (strcmp(fields[1], "all")) return CLI_CMD_SYNTAX; @@ -372,7 +378,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt, hard = 1; else if (strcmp(fields[2], "soft")) return CLI_CMD_SYNTAX; - } else if (fields_cnt != 2 && fields_cnt > 3) + } else if (fields_cnt != 2) return CLI_CMD_SYNTAX; pthread_rwlock_rdlock(&ppp_lock); @@ -389,7 +395,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt, static void terminate_help(char * const *fields, int fields_cnt, void *client) { - cli_send(client, "terminate <interface> [soft|hard]- terminate session by interface name\r\n"); + cli_send(client, "terminate if <interface> [soft|hard]- terminate session by interface name\r\n"); cli_send(client, "\t[match] username <username> [soft|hard]- terminate session by username\r\n"); cli_send(client, "\tip <addresss> [soft|hard]- terminate session by ip address\r\n"); cli_send(client, "\tcsid <id> [soft|hard]- terminate session by calling station id\r\n"); diff --git a/accel-pptpd/log.c b/accel-pptpd/log.c index 6994d86..428fedd 100644 --- a/accel-pptpd/log.c +++ b/accel-pptpd/log.c @@ -450,7 +450,6 @@ static void sighup(int n) static void load_config(void) { char *opt; - FILE *f; opt = conf_get_opt("log", "level"); if (opt && atoi(opt) >= 0) diff --git a/accel-pptpd/triton/triton.c b/accel-pptpd/triton/triton.c index 7d26251..c9ad646 100644 --- a/accel-pptpd/triton/triton.c +++ b/accel-pptpd/triton/triton.c @@ -494,8 +494,7 @@ void __export triton_collect_cpu_usage(void) clock_gettime(CLOCK_MONOTONIC, &ru_timestamp); ru_utime = rusage.ru_utime; ru_stime = rusage.ru_stime; - triton_stat.ru_utime = 0; - triton_stat.ru_stime = 0; + triton_stat.cpu = 0; } } @@ -510,13 +509,17 @@ static void ru_update(struct triton_timer_t *t) struct timespec ts; struct rusage rusage; unsigned int dt; + unsigned int val; getrusage(RUSAGE_SELF, &rusage); clock_gettime(CLOCK_MONOTONIC, &ts); dt = (ts.tv_sec - ru_timestamp.tv_sec) * 1000000 + (ts.tv_nsec - ru_timestamp.tv_nsec) / 1000000; - triton_stat.ru_utime = (double)((rusage.ru_utime.tv_sec - ru_utime.tv_sec) * 1000000 + (rusage.ru_utime.tv_usec - ru_utime.tv_usec)) / dt * 100; - triton_stat.ru_stime = (double)((rusage.ru_stime.tv_sec - ru_stime.tv_sec) * 1000000 + (rusage.ru_stime.tv_usec - ru_stime.tv_usec)) / dt * 100; + val = (double)((rusage.ru_utime.tv_sec - ru_utime.tv_sec) * 1000000 + (rusage.ru_utime.tv_usec - ru_utime.tv_usec) + + (rusage.ru_stime.tv_sec - ru_stime.tv_sec) * 1000000 + (rusage.ru_stime.tv_usec - ru_stime.tv_usec)) / dt * 100; + + if (val <= 100) + triton_stat.cpu = val; ru_timestamp = ts; ru_utime = rusage.ru_utime; diff --git a/accel-pptpd/triton/triton.h b/accel-pptpd/triton/triton.h index 2c3871e..1dc0033 100644 --- a/accel-pptpd/triton/triton.h +++ b/accel-pptpd/triton/triton.h @@ -64,8 +64,7 @@ struct triton_stat_t unsigned int timer_count; unsigned int timer_pending; time_t start_time; - int ru_utime; - int ru_stime; + unsigned int cpu; }; extern struct triton_stat_t triton_stat; |