home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / wCNews_1.0.30.lha / bin / newsdaily < prev    next >
Encoding:
AmigaDOS Script File  |  1994-01-04  |  11.2 KB  |  234 lines

  1. .key dummy
  2. .bra [
  3. .ket ]
  4. ;/* uucp:c/newsdaily, (c) Wed, 12 May 1993 03:59:30 +0200 by "Kai 'wusel' Siering" <wusel@hactar.hanse.de> */
  5.  
  6. set [$$]USERNAME `findconfig USERNAME`
  7. set [$$]NODENAME `findconfig NODENAME DOMAINNAME`
  8. set [$$]NEWSMASTER `findconfig NEWSMASTER`
  9. set [$$]HOSTNAME $HOSTNAME
  10.  
  11. if $[$$]NEWSMASTER eq NEWSMASTER
  12.    set [$$]NEWSMASTER $[$$]USERNAME
  13. endif
  14.  
  15. if $[$$]HOSTNAME eq *$HOSTNAME
  16.    set [$$]HOSTNAME `findconfig NODENAME`
  17. endif
  18.  
  19. set [$$]DATE `rx "say date('n', date('i')-1)"`
  20.  
  21. ; since gsort tends to fail with `gsort: virtual memory exhausted' on low
  22. ; memory situations with an exit code of 2 (yet another UNIX port ...),
  23. ; try to run gsort before actually doing anything else. Send mail to
  24. ; newsmaster in case of failure.
  25.  
  26. set [$$]pwd `cd`
  27. cd sys:tmp  ; for the sake of gsort which uses `/tmp/filename' =:-<
  28. gsort <uulib:news/log >nil:
  29. if $RC not eq 0 val
  30.    echo  >t:newsdaily[$$].newsdaily.mail "From: newsdaily@$[$$]NODENAME ($[$$]HOSTNAME's USENET Daemon)"
  31.    echo >>t:newsdaily[$$].newsdaily.mail "To: $[$$]NEWSMASTER"
  32.    echo >>t:newsdaily[$$].newsdaily.mail "Subject: Unable to compute daily USENET status report ($[$$]DATE) for $[$$]HOSTNAME*N"
  33.    echo >>t:newsdaily[$$].newsdaily.mail "Possible Reason: `gsort' ran out of memory.*N"
  34.    avail >>t:newsdaily[$$].newsdaily.mail
  35.    skip goodbye
  36. endif
  37.  
  38. if not exists uulib:news/log
  39.    echo  >t:newsdaily[$$].newsdaily.mail "From: newsdaily@$[$$]NODENAME ($[$$]HOSTNAME's USENET Daemon)"
  40.    echo >>t:newsdaily[$$].newsdaily.mail "To: $[$$]NEWSMASTER"
  41.    echo >>t:newsdaily[$$].newsdaily.mail "Subject: Daily USENET status report ($[$$]DATE) for $[$$]HOSTNAME*N"
  42.    echo >>t:newsdaily[$$].newsdaily.mail "There are no recordings of any news that may have arrived. This may be due*Nto some problems, you'd better check the system ...*N"
  43.    list uunews:in.coming >>t:newsdaily[$$].newsdaily.mail
  44.    skip goodbye
  45. endif
  46.  
  47. failat 21
  48. delete uulib:news/log.ooo >nil:
  49. rename uulib:news/log.oo     uulib:news/log.ooo >nil:
  50. rename uulib:news/log.o      uulib:news/log.oo  >nil:
  51. delete uulib:news/errlog.ooo >nil:
  52. rename uulib:news/errlog.oo  uulib:news/errlog.ooo >nil:
  53. rename uulib:news/errlog.o   uulib:news/errlog.oo  >nil:
  54. delete uulib:news/expire.log.ooo >nil:
  55. rename uulib:news/expire.log.oo  uulib:news/expire.log.ooo >nil:
  56. rename uulib:news/expire.log.o   uulib:news/expire.log.oo  >nil:
  57. rename uulib:news/expire.log     uulib:news/expire.log.o   >nil:
  58. delete uulib:news/batchlog.ooo >nil:
  59. rename uulib:news/batchlog.oo  uulib:news/batchlog.ooo     >nil:
  60. rename uulib:news/batchlog.o   uulib:news/batchlog.oo      >nil:
  61. rename uulib:news/batchlog     uulib:news/batchlog.o       >nil:
  62. failat 10
  63.  
  64. rename uulib:news/log        uulib:news/log.o
  65. if not exists uulib:news/errlog
  66.    echo "" >>uulib:news/errlog noline
  67. else
  68.    rename uulib:news/errlog     uulib:news/errlog.o
  69. endif
  70.  
  71. ; junked groups (names)
  72. grep 'junked ' uulib:news/log.o >t:newsdaily[$$].junked
  73. echo "{*N   printf(*"%s\n*", *$11);*N}" >t:newsdaily[$$].junked.awk
  74. echo "s/`//g*Ns/'//g*Ns/,/*N/g" >t:newsdaily[$$].junked.sed
  75. gawk -f t:newsdaily[$$].junked.awk <t:newsdaily[$$].junked >t:newsdaily[$$].junked2
  76. sed -f t:newsdaily[$$].junked.sed <t:newsdaily[$$].junked2 >t:newsdaily[$$].junked3
  77. gsort <t:newsdaily[$$].junked3 >t:newsdaily[$$].junked4
  78. uniq -c <t:newsdaily[$$].junked4 >t:newsdaily[$$].junked5
  79. gsort -nr +1 <t:newsdaily[$$].junked5 >t:newsdaily[$$].junked6
  80.  
  81. ;
  82. ; If you want to create groups of several hierarchies automatically if
  83. ; articles arrive there, you might want to utilize the following:
  84. ;
  85. ;echo "{*N   if(substr($2, 0, 4)==*"zer.*" || substr($2, 0, 5)==*"fras.*" || substr($2, 0, 4)==*"bln.*" || substr($2, 0, 5)==*"saar.*" || substr($2, 0, 5)==*"hanse*")" >t:newsdaily[$$].junked.awk
  86. ;echo "      printf(*"do.newgroup %s $[$$]HOSTNAME.config \*"created by newsdaily, check status!\*"\n*", *$2);*N}" >>t:newsdaily[$$].junked.awk
  87. ;gawk -f t:newsdaily[$$].junked.awk <t:newsdaily[$$].junked6 >t:newsdaily[$$].newgroupmsgs
  88. ;execute t:newsdaily[$$].newgroupmsgs
  89.  
  90. ; junked articles (number/site)
  91. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].junked.awk
  92. gawk -f t:newsdaily[$$].junked.awk <t:newsdaily[$$].junked >t:newsdaily[$$].junked2
  93. gsort <t:newsdaily[$$].junked2 >t:newsdaily[$$].junked3
  94. uniq -c <t:newsdaily[$$].junked3 >t:newsdaily[$$].junked4
  95. gsort -nr +1 <t:newsdaily[$$].junked4 >t:newsdaily[$$].junked5
  96.  
  97. ; accepted artices
  98. grep ' + ' uulib:news/log.o >t:newsdaily[$$].received
  99. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].received.awk
  100. gawk -f t:newsdaily[$$].received.awk <t:newsdaily[$$].received >t:newsdaily[$$].received2
  101. gsort <t:newsdaily[$$].received2 >t:newsdaily[$$].received3
  102. uniq -c <t:newsdaily[$$].received3 >t:newsdaily[$$].received4
  103. gsort -nr +1 <t:newsdaily[$$].received4 >t:newsdaily[$$].received5
  104.  
  105. ; duplicate articles
  106. grep 'duplicate' uulib:news/log.o >t:newsdaily[$$].duplicates
  107. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].duplicates.awk
  108. gawk -f t:newsdaily[$$].duplicates.awk <t:newsdaily[$$].duplicates >t:newsdaily[$$].duplicates2
  109. gsort <t:newsdaily[$$].duplicates2 >t:newsdaily[$$].duplicates3
  110. uniq -c <t:newsdaily[$$].duplicates3 >t:newsdaily[$$].duplicates4
  111. gsort -nr +1 <t:newsdaily[$$].duplicates4 >t:newsdaily[$$].duplicates5
  112.  
  113. ; short articles
  114. grep 'short by' uulib:news/log.o >t:newsdaily[$$].shortarts
  115. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].shortarts.awk
  116. gawk -f t:newsdaily[$$].shortarts.awk <t:newsdaily[$$].shortarts >t:newsdaily[$$].shortarts2
  117. gsort <t:newsdaily[$$].shortarts2 >t:newsdaily[$$].shortarts3
  118. uniq -c <t:newsdaily[$$].shortarts3 >t:newsdaily[$$].shortarts4
  119. gsort -nr +1 <t:newsdaily[$$].shortarts4 >t:newsdaily[$$].shortarts5
  120.  
  121. ; bad dates
  122. grep 'Date:' uulib:news/log.o >t:newsdaily[$$].baddates
  123. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].baddates.awk
  124. gawk -f t:newsdaily[$$].baddates.awk <t:newsdaily[$$].baddates >t:newsdaily[$$].baddates2
  125. gsort <t:newsdaily[$$].baddates2 >t:newsdaily[$$].baddates3
  126. uniq -c <t:newsdaily[$$].baddates3 >t:newsdaily[$$].baddates4
  127. gsort -nr +1 <t:newsdaily[$$].baddates4 >t:newsdaily[$$].baddates5
  128.  
  129. ; non conforming articles
  130. grep ' - ' uulib:news/log.o >t:newsdaily[$$].illarts.o
  131. egrep -vi 'duplicate|junked|Date|short by' t:newsdaily[$$].illarts.o >t:newsdaily[$$].illarts
  132. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].illarts.awk
  133. gawk -f t:newsdaily[$$].illarts.awk <t:newsdaily[$$].illarts >t:newsdaily[$$].illarts2
  134. gsort <t:newsdaily[$$].illarts2 >t:newsdaily[$$].illarts3
  135. uniq -c <t:newsdaily[$$].illarts3 >t:newsdaily[$$].illarts4
  136. gsort -nr +1 <t:newsdaily[$$].illarts4 >t:newsdaily[$$].illarts5
  137.  
  138. ; unapproved postings
  139. grep 'unapproved' uulib:news/log.o >t:newsdaily[$$].unapproved
  140. echo "{*N   printf(*"%s\n*", *$4);*N}" >t:newsdaily[$$].unapproved.awk
  141. gawk -f t:newsdaily[$$].unapproved.awk <t:newsdaily[$$].unapproved >t:newsdaily[$$].unapproved2
  142. gsort <t:newsdaily[$$].unapproved2 >t:newsdaily[$$].unapproved3
  143. uniq -c <t:newsdaily[$$].unapproved3 >t:newsdaily[$$].unapproved4
  144. gsort -nr +1 <t:newsdaily[$$].unapproved4 >t:newsdaily[$$].unapproved5
  145.  
  146. ; join the above for a total number of problems
  147. ;
  148. ; Due to a BUG in c:join (37.1), I've to use type instead =:-<
  149. ;                     - wusel, Thu, 13 May 1993 03:17:31 +0200
  150. ;
  151. ;join t:newsdaily[$$].shortarts2 t:newsdaily[$$].baddates2 t:newsdaily[$$].illarts2 t:newsdaily[$$].unapproved2 as t:newsdaily[$$].miscproblems2
  152. type t:newsdaily[$$].shortarts2 t:newsdaily[$$].baddates2 t:newsdaily[$$].illarts2 t:newsdaily[$$].unapproved2 >t:newsdaily[$$].miscproblems2
  153. gsort <t:newsdaily[$$].miscproblems2 >t:newsdaily[$$].miscproblems3
  154. uniq -c <t:newsdaily[$$].miscproblems3 >t:newsdaily[$$].miscproblems4
  155. gsort -nr +1 <t:newsdaily[$$].miscproblems4 >t:newsdaily[$$].miscproblems5
  156.  
  157. echo  >t:newsdaily[$$].newsdaily.mail "From: newsdaily@$[$$]NODENAME ($[$$]HOSTNAME's USENET Daemon)"
  158. echo >>t:newsdaily[$$].newsdaily.mail "To: $[$$]NEWSMASTER"
  159. echo >>t:newsdaily[$$].newsdaily.mail "Subject: Daily USENET status report ($[$$]DATE) for $[$$]HOSTNAME"
  160. set [$$]LINES `lines t:newsdaily[$$].junked6`
  161. if $[$$]LINES ge 1 val
  162.    echo >>t:newsdaily[$$].newsdaily.mail "*NUnknown newsgroups (by number of articles):*N-------------------------------------------"
  163.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].junked6
  164. endif
  165. set [$$]LINES `lines t:newsdaily[$$].junked5`
  166. if $[$$]LINES ge 1 val
  167.    echo >>t:newsdaily[$$].newsdaily.mail "*NUnknown newsgroups (by sites sending them):*N-------------------------------------------"
  168.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].junked5
  169. endif
  170. set [$$]LINES `lines t:newsdaily[$$].duplicates5`
  171. if $[$$]LINES ge 1 val
  172.    echo >>t:newsdaily[$$].newsdaily.mail "*NDuplicate articles (by system):*N-------------------------------"
  173.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].duplicates5
  174. endif
  175. set [$$]LINES `lines t:newsdaily[$$].miscproblems5`
  176. if $[$$]LINES ge 1 val
  177.    echo >>t:newsdaily[$$].newsdaily.mail "*NDropped articles for misc. reasons (by system):*N-----------------------------------------------"
  178.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].miscproblems5
  179.    echo >>t:newsdaily[$$].newsdaily.mail "*NDropped articles (by reason):*N-----------------------------"
  180.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].shortarts
  181.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].baddates
  182.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].illarts
  183.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].unapproved
  184. endif
  185. set [$$]LINES `lines t:newsdaily[$$].received5`
  186. if $[$$]LINES ge 1 val
  187.    echo >>t:newsdaily[$$].newsdaily.mail "*NNumber of articles accepted (by system):*N----------------------------------------"
  188.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].received5
  189. endif
  190. if exists uulib:news/errlog.o
  191.    set [$$]LINES `lines uulib:news/errlog.o`
  192.    if $[$$]LINES ge 1 val
  193.       echo >>t:newsdaily[$$].newsdaily.mail "*NContents of errlog:*N-------------------"
  194.       type >>t:newsdaily[$$].newsdaily.mail uulib:news/errlog.o
  195.       echo >>t:newsdaily[$$].newsdaily.mail "-------------------"
  196.    endif
  197. endif
  198. if exists uulib:news/batchlog.o
  199.    set [$$]LINES `lines uulib:news/batchlog.o`
  200.    if $[$$]LINES ge 1 val
  201.       echo >>t:newsdaily[$$].newsdaily.mail "*NContents of batchlog:*N-----------------------"
  202.       type >>t:newsdaily[$$].newsdaily.mail uulib:news/batchlog.o
  203.       echo >>t:newsdaily[$$].newsdaily.mail "-----------------------"
  204.    endif
  205. endif
  206. if exists uulib:news/expire.log.o
  207.    set [$$]LINES `lines uulib:news/expire.log.o`
  208.    if $[$$]LINES ge 1 val
  209.       echo >>t:newsdaily[$$].newsdaily.mail "*NContents of expire.log:*N-----------------------"
  210.       type >>t:newsdaily[$$].newsdaily.mail uulib:news/expire.log.o
  211.       echo >>t:newsdaily[$$].newsdaily.mail "-----------------------"
  212.    endif
  213. endif
  214. list uunews:in.coming/bad >t:newsdaily[$$].badincomingjobs dates lformat "%-30n %8l %t %d"
  215. set [$$]LINES `lines t:newsdaily[$$].badincomingjobs`
  216. if $[$$]LINES ge 1 val
  217.    echo >>t:newsdaily[$$].newsdaily.mail "*NBad jobs in uunews:in.coming/bad:*N---------------------------------"
  218.    type >>t:newsdaily[$$].newsdaily.mail t:newsdaily[$$].badincomingjobs
  219.    echo >>t:newsdaily[$$].newsdaily.mail "--------------------------------"
  220. endif
  221.  
  222. lab goodbye
  223.  
  224. cd $[$$]pwd
  225. sendmail <t:newsdaily[$$].newsdaily.mail
  226. unset [$$]LINES
  227. unset [$$]USERNAME
  228. unset [$$]NODENAME
  229. unset [$$]HOSTNAME
  230. unset [$$]NEWSMASTER
  231. unset [$$]DATE
  232. unset [$$]pwd
  233. delete t:newsdaily[$$].#? quiet
  234.