]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Track clock time as well as user/sys CPU time.
authorTimo Sirainen <tss@iki.fi>
Wed, 15 Jan 2014 20:50:38 +0000 (15:50 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 15 Jan 2014 20:50:38 +0000 (15:50 -0500)
src/plugins/stats/stats-plugin.c
src/plugins/stats/stats-plugin.h
src/stats/mail-stats.c
src/stats/mail-stats.h

index ed610f3ea724ba16b602e9df4975cca5dcb8a017..4345a971c5c92296d2091e724b002c9e97eb8c2a 100644 (file)
@@ -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);
index 9249c429d1c2ad9589a3521e698ee1831d222a82..291ee2c79cc3a7e97509d329abefa142a80a99ad 100644 (file)
@@ -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 */
index b93e3d4205e08c3613afadd720e2c49108601268..8af0578f403366cd6c13cf1413c36584052e8de1 100644 (file)
@@ -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),
index 30753e7a27e3757c23080359fbee1012d36675e9..1141fd060dae32b6bc412e8d7d55333262d4f7e1 100644 (file)
@@ -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;