mail-stats-fill.c revision 6ef83bcdc4e40d6b387857e5f7d58cd86c71ec50
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce/* Copyright (c) 2011-2017 Dovecot authors, see the included COPYING file */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorceprocess_io_buffer_parse(const char *buf, struct mail_stats *stats)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce const char *const *tmp;
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (str_to_uint64(*tmp + 7, &stats->read_bytes) < 0)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (str_to_uint64(*tmp + 7, &stats->write_bytes) < 0)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (str_to_uint32(*tmp + 7, &stats->read_count) < 0)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce if (str_to_uint32(*tmp + 7, &stats->write_count) < 0)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorcestatic int process_io_open(void)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce /* kludge: if we're running with permissions temporarily
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce dropped, get them temporarily back so we can open
c1058e96679c7ed1372825bf5226ce7d28a8e6ffPavel Březina if (seteuid(0) == 0) {
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce /* oops, this is bad */
c6872e79e8496fd075e20aec0343ade99cca725cSimo Sorce i_fatal("stats: seteuid(%s) failed", dec2str(uid));
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce /* ignore access errors too, certain security options can
ab967283b710dfa05d11ee5b30c7ac916486ceecSimo Sorce prevent root access to this file when not owned by root */
dfd71fc92db940b2892cc996911cec03d7b6c52bSimo Sorcestatic void process_read_io_stats(struct mail_stats *stats)
4dd38025efda88f123eac672f87d3cda12f050c8Jakub Hrozek i_error("read(%s) returned EOF", PROC_IO_PATH);
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek /* just shouldn't happen.. */
0161a3c5637a0c0092bf54c436bb3d6508d7df26Jakub Hrozek i_error("%s is larger than expected", PROC_IO_PATH);
64ea4127f463798410a2c20e0261c6b15f60257fJakub Hrozekuser_trans_stats_get(struct stats_user *suser, struct mail_stats *dest_r)
9118a539a5d59f669f551114f880fe91d6bb8741Jakub Hrozek mail_stats_add_transaction(dest_r, &suser->finished_transaction_stats);
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek for (strans = suser->transactions; strans != NULL; strans = strans->next)
19e44537c28f6d5f011cd7ac885c74c1e892605fSimo Sorce mail_stats_add_transaction(dest_r, &strans->trans->stats);
e732d23f3ec986a463d757781a334040e03d1f59Jakub Hrozekvoid mail_stats_fill(struct stats_user *suser, struct mail_stats *stats_r)
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce /* cputime */
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce } else if (timeval_diff_usecs(&usage.ru_stime, &prev_usage.ru_stime) < 0) {
8bcabb97d988d1602882a1f036aac2eaf5e09234Simo Sorce /* This seems to be a Linux bug. */
void mail_stats_fill_global_deinit(void)