home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume2 / shstat / shstat.sh
Linux/UNIX/POSIX Shell Script  |  1991-08-07  |  2KB  |  67 lines

  1. #!/bin/sh
  2.  
  3. # @(#)@ show_status    1.9    show system activity
  4. # @(#)@ Copyright 1988 by Johan Vromans - Multihouse Research
  5. # Contributed to Public Domain by the Author, Feb 15, 1988
  6.  
  7. # This is a little shell script which repeatedly displays the current
  8. # system activity, filtering out unneeded entries.
  9. #
  10. # Display uses tty enhancements, if present.
  11. #
  12. # Usage: show_status [ sleep-value ]
  13.  
  14. title="Multihouse USENET Gateway"    # descriptive title of this system
  15.  
  16. trap "rm -f /tmp/tmpa$$; trap '' 0; exit" 0 1 2 3 15
  17.  
  18. # get display interval
  19. sleep="$1"
  20. if [ "$sleep" = "" ]
  21. then
  22.     sleep=20
  23. fi
  24.  
  25. # get terminal enhancements
  26. home=`tput home`
  27. home=${home:-`tput khome`}
  28. home=${home:-`tput clear`}
  29. clear=`tput ed`
  30. cln=`tput el`
  31. so=`tput smso`
  32. se=`tput rmso`
  33.  
  34. # please keep the next line intact
  35. echo "$home`tput clear`show_status version 1.9 - Multihouse Research"
  36.  
  37. # build top display line
  38. line=`ps -f | line | sed \
  39.     -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" \
  40.     -e "s/^\(.....................\).../\1/"`
  41. line="$so$line    $se"
  42.  
  43. # other relevant data
  44. pid=$$
  45. set `uname -a`    # KEEP LAST - SCRIPT USES $1, $2 and so on ...
  46.  
  47. # and here we go ... until interrupted
  48. while [ a = a ]
  49. do
  50.     echo "$home$so $2   $1/$3   `date`    $title $se$cln\n"
  51.     # don't use a pipe - unwanted processes show up!
  52.     ps -ef > /tmp/tmpa$$
  53.     echo "$line"
  54.     sort +1n -2 < /tmp/tmpa$$ | sed        \
  55.         -e "/ -sh/d"            \
  56.         -e "/ -csh/d"            \
  57.         -e "/ -ksh/d"            \
  58.         -e "1d"                \
  59.         -e "/ $pid /d"            \
  60.         -e "\./etc/getty.d"        \
  61.         -e "s/^\(.....................\).../\1/"    \
  62.         -e "s/\$/$cln/"
  63.     echo "$clear\c"
  64.  
  65.     sleep $sleep
  66. done
  67.