1 /* $NetBSD: msg_stats.h,v 1.2 2022/10/08 16:12:45 christos Exp $ */ 2 3 #ifndef _MSG_STATS_H_INCLUDED_ 4 #define _MSG_STATS_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* msg_stats 3h 9 /* SUMMARY 10 /* message delivery profiling 11 /* SYNOPSIS 12 /* #include <msg_stats.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * System library. 18 */ 19 #include <sys/time.h> 20 #include <time.h> 21 #include <string.h> 22 23 /* 24 * Utility library. 25 */ 26 #include <attr.h> 27 #include <vstream.h> 28 29 /* 30 * External interface. 31 * 32 * This structure contains the time stamps from various mail delivery stages, 33 * as well as the connection reuse count. The time stamps provide additional 34 * insight into the nature of performance bottle necks. 35 * 36 * For convenience, we record absolute time stamps instead of time differences. 37 * This is because the decision of what numbers to subtract actually depends 38 * on program history. Since we prefer to compute time differences in one 39 * place, we postpone this task until the end, in log_adhoc(). 40 * 41 * A zero time stamp or reuse count means the information is not supplied. 42 * 43 * Specifically, a zero active_arrival value means that the message did not 44 * reach the queue manager; and a zero agent_handoff time means that the 45 * queue manager did not give the message to a delivery agent. 46 * 47 * Some network clients update the conn_setup_done value when connection setup 48 * fails or completes. 49 * 50 * The deliver_done value is usually left at zero, which means use the wall 51 * clock time when reporting recipient status information. The exception is 52 * with delivery agents that can deliver multiple recipients in a single 53 * transaction. These agents explicitly update the deliver_done time stamp 54 * to ensure that multiple recipient records show the exact same delay 55 * values. 56 */ 57 typedef struct { 58 struct timeval incoming_arrival; /* incoming queue entry */ 59 struct timeval active_arrival; /* active queue entry */ 60 struct timeval agent_handoff; /* delivery agent hand-off */ 61 struct timeval conn_setup_done; /* connection set-up done */ 62 struct timeval deliver_done; /* transmission done */ 63 int reuse_count; /* connection reuse count */ 64 } MSG_STATS; 65 66 #define MSG_STATS_INIT(st) \ 67 ( \ 68 memset((char *) (st), 0, sizeof(*(st))), \ 69 (st) \ 70 ) 71 72 #define MSG_STATS_INIT1(st, member, value) \ 73 ( \ 74 memset((char *) (st), 0, sizeof(*(st))), \ 75 ((st)->member = (value)), \ 76 (st) \ 77 ) 78 79 #define MSG_STATS_INIT2(st, m1, v1, m2, v2) \ 80 ( \ 81 memset((char *) (st), 0, sizeof(*(st))), \ 82 ((st)->m1 = (v1)), \ 83 ((st)->m2 = (v2)), \ 84 (st) \ 85 ) 86 87 extern int msg_stats_scan(ATTR_SCAN_COMMON_FN, VSTREAM *, int, void *); 88 extern int msg_stats_print(ATTR_PRINT_COMMON_FN, VSTREAM *, int, const void *); 89 90 /* LICENSE 91 /* .ad 92 /* .fi 93 /* The Secure Mailer license must be distributed with this software. 94 /* AUTHOR(S) 95 /* Wietse Venema 96 /* IBM T.J. Watson Research 97 /* P.O. Box 704 98 /* Yorktown Heights, NY 10598, USA 99 /* 100 /* Wietse Venema 101 /* Google, Inc. 102 /* 111 8th Avenue 103 /* New York, NY 10011, USA 104 /*--*/ 105 106 #endif 107