home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d992 / cyberpager.lha / CyberPager / rexx / caw / WatchForFailingSitesAndPage < prev   
Text File  |  1994-04-05  |  3KB  |  125 lines

  1. /*
  2.  * WatchForFailingSitesAndPage
  3.  *
  4.  * Copyright © 1993 by Christopher A. Wichura (caw@miroc.chi.il.us)
  5.  * All rights reserved.
  6.  *
  7.  * This script will monitor the UUSPOOL:LOGFILE generated by AmigaUUCP
  8.  * and keep track of how many times attempts to dial a site have failed.
  9.  * If the number of failed attempts exceeds the maximum set for the
  10.  * site (see configuration below) then a page will be spooled by
  11.  * shelling out to 'spoolpage'.
  12.  *
  13.  * This script should be started in a fashion similar to:
  14.  *
  15.  *    RunWSH >nil: watch UUSPOOL:LOGFILE | WatchForFailingSitesAndPage
  16.  * or
  17.  *    Run >nil: watch >"APIPE:rx WatchForFailingSitesAndPage" UUSPOOL:LOGFILE
  18.  */
  19.  
  20. /*
  21.  * This section contains configuration information for your particular
  22.  * site.  First you must supply the hostname of your machine.  Then,
  23.  * for each site that you dial, you must have an entry in the
  24.  * pageFailLevel and pageWho stems.  These tell this script a) how many
  25.  * failures may occur for the site before a page is to be generated,
  26.  * and b) who to send the page message to, respectively.
  27.  */
  28.  
  29. /* name of machine this script is running on */
  30. hostname = 'miroc.chi.il.us'
  31.  
  32. /* this indicates how often we should send a warning page out.  every
  33.    pageFailLevel. failures a page will be generated. */
  34.  
  35. pageFailLevel.clout = 3
  36. pageFailLevel.amiserv = 3
  37.  
  38. /* the pageWho stem tells this script who to send pages to when it wants to
  39.    send something out.  you can specifiy multiple targets by separating
  40.    then with spaces. */
  41.  
  42. pageWho.clout = 'caw'
  43. pageWho.amiserv = 'caw brianv'
  44.  
  45. /*
  46.  * No general user modifiable code is found below this point.
  47.  * Make changes here at your own risk.
  48.  */
  49.  
  50. do until eof(stdin)
  51.     line = readln(stdin)
  52.     call doLine(line)
  53. end
  54.  
  55. exit
  56.  
  57. /*
  58.  * The doLine procedure actually looks at the line read from the logfile
  59.  * and decides if anything needs to be done.
  60.  */
  61.  
  62. doLine: procedure expose hostname pageFailLevel. pageWho. siteFailCount.
  63.     parse arg . prog','machine','who message
  64.  
  65.     /*
  66.      * If the message wasn't generated by uucico then we can forget
  67.      * about it.
  68.      */
  69.  
  70.     if strip(prog) ~= 'uucico' then
  71.         return 0
  72.  
  73.     /*
  74.      * Get the variables we use into a clean state.
  75.      */
  76.  
  77.     machine = strip(machine)
  78.     machineUC = upper(machine)
  79.     who = strip(who)
  80.     message = strip(message)
  81.  
  82.     /*
  83.      * Look for SUCCEEDED call messages.  reset fail count when we
  84.      * see one.
  85.      */
  86.  
  87.     if left(message, 14) = 'SUCCEEDED call' then do
  88.         siteFailCount.machineUC = 0
  89.         return 0
  90.     end
  91.  
  92.     /*
  93.      * Look for FAILED call messages.  If found, update the fail
  94.      * count and send a page if needed.
  95.      */
  96.  
  97.     if left(message, 11) = 'FAILED call' then do
  98.         failCount = siteFailCount.machineUC
  99.         if ~datatype(failCount, 'N') then
  100.             failCount = 1
  101.         else
  102.             failCount = failCount + 1
  103.  
  104.         failLevel = pageFailLevel.machineUC
  105.  
  106.         if (failCount // failLevel) = 0 then do
  107.             msg = 'This page was generated automatically by'
  108.             msg = msg hostname ||'.  Attempts by uucico to dial'
  109.             msg = msg '`'machine'''' 'have failed' failCount
  110.             msg = msg 'consecutive times in a row.'
  111.  
  112.             address command 'spoolpage' pageWho.machineUC 'message' msg
  113.         end
  114.  
  115.         siteFailCount.machineUC = failCount
  116.         return 0
  117.     end
  118.  
  119.     /*
  120.      * Not a message we are interested in so ignore it.
  121.      */
  122.  
  123.     return 0
  124.  
  125.