From: Timo Sirainen Date: Wed, 15 Jan 2014 20:50:38 +0000 (-0500) Subject: stats: Track clock time as well as user/sys CPU time. X-Git-Tag: 2.2.11~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60131617da4d5b604e91fa3925ccc8227468aa07;p=thirdparty%2Fdovecot%2Fcore.git stats: Track clock time as well as user/sys CPU time. --- diff --git a/src/plugins/stats/stats-plugin.c b/src/plugins/stats/stats-plugin.c index ed610f3ea7..4345a971c5 100644 --- a/src/plugins/stats/stats-plugin.c +++ b/src/plugins/stats/stats-plugin.c @@ -196,6 +196,7 @@ void mail_stats_get(struct stats_user *suser, struct mail_stats *stats_r) stats_r->invol_cs = usage.ru_nivcsw; stats_r->disk_input = (unsigned long long)usage.ru_inblock * 512ULL; stats_r->disk_output = (unsigned long long)usage.ru_oublock * 512ULL; + (void)gettimeofday(&stats_r->clock_time, NULL); process_read_io_stats(stats_r); user_trans_stats_get(suser, &stats_r->trans_stats); } @@ -251,6 +252,8 @@ void mail_stats_add_diff(struct mail_stats *dest, &old_stats->user_cpu); timeval_add_diff(&dest->sys_cpu, &new_stats->sys_cpu, &old_stats->sys_cpu); + timeval_add_diff(&dest->clock_time, &new_stats->clock_time, + &old_stats->clock_time); trans_stats_dec(&dest->trans_stats, &old_stats->trans_stats); trans_stats_add(&dest->trans_stats, &new_stats->trans_stats); } @@ -263,6 +266,8 @@ void mail_stats_export(string_t *str, const struct mail_stats *stats) (long)stats->user_cpu.tv_usec); str_printfa(str, "\tscpu=%ld.%ld", (long)stats->sys_cpu.tv_sec, (long)stats->sys_cpu.tv_usec); + str_printfa(str, "\ttime=%ld.%ld", (long)stats->clock_time.tv_sec, + (long)stats->clock_time.tv_usec); str_printfa(str, "\tminflt=%u", stats->min_faults); str_printfa(str, "\tmajflt=%u", stats->maj_faults); str_printfa(str, "\tvolcs=%u", stats->vol_cs); diff --git a/src/plugins/stats/stats-plugin.h b/src/plugins/stats/stats-plugin.h index 9249c429d1..291ee2c79c 100644 --- a/src/plugins/stats/stats-plugin.h +++ b/src/plugins/stats/stats-plugin.h @@ -14,6 +14,8 @@ struct mail_stats { /* user/system CPU time used */ struct timeval user_cpu, sys_cpu; + /* clock time used (not counting the time in ioloop wait) */ + struct timeval clock_time; /* minor / major page faults */ uint32_t min_faults, maj_faults; /* voluntary / involuntary context switches */ diff --git a/src/stats/mail-stats.c b/src/stats/mail-stats.c index b93e3d4205..8af0578f40 100644 --- a/src/stats/mail-stats.c +++ b/src/stats/mail-stats.c @@ -19,6 +19,7 @@ struct mail_stats_parse_map { #define EN(parsename, name) E(parsename, name, TYPE_NUM) E("ucpu", user_cpu, TYPE_TIMEVAL), E("scpu", sys_cpu, TYPE_TIMEVAL), + E("time", clock_time, TYPE_TIMEVAL), EN("minflt", min_faults), EN("majflt", maj_faults), EN("volcs", vol_cs), diff --git a/src/stats/mail-stats.h b/src/stats/mail-stats.h index 30753e7a27..1141fd060d 100644 --- a/src/stats/mail-stats.h +++ b/src/stats/mail-stats.h @@ -5,7 +5,7 @@ #include "guid.h" struct mail_stats { - struct timeval user_cpu, sys_cpu; + struct timeval user_cpu, sys_cpu, clock_time; uint32_t min_faults, maj_faults; uint32_t vol_cs, invol_cs; uint64_t disk_input, disk_output;