home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / maint / badexpiry < prev    next >
Text File  |  1994-11-27  |  1KB  |  57 lines

  1. #! /bin/sh
  2. # Reports groups with more than $1 articles, >90% of all articles, or
  3. # or >$2KB of articles with expiry dates more than 10 days after their
  4. # arrival dates.  Defaults 15 and 500.
  5. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  6. . ${NEWSCONFIG-/etc/news/bin/config}
  7.  
  8. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  9. umask $NEWSUMASK
  10.  
  11. case "$#" in
  12. 0)    minarts=15 ; minsize=500    ;;
  13. 2)    minarts=$1 ; minsize=$2        ;;
  14. *)    echo "Usage: $0 [minarts minsize]" >&2 ; exit 2    ;;
  15. esac
  16.  
  17. cd $NEWSARTS
  18. egrep -v '~-' $NEWSCTL/history |
  19.     awk -F'    ' 'NF > 2 {
  20.         n = split($2, f, "~")
  21.         if (f[2] != "-" && f[2]-f[1] > 864000) {
  22.             n = split($3, f, " ")
  23.             for (i = 1; i <= n; i++)
  24.                 print f[i]
  25.         }
  26.     }' | tr . / | xargs $NEWSBIN/sizeof -i | sed 's;/[^/]* ; ;' |
  27.     ( sort ; echo dummy ) |
  28.     awk '{
  29.         if ($1 != newsgroup) {
  30.             if (newsgroup != "")
  31.                 print newsgroup, n, size
  32.             n = 0
  33.             size = 0
  34.             newsgroup = $1
  35.         }
  36.         n++
  37.         size += $2
  38.     }' |
  39.     while read group narts size
  40.     do
  41.         npresent=`ls -f $group | egrep '^[0-9]+$' | wc -l`
  42.         echo $group $narts $npresent $size
  43.     done | tr / . |
  44.     awk '    { bad = "" }
  45.         $2 > '$minarts' {
  46.             bad = bad ", " $2 " articles"
  47.         }
  48.         $2 > 0.9*$3 {
  49.             bad = bad ", " $2 " out of " $3 " articles"
  50.         }
  51.         $4 > '$minsize'*1024 {
  52.             bad = bad ", " int(($4+512)/1024) "KB"
  53.         }
  54.         bad != "" {
  55.             print $1, "has", substr(bad, 3), "on long expiry"
  56.         }'
  57.