Annotation of 43BSD/contrib/news/misc/delay, revision 1.1

1.1     ! root        1: startdir=/usr/spool/news/net
        !             2: history=/usr/lib/news/history
        !             3: rm=rm
        !             4: sed -e "
        !             5: 1i\\
        !             6: cd $startdir
        !             7: s/.*   //
        !             8: s/ .*//
        !             9: s/net\.//
        !            10: s!\.!/!g
        !            11: s!^!sed '/^\$/q' !
        !            12: " $history | sh |
        !            13: awk '
        !            14: BEGIN{
        !            15:        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"
        !            16:        split(t,x)
        !            17:        n = 0;
        !            18:        for(i=1;i<24;i+=2) {
        !            19:                month[x[i]] = (i+1)/2
        !            20:                days[(i+1)/2] = n
        !            21:                n += x[i+1]
        !            22:        }
        !            23: }
        !            24: 
        !            25: /^Date: /{
        !            26:        if (NF == 7 ){
        !            27:                t = $6
        !            28:                x[1] = $3
        !            29:                x[2] = $4
        !            30:                x[3] = $5
        !            31:        } else if (NF == 5 && split($3,x,"-") == 3) {
        !            32:                t = $4
        !            33:        } else if (NF == 4 && split($2,x,"-") == 3) {
        !            34:                t = $3
        !            35:        }else if (NF == 6) {
        !            36:                t = $5
        !            37:                x[1] = $2
        !            38:                x[2] = $3
        !            39:                x[3] = $4
        !            40:        }else{
        !            41:                print "Bad date",messageid, $0
        !            42:                next
        !            43:        }
        !            44:        sent = x[1] + days[month[x[2]]] + (x[3]-80)*365
        !            45:        if (x[3]%4 == 0 && month[x[2]] > 2)
        !            46:                sent++
        !            47:        split(t,x,":")
        !            48:        sent *= 60*24
        !            49:        sent += x[1] * 60 + x[2]
        !            50: }
        !            51: /^Date-Received: /{
        !            52:        if (NF == 7 ){
        !            53:                t = $6
        !            54:                x[1] = $3
        !            55:                x[2] = $4
        !            56:                x[3] = $5
        !            57:        } else if (NF == 5 && split($3,x,"-") == 3) {
        !            58:                t = $4
        !            59:        } else if (NF == 4 && split($2,x,"-") == 3) {
        !            60:                t = $3
        !            61:        }else if (NF == 6) {
        !            62:                t = $5
        !            63:                x[1] = $2
        !            64:                x[2] = $3
        !            65:                x[3] = $4
        !            66:        }else{
        !            67:                print "Bad date",messageid, $0
        !            68:                continue
        !            69:        }
        !            70:        rec = x[3]*10000 +  month[x[2]]* 100 + x[1]
        !            71:        if (rec > today)
        !            72:                today = rec
        !            73:        rec = x[1] + days[month[x[2]]] + (x[3]-80)*365
        !            74:        if (x[3]%4 == 0 && month[x[2]] > 2)
        !            75:                rec++
        !            76:        split(t,x,":")
        !            77:        rec *= 60*24
        !            78:        rec += x[1] * 60 + x[2] +1.44
        !            79: }
        !            80: /^Message-ID: /{messageid = $2}
        !            81: /^Path: /{
        !            82:        n = split($2,x,"!")
        !            83:        if( n > 2)
        !            84:                feed = x[2]
        !            85:        else
        !            86:                feed = x[1]
        !            87: }
        !            88: /^Relay-Version: /{
        !            89:        n = int((rec - sent)/(60*24)+0.999)
        !            90:        if( rec > 0 ) {
        !            91:                if ( n >= 0) {
        !            92:                        adelay[n]++
        !            93:                        if( n > amaxdelay)
        !            94:                                amaxdelay = n
        !            95:                } else {
        !            96:                        adelay[-1]++
        !            97:                        print "Time Warp", messageid
        !            98:                }
        !            99:                totdelay++
        !           100:                feedsite[feed]++
        !           101:        }
        !           102:        rec = sent = 0
        !           103: }
        !           104: END {
        !           105:        n = int((rec - sent)/(60*24)+0.999)
        !           106:        if( rec > 0 ) {
        !           107:                if ( n >= 0) {
        !           108:                        adelay[n]++
        !           109:                        if( n > amaxdelay)
        !           110:                                amaxdelay = n
        !           111:                } else {
        !           112:                        adelay[-1]++
        !           113:                        print "Time Warp", messageid
        !           114:                }
        !           115:                totdelay++
        !           116:                feedsite[feed]++
        !           117:        }
        !           118:        i = 0
        !           119:        count = 0
        !           120:        printf("\n\tPropagation Delay\n")
        !           121:        printf("\n\t     No. of   Cumulative\n")
        !           122:        printf("\tDays Articles Percent\n")
        !           123:        if (adelay[-1] > 0) {
        !           124:                printf("\t <0%8d%7d%% (Time Warp)\n",adelay[-1],0)
        !           125:                count += adelay[-1]
        !           126:        }
        !           127:        while (i <= amaxdelay) {
        !           128:                count += adelay[i]
        !           129:                if( adelay[i] != 0 )
        !           130:                        printf("\t%3d%8d%7d%%\n",i,adelay[i],(count*100)/totdelay)
        !           131:                i++
        !           132:        }
        !           133: 
        !           134:        n = 0
        !           135:        for (i in feedsite)
        !           136:                ptr[++n] = i
        !           137: 
        !           138:        j = 1
        !           139:        while (j < n){
        !           140:                if  (feedsite[ptr[j]] < feedsite[ptr[j+1]]){
        !           141:                        temp = ptr[j]
        !           142:                        ptr[j] = ptr[j+1]
        !           143:                        ptr[j+1] = temp
        !           144:                        if( j > 1) {
        !           145:                                j--
        !           146:                                continue
        !           147:                        }
        !           148:                }
        !           149:                j++
        !           150:        }
        !           151:        printf("\n\tDistribution of news feeds\n")
        !           152:        printf("\t   Count Percent   Site\n")
        !           153:        j = 0
        !           154:        while (++j <= n){
        !           155:                i =feedsite[ptr[j]]
        !           156:                printf("\t%8d%7d%%   %s\n",i,(i*100)/totdelay,ptr[j]);
        !           157:        }
        !           158: }'

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.