#!/bin/ksh # ckurf.ksh by Dan Martin (DRM/CTG) Fri Sep 15 07:59:13 CDT 2000 # lgdir="/nfs/apps/maf/log" lgdir="${HOME}/log" tmpfi="/tmp/junk$$" outfi="/tmp/`basename ${0} .ksh`.txt" # Output File if [[ -z "$1" ]] then # urffi="${lgdir}/URF_D20000915_T001537.log" cd $lgdir ls -1t URF*.log >$tmpfi duh=`awk 'NR == 1 {print $0; exit}' $tmpfi` urffi="${lgdir}/${duh}" # log file to examine rm $tmpfi cd - else urffi="${lgdir}/$1" # log file to examine fi [[ -s "${urffi}" ]] || exit 1 # data eg: # Connecting to stream: 3 # URF0013I Sending Repoll request for NEI=404 SEQUENCE=7696 - 7696. # URF0013I Sending Repoll request for NEI=4 SEQUENCE=6 - 6. # URF0015W Repoll response for NEI=4 SEQUENCE=6 :RECORD NOT FOUND. # clear siz=`ls -s $urffi | awk '{print $1}'` if (( $siz > 10000 )) # 10000 = 5 Mb then echo "\nFile \"$urffi\" is too big: $siz blocks\n" exit 0 else echo "\nWorking..." fi awk -v lgf="${urffi}" ' # spc(n) slides n [more] spaces along the current line: function spc(n) {for (i = 0; i < n; i++) printf(" ")} # skip(n) jumps to the next line and skips down an additional (n-1) lines: function skip(n) {for (i = 0; i < n; i++) printf("\n")} BEGIN \ {printf("\nUPSTREAM REPOLL INFO FROM: %s\n\n", lgf) } # main() {if ($1 == "Connecting" && $2 == "to" && $3 == "stream:") print $0 if ($1 == "URF0013I" && $2 == "Sending" && $3 == "Repoll") {fld = split($6,eq,"=") # Break $6 into array with = as field delimiter nei = eq[2] # NEI Number ++nct[nei] # Count how many times each NEI has been repolled ++rep # Count total repolls } if ($1 == "URF0015W" && $2 == "Repoll" && $3 == "response") {fld = split($5,rnf,"=") # Break $5 into array with = as field delimiter nei = rnf[2] # NEI Number ++nnf[nei] # Count how many times each NEI has been NOT FOUND ++tnf # Count Total Not Founds } # Would it be worth a 2-D array to attach stream info to nct[] ? } END \ {printf("\n") spc(15); printf("NEID TIMES REPOLLED\n") spc(15); printf("==== ==============\n") for (nei in nct) {spc(15); printf("%4d %4d\n", nei, nct[nei])} skip(1) spc(5); printf("Total Repolls: %4s\n\n", rep) spc(15); printf("NEID TIMES NOT FOUND\n") spc(15); printf("==== ===============\n") for (nei in nnf) {spc(15); printf("%4d %4d\n", nei, nnf[nei])} skip(1) spc(1); printf("Repolls Not Found: %4s\n\n", tnf) }' $urffi | tee $outfi echo "Output above also resides in \"$outfi\".\n" # EOF ckurf.ksh