home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 4.0 PR1 / NeXT_NEXTSTEP_4.0_PR1_(beta).rar / Openstep4-Pr1User.iso / private / etc / uucp / UUAIDS / uucpsummary < prev    next >
Text File  |  1995-09-02  |  5KB  |  241 lines

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