home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / NN / _NN-SPOO.TAR / usr / bin / nnstats < prev    next >
Encoding:
Text File  |  1994-09-13  |  3.2 KB  |  157 lines

  1. #!/bin/sh
  2.  
  3. # Generated by nn release 6.4.18
  4.  
  5. VERSION="6.4.18"
  6. INEWS="/usr/bin/inews"
  7. INEWS_DIR="/usr/bin"
  8. AWK="awk"
  9. NNTP=false
  10. ACTIVE=/var/lib/news/active
  11. LOG=/usr/lib/nn/Log
  12. TMP=${TMPDIR-/usr/tmp}
  13. DB=/var/spool/nn
  14. BIN=/usr/bin
  15. LIB=/usr/lib/nn
  16. AUTH=false
  17.  
  18. # ---- end of prefix
  19.  
  20. # --- prefix is inserted above by make ---
  21. #
  22. # Extract collection & expiration statistics from Log file.
  23. #
  24. # From: Mark Moraes <moraes@csri.toronto.edu>
  25. #
  26. # Heavily modified by Kim F. Storm:
  27. #  Added expiration statistics
  28. #  Will now make daily statistics & grand summary
  29. #  Split into two awk scripts to fit in argument list space
  30. #  (and as a side-effect to be able to use functions in old awk!!!)
  31.  
  32. CHECK="0>0"
  33. LONG=0
  34. SUMMARY=1
  35. debug=false
  36.  
  37. LOOP=true
  38. while $LOOP; do
  39.   case "$1" in
  40.   -l)    LONG=1
  41.     shift;;
  42.   -d)    CHECK="\$2!=\"$2\" || \$3!=\"$3\""
  43.     shift; shift; shift;;
  44.   -m)    CHECK="\$2!=\"$2\""
  45.     shift; shift;;
  46.   -t)   SUMMARY=0
  47.     shift;;
  48.   -D)    debug=true
  49.     shift;;
  50.   -*)   echo "unknown option: $1"
  51.     exit 1;;
  52.   *)    LOOP=false
  53.     ;;
  54.   esac
  55. done
  56.  
  57. grep '^[CX]:' `ls -tr ${@-$LOG}` |
  58. ${AWK} 'BEGIN{
  59.   day="0"; l='$LONG'; t='$SUMMARY'
  60.   f=" %d %d %d %d %d %d %d\n"
  61. }
  62. '"$CHECK"' { next }
  63. day!=$3{
  64.   if(day!="0")print "d " date
  65.   if(l && day!="0" && (run>0 || xrun>0)){
  66.     print "h"
  67.     printf "c" f,run,art,Mart,gr,Mgr,sec,Msec
  68.     printf "e" f,xrun,xart,xMart,xgr,xMgr,xsec,xMsec
  69.   }
  70.   day=$3
  71.   date=$2 " " $3
  72.   run=art=gr=sec=0
  73.   Mart=Mgr=Msec=0
  74.   xrun=xart=xgr=xsec=0
  75.   xMart=xMgr=xMsec=0
  76. }
  77. $6=="Collect:" {
  78.   if ($7 <= 0) next
  79.   run++; art+=$7; gr+=$9; sec+=$11
  80.   Trun++; Tart+=$7; Tgr+=$9; Tsec+=$11
  81.   if ($7 > Mart) Mart=$7;
  82.   if ($9 > Mgr) Mgr=$9;
  83.   if ($11 > Msec) Msec=$11;
  84.   if ($11 > 0) A=$7 / $11; else A=$7;
  85.   if (A > Mps) Mps=A;
  86.   next
  87. }
  88. $6=="Expire:" {
  89.   if ($7 <= 0) next
  90.   xrun++; xart+=$7; xgr+=$9; xsec+=$11
  91.   xTrun++; xTart+=$7; xTgr+=$9; xTsec+=$11
  92.   if ($7 > xMart) xMart=$7
  93.   if ($9 > xMgr) xMgr=$9
  94.   if ($11 > xMsec) xMsec=$11
  95.   if ($11 > 0) A=$7 / $11; else A=$7
  96.   if (A > xMps) xMps=A
  97.   next
  98. }
  99. END{
  100.   if (day == "0") { print "Z"; exit }
  101.   print "d " date
  102.   if (l && (run > 0 || xrun > 0)) {
  103.     print "h"
  104.     printf "c" f,run,art,Mart,gr,Mgr,sec,Msec
  105.     printf "e" f,xrun,xart,xMart,xgr,xMgr,xsec,xMsec
  106.   }
  107.   if (t) {
  108.     print "H"
  109.     printf "C %d %d %d %d\n",Trun,Tart,Tsec,Mps
  110.     printf "E %d %d %d %d\n",xTrun,xTart,xTsec,xMps
  111.   }
  112. }' |
  113. if $debug ; then
  114.   cat
  115. else
  116. ${AWK} 'BEGIN{
  117.  first=""
  118. }
  119. /^d/{
  120.  last=$2 " " $3
  121.  if (first == "") first=last
  122.  next
  123. }
  124. /^h/{
  125.  printf "\nStatistics for %s\n", last
  126.  next
  127. }
  128. /^H/{
  129.  tostr=""
  130.  if (first != last) tostr=" to " last
  131.  printf "\nSummary for %s%s:\n", first, tostr
  132.  next
  133. }
  134. /^[cC]/{tp="Collection"}
  135. /^[eE]/{tp="Expiration"}
  136. /^[ce]/{
  137.  if ($2 == 0) next
  138.  printf "\n  %s runs: %d\n", tp, $2
  139.  printf "%10d articles, average of %5d per run, maximum %6d\n", $3, $3/$2, $4
  140.  printf "%10d groups,   average of %5d per run, maximum %6d\n", $5, $5/$2, $6
  141.  printf "%10d seconds,  average of %5d per run, maximum %6d\n", $7, $7/$2, $8
  142.  next
  143. }
  144. /^[CE]/{
  145.  printf "\n  %s runs: %d\n", tp, $2
  146.  if ($2 == 0) next
  147.  printf "%10d articles, average of %5d per run\n", $3, $3/$2
  148.  printf "%10d seconds,  average of %5d per run\n", $4, $4/$2
  149.  if ($4>0) avg=$3/$4; else avg=$3
  150.  printf "    average of %d articles per second, maximum %d\n", avg, $5
  151. }
  152. /^Z/{
  153.  printf "Log is empty\n"
  154. }'
  155. fi
  156.  
  157.