1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#ifndef MAIL_STATS_H
#define MAIL_STATS_H
#include <sys/time.h>
#include "net.h"
#include "guid.h"
#include "stats.h"
struct stats_send_ctx;
struct mail_command {
struct mail_command *stable_prev, *stable_next;
struct mail_command *session_prev, *session_next;
struct mail_session *session;
char *name, *args;
/* non-zero id means the command is still running */
unsigned int id;
struct timeval last_update;
struct stats *stats;
int refcount;
};
struct mail_session {
struct mail_session *stable_prev, *stable_next;
struct mail_session *sorted_prev, *sorted_next;
struct mail_session *user_prev, *user_next;
struct mail_session *ip_prev, *ip_next;
/* if id="", the session no longer exists */
char *id;
struct mail_user *user;
const char *service;
pid_t pid;
/* ip address may be NULL if there's none */
struct mail_ip *ip;
struct timeout *to_idle;
struct stats *stats;
struct timeval last_update;
unsigned int num_cmds;
bool disconnected;
unsigned int highest_cmd_id;
int refcount;
struct mail_command *commands;
};
struct mail_user {
struct mail_user *stable_prev, *stable_next;
struct mail_user *sorted_prev, *sorted_next;
struct mail_user *domain_prev, *domain_next;
char *name;
struct mail_domain *domain;
time_t reset_timestamp;
struct timeval last_update;
struct stats *stats;
unsigned int num_logins;
unsigned int num_cmds;
int refcount;
struct mail_session *sessions;
};
struct mail_domain {
struct mail_domain *stable_prev, *stable_next;
struct mail_domain *sorted_prev, *sorted_next;
char *name;
time_t reset_timestamp;
struct timeval last_update;
struct stats *stats;
unsigned int num_logins;
unsigned int num_cmds;
unsigned int num_connected_sessions;
int refcount;
struct mail_user *users;
};
struct mail_ip {
struct mail_ip *stable_prev, *stable_next;
struct mail_ip *sorted_prev, *sorted_next;
struct ip_addr ip;
time_t reset_timestamp;
struct timeval last_update;
struct stats *stats;
unsigned int num_logins;
unsigned int num_cmds;
unsigned int num_connected_sessions;
int refcount;
struct mail_session *sessions;
};
struct mail_global {
time_t reset_timestamp;
struct timeval last_update;
struct stats *stats;
unsigned int num_logins;
unsigned int num_cmds;
unsigned int num_connected_sessions;
struct timeout *to_stats_send;
struct stats_send_ctx *stats_send_ctx;
};
extern struct mail_global mail_global_stats;
void mail_global_init(void);
void mail_global_deinit(void);
void mail_global_login(void);
void mail_global_disconnected(void);
void mail_global_refresh(const struct stats *diff_stats);
#endif
|