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

  1. #!/usr/local/bin/wermit +
  2.  
  3. ; m p s e r v e r s  --  Census of modem-pool servers.
  4.  
  5. ; Reports number of ports defined, in use, and free on a terminal-server
  6. ; based modem-pool farm.  Summarizes by server and by phone number.
  7. ; Assumes one phone number per server, but allows many servers per phone
  8. ; number.  Assumes servers respond to "finger" request with a list of
  9. ; active sessions.  Results are written to stdout.
  10. ;
  11. ; Illustrates:
  12. ;  . Another tool for modem-pool management.
  13. ;  . Associative arrays.
  14. ;  . Reading output from external commands.
  15. ;
  16. ; Requires C-Kermit 7.1 on a UNIX host.
  17. ;
  18. ; Author: F. da Cruz, Columbia University, Apr 2001.
  19.  
  20. ; Parallel arrays of server hostnames, port counts, and phone numbers.
  21. ; For example, the server called abcts1 has 92 ports and is on the
  22. ; 5551234 hunt group.
  23. ;
  24. ; CHANGE THESE DEFINITIONS FOR YOUR OWN INSTALLATION.
  25. ;
  26. dcl \&s[] = abcts1  abcts2  xyzts1  xyzts2  xyzts3  xyzts4  xyzts5  xyzts6
  27. dcl \&n[] = 92      92      92      92      92      184     46      92
  28. dcl \&t[] = 5551234 5551234 5554321 5554321 5554321 5554321 5554321 5559999
  29.  
  30. define badversion echo C-Kermit 7.1 required, exit 1
  31. if LLT \v(version) 701199 badversion
  32.  
  33. .n := \fdim(&n)                     ; Number of servers
  34. .myname := \&_[0]                   ; Pathname of this script
  35.  
  36. def RECORD {                        ; Write a record
  37.     local s
  38.     .s := \v(ndate) \v(time)  \%1
  39.     echo {\m(s)}
  40. }
  41. .ports := 0                         ; Get total port count
  42. for \i 1 n 1 {
  43.     incr ports \&n[i]
  44.     _incr xn<\&t[i]> \&n[i]         ; And number of ports per phone number
  45. }
  46.  
  47. echo {-------}                      ; Write heading
  48. show mac ports
  49. echo date.... time....  server  ports busy free
  50. echo {-------}
  51.  
  52. .\%s = 0                            ; Clear counts
  53. for i 1 n 1 {
  54.     _def pn<\&t[i]> 0
  55. }
  56.  
  57. ; Send "finger" command to each server.
  58. ; Pipe results through "grep -c tty" to count number of active tty ports.
  59. ; Accumulate per-server and per-phone-number sums.
  60.  
  61. for i 1 n 1 {                       ; Loop for each server
  62.     .\%x := \fcommand(finger @\&s[i] | grep -c tty)
  63.     .\%y ::= \&n[i] - \%x
  64.     record {\frpad(\&s[i],7) \flpad(\&n[i],4) \flpad(\%x,4) \flpad(\%y,4)}
  65.     incr \%s \%x
  66.     _incr pn<\&t[i]> \%x
  67. }
  68.  
  69. .z := \faaconvert(pn,&a,&b)         ; Convert associative array
  70. for i 1 z 1 {                       ; Loop thru phone numbers
  71.     .\%x := \m(xn<\&a[i]>)          ; Number of ports for this number
  72.     .\%y ::=  \%x - \&b[i]          ; Number free
  73.     record {\&a[i] \flpad(\%x,4) \flpad(\&b[i],4) \flpad(\%y,4)}
  74. }
  75. .\%y ::= \m(ports) - \%s            ; Grand totals
  76.  
  77. record {TOTAL   \flpad(\m(ports),4) \flpad(\%s,4) \flpad(\%y,4)}
  78. exit 0
  79.