home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / sources / 3094 < prev    next >
Encoding:
Text File  |  1993-01-25  |  3.2 KB  |  84 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!urmel.informatik.rwth-aachen.de!uni-paderborn.de!pbhrzx.uni-paderborn.de!q77755
  2. From: q77755@pbhrzx.uni-paderborn.de (Marcus Hampel 'alias Zenith')
  3. Newsgroups: alt.sources
  4. Subject: cfree - look for free console (sh script)
  5. Date: 25 Jan 93 11:19:13 GMT
  6. Organization: Uni Paderborn FB 17 Informatik GERMANY
  7. Lines: 72
  8. Message-ID: <q77755.727960753@pbhrzx.uni-paderborn.de>
  9. NNTP-Posting-Host: pbhrzx.uni-paderborn.de
  10. Keywords: cfree
  11.  
  12. Hello ...
  13.  
  14. I have written a small tool to look at multiple consols.
  15. If you use a multi processor system, look at the comments and use this
  16. feature (this is much faster).
  17.  
  18. So long ...
  19.  
  20. ---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---
  21. #!/bin/sh
  22. # cfree    -    Look for free machines        v1.0
  23. #        by Marcus Hampel (q77755@pbhrzx.uni-paderborn.de) Jan 1993
  24. #
  25. # usage: cfree <hostname> ...
  26.  
  27. myhosts=$@
  28.  
  29. ##############################################################################
  30. # To use screen attributes
  31. ##############################################################################
  32. #invers=`tput smso`
  33. #normal=`tput rmso` 
  34. inverse=""
  35. normal=""
  36.  
  37. ##############################################################################
  38. # For parallel "sh"
  39. ##############################################################################
  40. # PARALLEL=100
  41.  
  42. for host in $myhosts
  43. do
  44. ##############################################################################
  45. # The next line is for parallel "sh"
  46. ##############################################################################
  47. #  (
  48.   rup $host|sed 's/.*average: //g;s/,[ 0-9,.]*$//g' >/tmp/frei.rup.$host.$$ &
  49.   rusers -l $host|fgrep console >/tmp/frei.rusers.$host.$$ &
  50.   wait 
  51.   set `cat /tmp/frei.rusers.$host.$$` x
  52.   load=`cat /tmp/frei.rup.$host.$$`
  53.   rm -f /tmp/frei.*.$host.$$
  54.   if [ "$2" = "" ]
  55.   then
  56.     echo F $host $load &
  57.   else
  58.     echo B $host $load $1 &
  59.   fi
  60. ##############################################################################
  61. # The next line is for parallel "sh"
  62. ##############################################################################
  63. #  ) &
  64. done|
  65. awk '
  66.     BEGIN{print "+------------+----------------+--------------------------------------+-------+"
  67.       print "| Status:    | Host:          | Wer besetzt den Rechner:             | Load: |"
  68.       print "+------------+----------------+--------------------------------------+-------+"}
  69. $1 == "B"{frei=" Besetzt  "
  70.       wer=$4}
  71. $1 == "F"{frei=invers " Frei !!! " normal
  72.       wer="--------"}
  73.      {printf "| %s | %-14s | %-36s | %5s |\n",frei,$2,wer,$3}
  74.       END{print "+------------+----------------+--------------------------------------+-------+"}
  75.     ' normal="$normal" invers="$invers" -
  76. ---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---CUT---
  77. --
  78. | Marcus Hampel, E-Mail: q77755@pbhrzx.uni-paderborn.de, Zenith on IRC      |
  79. |                                                                           |
  80. | "Die Taste, die frueher "Control" hiess, wird nun "Strg" genannt, was     |
  81. | unweigerlich die Assoziation hervorruft, der Anwender werde mit dem       |
  82. | Tastaturkabel stranguliert, sobald er diese Teste betaetigt."             |
  83. | (DOS International , 7/90)                                                |
  84.