|
|
1.1 root 1: #!/bin/sh
2: PATH=:/bin:/usr/bin:/usr/ucb
3: export PATH
4: rm -f /tmp/cmds /tmp/callsto /tmp/callsfrom /tmp/inuse /tmp/outuse
5: touch /tmp/cmds /tmp/inuse /tmp/outuse
6: cd /usr/spool/uucp
7: if [ $# -gt 0 ]
8: then
9: what="$1/uucico/* $1/uux*/* $1/xferstats/*"
10: else
11: if [ -f LOGFILE ]
12: then
13: what="LOGFILE SYSLOG"
14: else
15: what="LOG/uucico/* LOG/uux*/* LOG/xferstats/*"
16: fi
17: fi
18: sed -e "s/PATH=.*PATH;//
19: /REQUEST/d" $what |
20: /bin/awk '
21: BEGIN { fmon = fday = ftime = 99
22: lmon = lday = ltime = 0 }
23: $4 ~ /SUCCEEDED|OK/ {
24: t = substr($3,index($3,"-")+1,5)
25: split(t,time,":")
26: if($5 !~ /conversation/) {
27: startup[$2] = time[1]*60+time[2]
28: date[$2] = substr($3, 2, index($3,"-")-2)
29: }
30: }
31: $4 ~ /FAILED|CAUGHT|OK|TIMEOUT/ {
32: if(startup[$2] == 0 || $5 ~ /startup/)
33: continue
34: t = substr($3,index($3,"-")+1,5)
35: split(t,time,":")
36: elapsed = time[1]*60+time[2] - startup[$2]
37: if (elapsed < 0 )
38: elapsed += 24*60
39: if (elapsed == 0)
40: elapsed = 1
41: if(callto[$2] ){
42: totcallto[$2] += elapsed
43: numcallto[$2]++
44: printf("%s\t%s\t%02d:%02d - %02d:%02d\n",$2,date[$2],startup[$2]/60,startup[$2]%60,time[1],time[2])>>"/tmp/callsto"
45: }else{
46: totcallby[$2] += elapsed
47: numcallby[$2]++
48: printf("%s\t%s\t%02d:%02d - %02d:%02d\n",$2,date[$2],startup[$2]/60,startup[$2]%60,time[1],time[2])>>"/tmp/callsfrom"
49: }
50: callto[$2] = 0
51: startup[$2] = 0
52: }
53: $4 ~ /SUCCEEDED/{
54: if ($5 ~ /call/)
55: callto[$2]++
56: }
57: $4 ~ /FAILED|CAUGHT/{
58: if ($5 ~ /call|conversation|SIGNAL/ )
59: failed[$2]++
60: }
61: $5 ~ /sent/{
62: sentbytes[$2] += $7
63: sentfiles[$2] ++
64: seconds[$2] += $9
65: retries[$2] += $11
66: havout = 1
67: outuse[$1] = $1
68: outusebytes[$1] += $7
69: outusefiles[$1] ++
70: outusesecs[$1] += $9
71: }
72: $5 ~ /received/{
73: recbytes[$2] += $7
74: recfiles[$2] ++
75: seconds[$2] += $9
76: retries[$2] += $11
77: havin = 1
78: inuse[$2 "!" $1] = $2 "!" $1
79: inusebytes[$2 "!" $1] += $7
80: inusefiles[$2 "!" $1] ++
81: inusesecs[$2 "!" $1] += $9
82: }
83: $5 ~/XQT/{
84: if( $7 ~ /!|@/ && $6 ~ /rmail/)
85: printf("%s\t%s\t%-8s\t%s\n",substr($3,2,index($3,"-")-2),substr($3,index($3,"-")+1,5),$2 "!" $4,$7)>>"/tmp/cmds"
86: }
87: $4 ~/XQT/{
88: if ($1 ~ /uucp|daemon|root|news/ || $7 != "rmail")
89: continue
90: printf("%s\t%s\t%-8s\t%s!%s\n",substr($3,2,index($3,"-")-2),substr($3,index($3,"-")+1,5),$1,$2,$7)>>"/tmp/cmds"
91: }
92: $10 ~/secs/ {
93: curtime = substr($4, 5, 6)
94: dtmp = curtime - int($9) - lasttime[$2]
95: if (dtmp > 0 && dtmp < 20)
96: dead[$2] += dtmp
97: lasttime[$2] = curtime
98: live[$2] += $9
99: }
100: {
101: n = index ($3, "/")
102: thismon = 0
103: if (n > 0 ) {
104: thismon = int(substr($3, 2, n-2))
105: if (lmon < thismon)
106: lmon = thismon
107: if (thismon < fmon)
108: fmon = thismon
109: }
110: m = index ($3, "-")
111: n++
112: thisday = 0
113: if( (m-n) > 0 ) {
114: thisday = int(substr($3, n, m-n))
115: if ((lday < thisday) && (lmon == thismon) || ldaymon != lmon) {
116: lday = thisday
117: ldaymon = thismon
118: }
119: if ((thisday < fday) && (fmon == thismon) || fdaymon != fmon) {
120: fday = thisday
121: fdaymon = thismon
122: }
123: }
124: thistime = substr($3,m+1,5)
125: if ((ltime < thistime) && (lmon == thismon) && (lday == thisday))
126: ltime = thistime
127: if ((thistime < ftime) && (fmon == thismon) && (fday == thisday))
128: ftime = thistime
129: }
130: END{
131: printf("\n\t\t\t\tUUCP Traffic Summary\n\n")
132: printf("\t\t\t\tFrom %d/%d %s To %d/%d %s\n\n",fmon,fday,ftime,lmon,lday,ltime)
133: printf("\t Calls Minutes Files Bytes Effective Unused\n")
134: printf("Site[Failed] To/From To/From To/From Sent/Received Baudrate Bandwidth\n")
135: for( i in startup ){
136: if(seconds[i]== 0)seconds[i]++
137: if(dead[i]+live[i])
138: percent = dead[i]*100/(dead[i]+live[i])
139: else
140: percent = 0
141: if (failed[i] || retries[i]) {
142: temp = i "[" failed[i]
143: if (retries[i])
144: temp = temp "/" retries[i] "]"
145: else
146: temp = temp "]"
147: } else
148: temp = i
149: printf("%-12s %3d/%-3d %5d/%-5d %4d/%-4d %8d/%-8d %6d %5d%%\n",\
150: temp,numcallto[i],numcallby[i],\
151: totcallto[i],totcallby[i],\
152: sentfiles[i],recfiles[i],\
153: sentbytes[i],recbytes[i],\
154: (recbytes[i]+sentbytes[i])*8/seconds[i],\
155: percent)
156: }
157: printf("\n\n\n\t\t\t\tOriginating Users\n\n")
158: printf("User\t\t Minutes Files Bytes\n\n")
159: if (havout == 1) {
160: for (i in outuse) {
161: printf("%-21s %5d %7d %8d\n", i,\
162: (outusesecs[i]+30)/60,\
163: outusefiles[i], outusebytes[i]) >> "/tmp/outuse"
164: }
165: }
166: if (havin == 1) {
167: for (i in inuse) {
168: printf("%-21s %5d %7d %8d\n", i,\
169: (inusesecs[i]+30)/60,\
170: inusefiles[i], inusebytes[i]) >> "/tmp/inuse"
171: }
172: }
173: }'
174:
175: sort /tmp/outuse
176: echo " "
177: sort /tmp/inuse
178: echo " "
179: echo " "
180: echo " "
181: echo " Long Distance Calls"
182: echo
183: echo "To Day Start - End From Day Start - End"
184: cat >/tmp/$$local<<!!!
185: /^ut/d
186: !!!
187: sed -f /tmp/$$local /tmp/callsto | /bin/awk '
188: {
189: if (last == $1)
190: pr = ""
191: else {
192: last = $1
193: pr = $1
194: }
195: if (pr == "" && date == $2)
196: pd = ""
197: else {
198: date = $2
199: pd = $2
200: }
201: printf("%s\t%s\t%s - %s\n",pr,pd,$3,$5)
202: }'>/tmp/$$a
203: sed -f /tmp/$$local /tmp/callsfrom | /bin/awk '
204: {
205: if (last == $1)
206: pr = ""
207: else {
208: last = $1
209: pr = $1
210: }
211: if (pr == "" && date == $2)
212: pd = ""
213: else {
214: date = $2
215: pd = $2
216: }
217: printf("%s\t%s\t%s - %s\n",pr,pd,$3,$5)
218: }'>/tmp/$$b
219: pr -t -m /tmp/$$a /tmp/$$b | uniq
220: rm -f /tmp/$$[ab]
221: sed -e "
222: /rmail seismo!/d
223: /rmail rlgvax!/d
224: /rmail rochester!/d
225: /rmail umcp-cs!/d
226: /rmail brl-tgr!/d
227: /rmail brl-vgr!/d
228: s/)$//
229: " /tmp/cmds >/tmp/$$c
230: if [ -s /tmp/$$c ]
231: then
232: echo " "
233: echo " "
234: echo " "
235: echo " Outgoing Mail from Other Sites"
236: echo
237: echo "Day Time From To"
238: cat /tmp/$$c
239: fi
240: rm -f /tmp/cmds /tmp/$$* /tmp/callsto /tmp/callsfrom /tmp/inuse /tmp/outuse
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.