|
|
1.1 root 1: #
2: # Note, Date-Received knows abotu yout local timezone
3: #
4: ./grabheaders | awk '
5: BEGIN{
6: t = "Jan 31 Feb 28 Mar 31 Apr 30 May 31 Jun 30 Jul 31 Aug 31 Sep 30 Oct 31 Nov 30 Dec 31"
7: split(t,x)
8: n = 0;
9: for(i=1;i<24;i+=2) {
10: month[x[i]] = month[(i+1)/2] = (i+1)/2
11: days[(i+1)/2] = n
12: n += x[i+1]
13: }
14: }
15:
16: /^Date: /{
17: if (NF == 7 ){
18: t = $6
19: x[1] = $3
20: x[2] = $4
21: x[3] = $5
22: } else if (NF == 5 && split($3,x,"-") == 3) {
23: t = $4
24: } else if (NF == 4 && split($2,x,"-") == 3) {
25: t = $3
26: }else if (NF == 6) {
27: t = $5
28: x[1] = $2
29: x[2] = $3
30: x[3] = $4
31: }else{
32: print "Bad date",messageid, $0
33: next
34: }
35: sent = x[1] + days[month[x[2]]] + (x[3]-80)*365
36: if (x[3]%4 == 0 && month[x[2]] > 2)
37: sent++
38: split(t,x,":")
39: sent *= 60*24
40: sent += x[1] * 60 + x[2]
41: }
42: /^Date-Received: /{
43: if (NF < 3){
44: print "Date-received", messageid ,$0
45: rec = 0
46: next
47: }
48: split($2,x,"/")
49: rec = x[2] + days[x[1]+0] +(x[3]-80)*365
50: if (x[3]%4 == 0 && x[1] > 2)
51: rec++
52: split($3,x,":")
53: rec *= 60*24
54: rec += x[1] * 60 + x[2] + 1.44
55: if ($4 != "GMT")
56: rec += 60*5
57: if (rec > today)
58: today = rec
59: }
60: /^Message-ID: /{messageid = $2}
61: /^Path: /{
62: n = split($2,x,"!")
63: if( n > 2)
64: feed = x[2]
65: else
66: feed = x[1]
67: }
68: /^$/{
69: n = int((rec - sent)/(60*24)+0.999)
70: if( rec > 0 ) {
71: if ( n >= 0) {
72: adelay[n]++
73: if( n > amaxdelay)
74: amaxdelay = n
75: } else {
76: adelay[-1]++
77: print "Time Warp", messageid
78: }
79: totdelay++
80: feedsite[feed]++
81: }
82: rec = sent = 0
83: }
84: END {
85: n = int((rec - sent)/(60*24)+0.999)
86: if( rec > 0 ) {
87: if ( n >= 0) {
88: adelay[n]++
89: if( n > amaxdelay)
90: amaxdelay = n
91: } else {
92: adelay[-1]++
93: print "Time Warp", messageid
94: }
95: totdelay++
96: feedsite[feed]++
97: }
98: i = 0
99: count = 0
100: printf("\n\tPropagation Delay\n")
101: printf("\n\t No. of Cumulative\n")
102: printf("\tDays Articles Percent\n")
103: if (adelay[-1] > 0) {
104: printf("\t <0%8d%7d%% (Time Warp)\n",adelay[-1],0)
105: count += adelay[-1]
106: }
107: while (i <= amaxdelay) {
108: count += adelay[i]
109: if( adelay[i] != 0 )
110: printf("\t%3d%8d%7d%%\n",i,adelay[i],(count*100)/totdelay)
111: i++
112: }
113:
114: n = 0
115: for (i in feedsite)
116: ptr[++n] = i
117:
118: j = 1
119: while (j < n){
120: if (feedsite[ptr[j]] < feedsite[ptr[j+1]]){
121: temp = ptr[j]
122: ptr[j] = ptr[j+1]
123: ptr[j+1] = temp
124: if( j > 1) {
125: j--
126: continue
127: }
128: }
129: j++
130: }
131: printf("\n\tDistribution of news feeds\n")
132: printf("\t Count Percent Site\n")
133: j = 0
134: while (++j <= n){
135: i =feedsite[ptr[j]]
136: printf("\t%8d%7d%% %s\n",i,(i*100)/totdelay,ptr[j]);
137: }
138: }'
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.