Mercurial > dovecot > core-2.2
annotate src/stats/mail-stats.h @ 22715:20415dd0b85a
dsync: Add per-mailbox sync lock that is always used.
Both importing and exporting gets the lock before they even sync the
mailbox. The lock is kept until the import/export finishes. This guarantees
that no matter how dsync is run, two dsyncs can't be working on the same
mailbox at the same time.
This lock is in addition to the optional per-user lock enabled by the -l
parameter. If the -l parameter is used, the same lock timeout is used for
the per-mailbox lock. Otherwise 30s timeout is used.
This should help to avoid email duplication when replication is enabled for
public namespaces, and maybe in some other rare situations as well.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 28 Dec 2017 14:10:23 +0200 |
parents | 968da3b58769 |
children |
rev | line source |
---|---|
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 #ifndef MAIL_STATS_H |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 #define MAIL_STATS_H |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
18406
736730cf45f0
stats: Fixed compiling with some OSes.
Timo Sirainen <tss@iki.fi>
parents:
18292
diff
changeset
|
4 #include <sys/time.h> |
736730cf45f0
stats: Fixed compiling with some OSes.
Timo Sirainen <tss@iki.fi>
parents:
18292
diff
changeset
|
5 |
15187
02451e967a06
Renamed network.[ch] to net.[ch].
Timo Sirainen <tss@iki.fi>
parents:
13457
diff
changeset
|
6 #include "net.h" |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "guid.h" |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
8 #include "stats.h" |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 |
21098
968da3b58769
stats: Add support for carbon-server
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
18406
diff
changeset
|
10 struct stats_send_ctx; |
968da3b58769
stats: Add support for carbon-server
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
18406
diff
changeset
|
11 |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 struct mail_command { |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 struct mail_command *stable_prev, *stable_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 struct mail_command *session_prev, *session_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 struct mail_session *session; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 char *name, *args; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 /* non-zero id means the command is still running */ |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 unsigned int id; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
13358
fd68963a7add
stats: Keep track of last_update in microsecond precision and export it as such.
Timo Sirainen <tss@iki.fi>
parents:
13345
diff
changeset
|
21 struct timeval last_update; |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
22 struct stats *stats; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 int refcount; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 }; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 struct mail_session { |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 struct mail_session *stable_prev, *stable_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 struct mail_session *sorted_prev, *sorted_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 struct mail_session *user_prev, *user_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 struct mail_session *ip_prev, *ip_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 |
18072
0694bfec140a
stats: Use the same session ID string for stats tracking as everywhere else.
Timo Sirainen <tss@iki.fi>
parents:
18070
diff
changeset
|
33 /* if id="", the session no longer exists */ |
0694bfec140a
stats: Use the same session ID string for stats tracking as everywhere else.
Timo Sirainen <tss@iki.fi>
parents:
18070
diff
changeset
|
34 char *id; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 struct mail_user *user; |
18070
688da3675901
stats: Use the new str-table API to reduce memory usage for service strings.
Timo Sirainen <tss@iki.fi>
parents:
18068
diff
changeset
|
36 const char *service; |
13359
07f02f421588
stats: Keep track of session's PIDs.
Timo Sirainen <tss@iki.fi>
parents:
13358
diff
changeset
|
37 pid_t pid; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 /* ip address may be NULL if there's none */ |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 struct mail_ip *ip; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 struct timeout *to_idle; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
42 struct stats *stats; |
13358
fd68963a7add
stats: Keep track of last_update in microsecond precision and export it as such.
Timo Sirainen <tss@iki.fi>
parents:
13345
diff
changeset
|
43 struct timeval last_update; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 unsigned int num_cmds; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 bool disconnected; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 unsigned int highest_cmd_id; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 int refcount; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 struct mail_command *commands; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 }; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 struct mail_user { |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 struct mail_user *stable_prev, *stable_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 struct mail_user *sorted_prev, *sorted_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 struct mail_user *domain_prev, *domain_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 char *name; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 struct mail_domain *domain; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 time_t reset_timestamp; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 |
13358
fd68963a7add
stats: Keep track of last_update in microsecond precision and export it as such.
Timo Sirainen <tss@iki.fi>
parents:
13345
diff
changeset
|
60 struct timeval last_update; |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
61 struct stats *stats; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 unsigned int num_logins; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 unsigned int num_cmds; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 int refcount; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 struct mail_session *sessions; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 }; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 struct mail_domain { |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 struct mail_domain *stable_prev, *stable_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 struct mail_domain *sorted_prev, *sorted_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 char *name; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 time_t reset_timestamp; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 |
13358
fd68963a7add
stats: Keep track of last_update in microsecond precision and export it as such.
Timo Sirainen <tss@iki.fi>
parents:
13345
diff
changeset
|
75 struct timeval last_update; |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
76 struct stats *stats; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 unsigned int num_logins; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 unsigned int num_cmds; |
17706
f78d4b2bb6c3
stats: Added num_connected_sessions for domains and IPs.
Timo Sirainen <tss@iki.fi>
parents:
17109
diff
changeset
|
79 unsigned int num_connected_sessions; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 int refcount; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 struct mail_user *users; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 }; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
85 struct mail_ip { |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 struct mail_ip *stable_prev, *stable_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
87 struct mail_ip *sorted_prev, *sorted_next; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 struct ip_addr ip; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 time_t reset_timestamp; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 |
13358
fd68963a7add
stats: Keep track of last_update in microsecond precision and export it as such.
Timo Sirainen <tss@iki.fi>
parents:
13345
diff
changeset
|
91 struct timeval last_update; |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
92 struct stats *stats; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 unsigned int num_logins; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 unsigned int num_cmds; |
17706
f78d4b2bb6c3
stats: Added num_connected_sessions for domains and IPs.
Timo Sirainen <tss@iki.fi>
parents:
17109
diff
changeset
|
95 unsigned int num_connected_sessions; |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 int refcount; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 struct mail_session *sessions; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
99 }; |
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 |
18068
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
101 struct mail_global { |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
102 time_t reset_timestamp; |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
103 |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
104 struct timeval last_update; |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
105 struct stats *stats; |
18068
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
106 unsigned int num_logins; |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
107 unsigned int num_cmds; |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
108 unsigned int num_connected_sessions; |
21098
968da3b58769
stats: Add support for carbon-server
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
18406
diff
changeset
|
109 |
968da3b58769
stats: Add support for carbon-server
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
18406
diff
changeset
|
110 struct timeout *to_stats_send; |
968da3b58769
stats: Add support for carbon-server
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
18406
diff
changeset
|
111 struct stats_send_ctx *stats_send_ctx; |
18068
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
112 }; |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
113 |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
114 extern struct mail_global mail_global_stats; |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
115 |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
116 void mail_global_init(void); |
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
117 void mail_global_deinit(void); |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 |
18068
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
119 void mail_global_login(void); |
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
120 void mail_global_disconnected(void); |
18292
a9952ceeac61
stats process/plugin redesign to be more modular.
Timo Sirainen <tss@iki.fi>
parents:
18072
diff
changeset
|
121 void mail_global_refresh(const struct stats *diff_stats); |
18068
9c2bcafcf121
stats: Added support for "global" stats type.
Timo Sirainen <tss@iki.fi>
parents:
17706
diff
changeset
|
122 |
13294
c51fbe64eae1
Initial implementation of statistics gathering daemon and plugins to feed it.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 #endif |