home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / callstats < prev    next >
Text File  |  2020-01-01  |  5KB  |  120 lines

  1. #!/usr/local/bin/kermit +
  2. #
  3. # c a l l s t a t s
  4. #
  5. # Modem call statistics script.  Works in UNIX, Windows, VMS, etc, with 
  6. # minor adjustments.  Collects data on modem pool answer/busy performance.
  7. # F. da Cruz, Columbia University, April 2000
  8. #
  9. # Dials one, two, or more different modem pools repeatedly and logs results
  10. # of each call to a file, one record per call.  Numbers are dialed randomly
  11. # with a distribution based on how many modems are in each pool.  Each phone
  12. # number is assumed to reach a separate modem pool with no overlap or hunting
  13. # between pools.
  14. #
  15. # Runs forever, with a chance to exit after each call by pressing a key.
  16. #
  17. # Log file format:
  18. #
  19. # yyyymmdd hh:mm:ss x phonenum ds Dialresult (Modem message)
  20. # 20000404 10:26:37 2 519-3900  0 CONNECT 50000 V42bis
  21. # 20000404 10:28:53 2 519-3900 22 BUSY
  22. #
  23. # x  = numeric day of week (0 = Sunday)
  24. # ds = Dial status code (usually 0 = CONNECT, 22 = BUSY)
  25. #
  26. # These can be fed into a statistical package like SAS or SPSS to provide
  27. # modem availability statistics per pool or aggregate by time of day and/or
  28. # day of week.
  29.  
  30. define badversion echo C-Kermit 7.0 or K95 1.1.19 required, exit 1
  31. if LLT \v(version) 70000 badversion
  32.  
  33. # &n and &p are parallel arrays and should be initialized with the phone
  34. # numbers and corresponding number of modems, as many pairs as you like.
  35. # Lines marked (*) should be adjusted for your calling platform.
  36.  
  37. .logfile = C:/K95/TMP/CALLS.LOG          ; (*) Logfile name
  38. set modem type usrobotics                ; (*) Change as needed
  39. set port 1                               ; (*) Change as needed
  40. if fail stop 1 {Device not available}
  41. set speed 57600                          ; (*) Set the desired speed
  42. set flow rts/cts                         ; (*) and flow control
  43.  
  44. # The next two lines define the phone numbers and pool size for each.
  45.  
  46. dcl \&n[] = 555-1234 555-4321            ; (*) Replace by real phone numbers
  47. dcl \&p[] =   184      460               ; (*) How many modems in each pool
  48.  
  49. # No changes needed from here down.
  50.  
  51. .\%n := \fdim(&n)                        ; Number of phone numbers
  52. if ( != \%n \fdim(&p) ) stop 1 Arrays not parallel
  53.  
  54. dcl \&r[\%n]                             ; Phone-number ranges (histogram)
  55. .\&r[0] = 0                              ; Fill in the ranges...
  56. for ( \%i 1 \%n 1 ) {
  57.     .\&r[\%i] ::= \&r[\%i-1] + \&p[\%i]
  58. }
  59. .\%t := \&r[\%n]                         ; \%t = total number of modems
  60. .\%m = 0                                 ; \%m = total calls
  61. .\%a = 0                                 ; \%a = total answers
  62.  
  63. set dial retries 0                       ; No redialing
  64. set dial speed-matching off              ; No speed changing
  65. set exit warning off                     ; In case of misconfigured modem
  66. set bell off                             ; Silence please
  67. set modem speaker off
  68. set dial display off                     ; Minimal screen display
  69. set quiet on
  70. set dial hangup off                      ; Hang up after rather than before
  71. set modem hangup rs232                   ; Fast hangup method
  72. hangup                                   ; Hang up before starting
  73.  
  74. ; After each call we save the dial status, then hang up immediately
  75. ; (so as not to keep the line open, which could prevent real callers from
  76. ; getting in).  The saved dial status is because the HANGUP command sets
  77. ; the dialstatus variable too.  Then we append a record to the log, and
  78. ; then wait 2 minutes before dialing again (if we didn't wait, then BUSYs
  79. ; might be overrepresented since they happen faster than CONNECTs).
  80.  
  81. set command interruption off             ; Require graceful exit
  82.  
  83. while true {                             ; Loop forever
  84.     .\%x := \frandom(\%t)                ; Pick number to dial at random
  85.     for ( \%i 1 \%n 1 ) {                ; but weighted by size of each pool
  86.         if ( <= \%x \&r[\%i] ) break
  87.     }
  88.     increment \%m                        ; Count the call
  89.     clear dial-status
  90.     xecho \flpad(\%m,6): \&n[\%i]...
  91.     dial \&n[\%i]
  92.     .callstatus := \v(dialstatus)        ; Save DIAL status
  93.     hangup                               ; Hang up immediately
  94.     fopen /append \%c \m(logfile)        ; Write log record
  95.     if fail stop 1 LOG OPEN ERROR: \f_errmsg()
  96.     fwrite /line \%c -
  97. \v(ndate) \v(time) \v(nday) \&n[\%i] \flpad(\m(callstatus),2) \v(dialresult)
  98.     if fail stop 1 LOG WRITE ERROR: \f_errmsg()
  99.     fclose \%c
  100.     if fail stop 1 LOG CLOSE ERROR: \f_errmsg()
  101.     clear device
  102.     if ( = \m(callstatus) 0 ) {          ; If call anwered
  103.         increment \%a                    ; count it.
  104.     }
  105.     echo \v(dialresult)
  106.     set ask-timer 120                    ; Wait two minutes
  107.     getc \%u {>>> Press a key to quit: } ; Let user break the loop
  108.     set ask-timer 0    
  109.     if not asktimeout break
  110.     echo
  111. }
  112. echo                                     ; Loop broken
  113. echo Stopping.                           ; Print summary
  114. close                                    ; Close and release dialout device
  115. echo Calls:   \flpad(\%m,5)
  116. echo Answers: \flpad(\%a,5)
  117. echo
  118. end 0
  119.