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 /accel-pptpd/triton | |
parent | 2b34d862111f1fd84cdb9d744ac34c1c933f34da (diff) | |
download | accel-ppp-453e170879f599dfe4a82f7880929a7040b8b724.tar.gz accel-ppp-453e170879f599dfe4a82f7880929a7040b8b724.zip |
cli: changed terminate syntax
cli: fixed cpu/mem utilization statistics
Diffstat (limited to 'accel-pptpd/triton')
-rw-r--r-- | accel-pptpd/triton/triton.c | 11 | ||||
-rw-r--r-- | accel-pptpd/triton/triton.h | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/accel-pptpd/triton/triton.c b/accel-pptpd/triton/triton.c index 7d262512..c9ad646a 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 2c3871ea..1dc0033d 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; |