1*48638Sbostic# An awk script for printing a pretty report of UUCP activities from the 2*48638Sbostic# UUCP SYSLOG - Erik E. Fair October 2, 1984 3*48638Sbostic# 4*48638Sbostic# v7 UUCP 5*48638Sbostic$4 == "received" { 6*48638Sbostic sysname[$2] = $2; 7*48638Sbostic by_rec[$2] += $6; 8*48638Sbostic sec_rec[$2] += $8; 9*48638Sbostic sys_xf[$2] ++; 10*48638Sbostic} 11*48638Sbostic# 12*48638Sbostic# 4.2 BSD UUCP 13*48638Sbostic$5 == "received" { 14*48638Sbostic sysname[$2] = $2; 15*48638Sbostic by_rec[$2] += $7; 16*48638Sbostic sec_rec[$2] += $9; 17*48638Sbostic sys_xf[$2] ++; 18*48638Sbostic} 19*48638Sbostic# 20*48638Sbostic# System V UUCP 21*48638Sbostic$6 == "<-" { 22*48638Sbostic $1 = substr($1, 1, (index($1, "!") - 1)); 23*48638Sbostic sysname[$1] = $1; 24*48638Sbostic by_rec[$1] += $7; 25*48638Sbostic sec_rec[$1] += $9; 26*48638Sbostic sys_xf[$1] ++; 27*48638Sbostic} 28*48638Sbostic# 29*48638Sbostic# v7 UUCP 30*48638Sbostic$4 == "sent" { 31*48638Sbostic sysname[$2] = $2; 32*48638Sbostic by_xmt[$2] += $6; 33*48638Sbostic sec_xmt[$2] += $8; 34*48638Sbostic sys_xf[$2] ++; 35*48638Sbostic} 36*48638Sbostic# 37*48638Sbostic# 4.2 BSD UUCP 38*48638Sbostic$5 == "sent" { 39*48638Sbostic sysname[$2] = $2; 40*48638Sbostic by_xmt[$2] += $7; 41*48638Sbostic sec_xmt[$2] += $9; 42*48638Sbostic sys_xf[$2] ++; 43*48638Sbostic} 44*48638Sbostic# 45*48638Sbostic# System V UUCP 46*48638Sbostic$6 == "->" { 47*48638Sbostic $1 = substr($1, 1, (index($1, "!") - 1)); 48*48638Sbostic sysname[$1] = $1; 49*48638Sbostic by_xmt[$1] += $7; 50*48638Sbostic sec_xmt[$1] += $9; 51*48638Sbostic sys_xf[$1] ++; 52*48638Sbostic} 53*48638SbosticEND { 54*48638Sbostic# 55*48638Sbostic# print a report header 56*48638Sbostic printf("System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt\n") 57*48638Sbostic for(i in sysname) { 58*48638Sbostic# 59*48638Sbostic# sort report by most connect time (selection sort) 60*48638Sbostic first = 0; 61*48638Sbostic for(j in sysname) { 62*48638Sbostic if (sys_xf[j] > 0) { 63*48638Sbostic tmp1 = sec_xmt[j]; 64*48638Sbostic tmp2 = sec_rec[j]; 65*48638Sbostic# Stupid AWK bug - needs a simple expression 66*48638Sbostic time = (tmp1 + tmp2); 67*48638Sbostic if (time > first) { 68*48638Sbostic first = time; 69*48638Sbostic sys = sysname[j]; 70*48638Sbostic } 71*48638Sbostic } 72*48638Sbostic } 73*48638Sbostic# 74*48638Sbostic# 4.2 BSD awk seems to have problems. This check should not be necessary. 75*48638Sbostic# Oddly enough, this problem also shows up in System V. WHY??? 76*48638Sbostic if (sys_xf[sys] != 0) { 77*48638Sbostic# 78*48638Sbostic# time for some bean counting 79*48638Sbostic tmp1 = sec_xmt[sys]; 80*48638Sbostic tmp2 = sec_rec[sys]; 81*48638Sbostic# Stupid AWK bug - needs a simple expression 82*48638Sbostic time = (tmp1 + tmp2); 83*48638Sbostic hours = time / 3600; 84*48638Sbostic sec = time % 3600; 85*48638Sbostic min = sec / 60; 86*48638Sbostic sec %= 60; 87*48638Sbostic tot_xf += sys_xf[sys]; 88*48638Sbostic tot_by_rec += by_rec[sys]; 89*48638Sbostic tot_by_xmt += by_xmt[sys]; 90*48638Sbostic tot_time += time; 91*48638Sbostic# 92*48638Sbostic# protect myself against mathematical crime (divide by zero) 93*48638Sbostic if (sec_rec[sys] == 0) 94*48638Sbostic sec_rec[sys] = 1; 95*48638Sbostic if (sec_xmt[sys] == 0) 96*48638Sbostic sec_xmt[sys] = 1; 97*48638Sbostic# 98*48638Sbostic# print a pretty system report (god what an awful printf format...) 99*48638Sbostic printf("%-8s%8d%11d%11d%4d:%.2d:%.2d%8d%9d%9d\n", \ 100*48638Sbosticsysname[sys], sys_xf[sys], by_rec[sys], by_xmt[sys], hours, min, sec, \ 101*48638Sbostic((by_rec[sys] + by_xmt[sys]) / sys_xf[sys]), \ 102*48638Sbostic(by_rec[sys] / sec_rec[sys]), \ 103*48638Sbostic(by_xmt[sys] / sec_xmt[sys])); 104*48638Sbostic# 105*48638Sbostic# make certain we will not see this system again... (selection sort) 106*48638Sbostic sys_xf[sys] = 0; 107*48638Sbostic } 108*48638Sbostic } 109*48638Sbostic# 110*48638Sbostic# calculate time split for total time (and print totals [*shudder*]) 111*48638Sbostic hours = tot_time / 3600; 112*48638Sbostic sec = tot_time % 3600; 113*48638Sbostic min = sec / 60; 114*48638Sbostic sec %= 60; 115*48638Sbostic printf("\n%-8s%8d%11d%11d%4d:%.2d:%.2d\n", \ 116*48638Sbostic "TOTALS", tot_xf, tot_by_rec, tot_by_xmt, hours, min, sec); 117*48638Sbostic} 118