-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqmailanalog.patch
166 lines (146 loc) · 5.28 KB
/
qmailanalog.patch
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
From [email protected] Wed Nov 05 04:10:01 2003
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
["4108" "" "4" "November" "2003" "23:08:30" "-0500" "John R Levine" "[email protected]" nil "140" "For qmail.org, patch to qmailanalog" "^From:" nil nil "11" nil "For qmail.org, patch to qmailanalog" nil nil nil nil nil nil]
nil)
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: (qmail 7390 invoked from network); 5 Nov 2003 04:10:01 -0000
Received: from unknown (HELO ns.crynwr.com) (192.203.178.14)
by desk.crynwr.com with SMTP; 5 Nov 2003 04:10:01 -0000
Received: (qmail 19093 invoked by uid 500); 5 Nov 2003 04:08:36 -0000
Delivered-To: [email protected]
Received: (qmail 19089 invoked from network); 5 Nov 2003 04:08:34 -0000
Received: from tom.iecc.com (208.31.42.38)
by pdam.crynwr.com with SMTP; 5 Nov 2003 04:08:34 -0000
Received: (qmail 12405 invoked from network); 5 Nov 2003 04:08:30 -0000
Received: (ofmipd 208.31.42.39); 5 Nov 2003 04:08:08 -0000
Message-ID: <[email protected]>
Cleverness: None detected
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
From: "John R Levine" <[email protected]>
To: "Russell Nelson" <[email protected]>
Subject: For qmail.org, patch to qmailanalog
Date: 4 Nov 2003 23:08:30 -0500
I'm working on the log analysis part of the book. Dan never updated
qmailanalog to handle the date stamps that multilog creates. Here's the
patch to do so. The interesting bits are stolen from Russ Alberry's
tai64frac which in turn stole them from Dan's tai64ocal.
It turns new dates into old dates rather than updating the code to use new
dates, because the analysis code is all awk scripts subtracting one
timestamp from another to find out how long deliveries took.
Yes, I tested it.
R's,
John
----- snip -----
This small patch modifies the matchup program to handle tai64
format dates. Lines that start with @ have dates translated to
the older seconds.nanoseconds format that qmailanalog wants.
Lines that don't start with @ are left alone, so that the pending
file that matchup writes can be processed properly.
John Levine, [email protected], Nov 2003
diff -C2 qmailanalog-dist/matchup.c qmailanalog-0.70/matchup.c
*** qmailanalog-dist/matchup.c Tue Nov 4 17:50:09 2003
--- qmailanalog-0.70/matchup.c Tue Nov 4 23:01:21 2003
***************
*** 184,187 ****
--- 184,228 ----
}
+ /* turn TAI date into old fashioned date */
+ /* dates without @ are left alone */
+
+ static char datebuf[FMT_ULONG+FMT_ULONG+2]; /* ssssssssss.ffffffffff\n */
+
+ char *
+ datize(s)
+ char *s;
+ {
+ int c;
+ int len;
+ unsigned long u;
+ unsigned long seconds = 0;
+ unsigned long nanoseconds = 0;
+
+ if(*s != '@') return s;
+ s++;
+
+ while ((c = *s++)) {
+ u = c - '0';
+ if (u >= 10) {
+ u = c - 'a';
+ if (u >= 6) break;
+ u += 10;
+ }
+ seconds <<= 4;
+ seconds += nanoseconds >> 28;
+ nanoseconds &= 0xfffffff;
+ nanoseconds <<= 4;
+ nanoseconds += u;
+ }
+ seconds -= 4611686018427387914ULL;
+
+ len = fmt_ulong(datebuf, seconds);
+ datebuf[len++] = '.';
+ len += fmt_ulong(datebuf+len, nanoseconds);
+ datebuf[len] = 0;
+
+ return datebuf;
+ }
+
stralloc line = {0};
int match;
***************
*** 210,214 ****
dstart.u[dpos] = pool.len;
! if (!stralloc_cats(&pool,line.s + field[0])) nomem();
if (!stralloc_0(&pool)) nomem();
--- 251,255 ----
dstart.u[dpos] = pool.len;
! if (!stralloc_cats(&pool,datize(line.s + field[0]))) nomem();
if (!stralloc_0(&pool)) nomem();
***************
*** 268,272 ****
outs(pool.s + birth.u[mpos]);
outs(" "); outs(pool.s + dstart.u[dpos]);
! outs(" "); outs(line.s + field[0]);
outs(" "); out(strnum,fmt_ulong(strnum,bytes.u[mpos]));
outs(" "); outs(pool.s + sender.u[mpos]);
--- 309,313 ----
outs(pool.s + birth.u[mpos]);
outs(" "); outs(pool.s + dstart.u[dpos]);
! outs(" "); outs(datize(line.s + field[0]));
outs(" "); out(strnum,fmt_ulong(strnum,bytes.u[mpos]));
outs(" "); outs(pool.s + sender.u[mpos]);
***************
*** 280,284 ****
outs(pool.s + dstart.u[dpos]);
outs(" "); outs(pool.s + dstart.u[dpos]);
! outs(" "); outs(line.s + field[0]);
outs(" 0 ? "); outs(pool.s + dchan.u[dpos]);
outs("."); outs(pool.s + drecip.u[dpos]);
--- 321,325 ----
outs(pool.s + dstart.u[dpos]);
outs(" "); outs(pool.s + dstart.u[dpos]);
! outs(" "); outs(datize(line.s + field[0]));
outs(" 0 ? "); outs(pool.s + dchan.u[dpos]);
outs("."); outs(pool.s + drecip.u[dpos]);
***************
*** 314,318 ****
outs("m "); outs(pool.s + birth.u[mpos]);
! outs(" "); outs(line.s + field[0]);
outs(" "); out(strnum,fmt_ulong(strnum,bytes.u[mpos]));
outs(" "); out(strnum,fmt_ulong(strnum,numk.u[mpos]));
--- 355,359 ----
outs("m "); outs(pool.s + birth.u[mpos]);
! outs(" "); outs(datize(line.s + field[0]));
outs(" "); out(strnum,fmt_ulong(strnum,bytes.u[mpos]));
outs(" "); out(strnum,fmt_ulong(strnum,numk.u[mpos]));
***************
*** 345,349 ****
birth.u[mpos] = pool.len;
! if (!stralloc_cats(&pool,line.s + field[0])) nomem();
if (!stralloc_0(&pool)) nomem();
--- 386,390 ----
birth.u[mpos] = pool.len;
! if (!stralloc_cats(&pool,datize(line.s + field[0]))) nomem();
if (!stralloc_0(&pool)) nomem();