* Update to packages/alpine.spec to account for the new location of man
[alpine.git] / alpine / mailtrfc.sh
blob456ee8178aec2a1c9ac8e828fd1c3ac0a1d7bcdc
1 #!/bin/sh
3 # $Id: mailtrfc.sh 761 2007-10-23 22:35:18Z hubert@u.washington.edu $
5 # T H E P I N E M A I L S Y S T E M
7 # Laurence Lundblade and Mike Seibel
8 # Networks and Distributed Computing
9 # Computing and Communications
10 # University of Washington
11 # Administration Building, AG-44
12 # Seattle, Washington, 98195, USA
13 # Internet: lgl@CAC.Washington.EDU
14 # mikes@CAC.Washington.EDU
16 # Please address all bugs and comments to "pine-bugs@cac.washington.edu"
19 # Pine and Pico are registered trademarks of the University of Washington.
20 # No commercial use of these trademarks may be made without prior written
21 # permission of the University of Washington.
23 # Pine, Pico, and Pilot software and its included text are Copyright
24 # 1989-1996 by the University of Washington.
26 # The full text of our legal notices is contained in the file called
27 # CPYRIGHT, included with this distribution.
30 # Pine is in part based on The Elm Mail System:
31 # ***********************************************************************
32 # * The Elm Mail System - Revision: 2.13 *
33 # * *
34 # * Copyright (c) 1986, 1987 Dave Taylor *
35 # * Copyright (c) 1988, 1989 USENET Community Trust *
36 # ***********************************************************************
42 # mailtrfc.sh -- A shell script to analyze the mail traffic as logged in
43 # /usr/spool/mqueue/syslog*. This currently as the University of Washington
44 # domains wired in and needs to be made more general. Also, lots more
45 # formats of message ID's could be added.
50 org=`awk '/^domain/ {print $2}' < /etc/resolv.conf`
51 domain=`echo $org | sed -e 's/^[^.]*\.//'`
52 host=`hostname`".$org"
54 echo "Domain: $domain"
55 echo "Organization: $org"
56 echo "Hostname: $host"
58 sed -n -e '/message-id/s/^.*</</p' |
59 awk 'BEGIN {mailers[0] = "Other";
60 mailers[1] = "Pine";
61 mailers[2] = "MailManager";
62 mailers[3] = "sendmail";
63 mailers[4] = "BITNET";
64 mailers[5] = "? news ?";
65 mailers[6] = "Sprint";
66 mailers[7] = "X.400";
67 mailers[8] = "Mac MS";
68 mailers[9] = "MMDF";
69 mailers[10] = "Andrew";
70 mailers[11] = "Columbia MM";
71 mailers[12] = "Unknown #1";
72 mailers[13] = "EasyMail";
73 mailers[14] = "CompuServe";
74 mailers[15] = "smail";
75 mailers[16] = "MCI Mail";
76 mailers[17] = "VAX MAIL(?)";
77 mailers[18] = "Gator Mail (?)";
78 mailers[19] = "TOTAL";
79 max = 19;}
80 {mailer = 0;}
81 /^<Pine/ {mailer = 1;}
82 /^<MailManager/ {mailer = 2;}
83 /^<[12]?[90]?9[0-9]1?[0-9][1-3]?[0-9]+\.[AaBb][AaBb][0-9]+@/ {mailer = 3;}
84 /^<[0-9A-Z]+@/ {mailer = 4;}
85 /^<199[0-9][A-Za-z]..[0-9]*\./ {mailer = 5;}
86 /@sprint.com/ {mailer = 6;}
87 /\/[A-Z]*=.*\/[A-Z]*=.*/ {mailer = 7;}
88 /^<MacMS\.[0-9]+\.[0-9]+\.[a-z]+@/ {mailer = 8;}
89 /^<MAILQUEUE-[0-9]+\.[0-9]+/ {mailer = 9;}
90 /^<.[d-l][A-Z0-9a-z=_]+00[A-Za-z0-9_=]+@/ {mailer = 10;}
91 /^<CMM\.[0-9]+\.[0-9]+\.[0-9]+/ {mailer = 11 ;}
92 /^<9[0-9][JFMASOND][aepuco][nbrylgptvc][0-9][0-9]?\.[0-9]+[a-z]+\./ {mailer = 12;}
93 /^<EasyMail\.[0-9]+/ {mailer = 13;}
94 /@CompuServe.COM/ {mailer = 14;}
95 /^<m[A-Za-z0-9].....-[0-9A-Za-z].....C@/ {mailer = 15;}
96 /@mcimail.com/ {mailer = 16;}
97 /^<9[0-9][01][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9].[0-9a-z]*@/ {mailer = 17;}
98 /^<0[0-9][0-9]+\.[0-9][0-9][0-9][0-9]+\.[0-9][0-9]+@/ {mailer=18;}
102 '"/$domain>/"' {campus[mailer]++; campus[max]++}
103 '"/$org>/"' {u[mailer]++; u[max]++}
104 '"/$host>/"' {milton[mailer]++; milton[max]++}
105 {total[mailer]++; total[max]++}
106 {if(mailer == 0) printf("-->%s\n",$0)}
107 END {
108 for(m = 0; m <= max; m++) {
109 printf("%-10.10s", mailers[m]);
110 printf(" %11d %11d %11d %11d %11d (%3d%%)\n", milton[m], u[m] - milton[m], campus[m] -u[m], total[m] - campus[m], total[m], (total[m]*100)/total[max]);
112 printf(" ---- (%3d%%) (%3d%%) (%3d%%) (%3d%%)\n", (milton[max]*100)/total[max], ((u[max] - milton[max])*100)/total[max], ((campus[max] - u[max])*100)/total[max], ((total[max] - campus[max])*100)/total[max], (u[max]*100)/total[max]);
114 }' > /tmp/syslogx.$$
117 echo $host $org $domain | \
118 awk '{printf(" %.17s %.11s %.11s Off Campus Total\n", $1, $2, $3)}'
119 egrep -v 'TOTAL|----|^-->' /tmp/syslogx.$$ | sort +0.60rn
120 egrep 'TOTAL|----' /tmp/syslogx.$$
121 grep '^-->' /tmp/syslogx.$$ | sed -e 's/-->//' > other-traffic
122 rm -f /tmp/syslogx.$$