home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/kermit +
- #
- # c a l l s t a t s
- #
- # Modem call statistics script. Works in UNIX, Windows, VMS, etc, with
- # minor adjustments. Collects data on modem pool answer/busy performance.
- #
- # F. da Cruz, Columbia University, April 2000
- #
- # Dials one, two, or more different modem pools repeatedly and logs results
- # of each call to a file, one record per call. Numbers are dialed randomly
- # with a distribution based on how many modems are in each pool. Each phone
- # number is assumed to reach a separate modem pool with no overlap or hunting
- # between pools.
- #
- # Runs forever, with a chance to exit after each call by pressing a key.
- #
- # Log file format:
- #
- # yyyymmdd hh:mm:ss x phonenum ds Dialresult (Modem message)
- # 20000404 10:26:37 2 519-3900 0 CONNECT 50000 V42bis
- # 20000404 10:28:53 2 519-3900 22 BUSY
- #
- # x = numeric day of week (0 = Sunday)
- # ds = Dial status code (usually 0 = CONNECT, 22 = BUSY)
- #
- # These can be fed into a statistical package like SAS or SPSS to provide
- # modem availability statistics per pool or aggregate by time of day and/or
- # day of week.
-
- define badversion echo C-Kermit 7.0 or K95 1.1.19 required, exit 1
- if LLT \v(version) 70000 badversion
-
- # &n and &p are parallel arrays and should be initialized with the phone
- # numbers and corresponding number of modems, as many pairs as you like.
- # Lines marked (*) should be adjusted for your calling platform.
-
- .logfile = C:/K95/TMP/CALLS.LOG ; (*) Logfile name
- set modem type usrobotics ; (*) Change as needed
- set port 1 ; (*) Change as needed
- if fail stop 1 {Device not available}
- set speed 57600 ; (*) Set the desired speed
- set flow rts/cts ; (*) and flow control
-
- # The next two lines define the phone numbers and pool size for each.
-
- dcl \&n[] = 555-1234 555-4321 ; (*) Replace by real phone numbers
- dcl \&p[] = 184 460 ; (*) How many modems in each pool
-
- # No changes needed from here down.
-
- .\%n := \fdim(&n) ; Number of phone numbers
- if ( != \%n \fdim(&p) ) stop 1 Arrays not parallel
-
- dcl \&r[\%n] ; Phone-number ranges (histogram)
- .\&r[0] = 0 ; Fill in the ranges...
- for ( \%i 1 \%n 1 ) {
- .\&r[\%i] ::= \&r[\%i-1] + \&p[\%i]
- }
- .\%t := \&r[\%n] ; \%t = total number of modems
- .\%m = 0 ; \%m = total calls
- .\%a = 0 ; \%a = total answers
-
- set dial retries 0 ; No redialing
- set dial speed-matching off ; No speed changing
- set exit warning off ; In case of misconfigured modem
- set bell off ; Silence please
- set modem speaker off
- set dial display off ; Minimal screen display
- set quiet on
- set dial hangup off ; Hang up after rather than before
- set modem hangup rs232 ; Fast hangup method
- hangup ; Hang up before starting
-
- ; After each call we save the dial status, then hang up immediately
- ; (so as not to keep the line open, which could prevent real callers from
- ; getting in). The saved dial status is because the HANGUP command sets
- ; the dialstatus variable too. Then we append a record to the log, and
- ; then wait 2 minutes before dialing again (if we didn't wait, then BUSYs
- ; might be overrepresented since they happen faster than CONNECTs).
-
- set command interruption off ; Require graceful exit
-
- while true { ; Loop forever
- .\%x := \frandom(\%t) ; Pick number to dial at random
- for ( \%i 1 \%n 1 ) { ; but weighted by size of each pool
- if ( <= \%x \&r[\%i] ) break
- }
- increment \%m ; Count the call
- clear dial-status
- xecho \flpad(\%m,6): \&n[\%i]...
- dial \&n[\%i]
- .callstatus := \v(dialstatus) ; Save DIAL status
- hangup ; Hang up immediately
- fopen /append \%c \m(logfile) ; Write log record
- if fail stop 1 LOG OPEN ERROR: \f_errmsg()
- fwrite /line \%c -
- \v(ndate) \v(time) \v(nday) \&n[\%i] \flpad(\m(callstatus),2) \v(dialresult)
- if fail stop 1 LOG WRITE ERROR: \f_errmsg()
- fclose \%c
- if fail stop 1 LOG CLOSE ERROR: \f_errmsg()
- clear device
- if ( = \m(callstatus) 0 ) { ; If call anwered
- increment \%a ; count it.
- }
- echo \v(dialresult)
- set ask-timer 120 ; Wait two minutes
- getc \%u {>>> Press a key to quit: } ; Let user break the loop
- set ask-timer 0
- if not asktimeout break
- echo
- }
- echo ; Loop broken
- echo Stopping. ; Print summary
- close ; Close and release dialout device
- echo Calls: \flpad(\%m,5)
- echo Answers: \flpad(\%a,5)
- echo
- end 0
-