#!/bin/sh # MetaCard 2.1 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" ñtop `wBlackÀÀÀÀÀÀffffffÿÿÿwhite€€€€€€©©© darkgray€(˜¢EditStack Properties... YDRXRYRWW UCourierê P local lasttimes, timerid function readfile which local nulloffset open file which for read if the result is not empty then return empty # file wasn't there! read from file which until empty close file which # find any 0 bytes and convert them to spaces put offset(numToChar(0), it) into nulloffset repeat until nulloffset is 0 put space into char nulloffset of it put offset(numToChar(0), it) into nulloffset end repeat return it end readfile on updatelist local procstat, newtotaltime, totaltime, procs, procid, procpath local newtime, percenttime, toplist set the cursor to watch put readfile("/proc/stat") into procstat put word 2 of procstat + word 3 of procstat + word 4 of procstat\ + word 5 of procstat into newtotaltime put max(1, newtotaltime - lasttimes["total"]) into totaltime put newtotaltime into lasttimes["total"] put shell("ls -l /proc") into procs delete line 1 of procs # delete "total" line repeat for each line l in procs put the last word of l into procid if procid is not a number then next repeat put "/proc/" & procid & "/" into procpath put readfile(procpath & "stat") into procstat if procstat is empty then next repeat put word 14 of procstat + word 15 of procstat into newtime put (newtime - lasttimes[procid]) / totaltime * 100 into percenttime put newtime into lasttimes[procid] put format("%5s %-10s %5d %5d %4d %s\n", word 1 of procstat, word 3 of l,\ word 23 of procstat div 1024, word 24 of procstat * 4, percenttime,\ readfile(procpath & "cmdline")) after toplist end repeat delete last char of toplist # get rid of trailing newline sort lines of toplist numeric by word 4 of each sort lines of toplist descending numeric by word 5 of each put toplist into field "toplist" send "updatelist" to me in (the updateinterval of me) seconds put the result into timerid set the cursor to hand disable button "Kill Process" end updatelist on resizeStack set the height of field "toplist" to the height of this card - 80 repeat with i = 1 to the number of buttons set the bottom of button i to the height of this card - 8 end repeat end resizeStack on openStack updatelist end openStack on closeStack cancel timerid end closeStack on iconifyStack cancel timerid end iconifyStack on unIconifyStack updatelist end unIconifyStack on mouseUp switch the short name of the target case "Kill Process" kill process word 1 of the selectedText of field "toplist" updatelist break case "Set Update Interval..." ask "Set update interval to:" with the updateinterval of me if it is not a number then answer "Update interval must be a number." else set the updateinterval of me to it cancel timerId updatelist end if break case "Close" close this stack break case "toplist" enable button "Kill Process" cancel timerId send "updatelist" to me in 5 seconds put the result into timerid break end switch end mouseUp €¢updateinterval5ìîïðñ ìtoplist·)h$R %18639 raney 4208 5720 8 mc % 226 minshe 7449 8708 0 mc -10295 raney 3015163 8064 0 netscape . 4594 raney 4579 5708 0 mc ./KeyGen ( 507 raney 3705 5604 0 emacs ( 566 raney 1636 3452 0 emacs '17376 raney 1361 2356 0 pine 0 263 root 366 1844 0 xterm -n pine ( 503 root 366 1784 0 xterm ( 5857 root 278 1748 0 xterm ( 96 root 790 1140 0 named ' 5859 root 152 696 0 bash ' 504 raney 148 696 0 bash ( 5251 raney 143 640 0 -bash &16429 minshe 161 636 0 elm ' 264 raney 141 568 0 bash ( 428 nobody 160 564 0 httpd ( 155 nobody 168 536 0 httpd ( 293 nobody 168 508 0 httpd ' 5858 raney 141 500 0 bash ( 175 root 145 488 0 -bash 8 163 root 212 484 0 cfs -cf /etc/cfs.conf ( 238 minshe 137 480 0 -bash ( 212 minshe 139 480 0 -bash ( 156 nobody 168 476 0 httpd ( 2717 nobody 160 468 0 httpd ( 193 root 153 424 0 -bash M 134 root 139 420 0 sendmail: accepting connections on port 25 - 5250 root 70 328 0 in.telnetd ( 146 root 147 324 0 httpd ,18633 root 33 300 0 sleep 300 - 237 root 70 276 0 in.telnetd - 211 root 70 196 0 in.telnetd * 46 root 73 192 0 syslogd ( 55 root 52 140 0 klogd = 1 root 39 132 0 init [3] 3 182 root 35 124 0 update (bdflush) < 179 root 76 120 0 /sbin/getty tty5 VC linux < 177 root 76 120 0 /sbin/getty tty3 VC linux ( 66 root 62 112 0 crond < 176 root 76 88 0 /sbin/getty tty2 VC linux # 181 root 35 76 0 + 117 root 99 72 0 rpc.nfsd - 108 root 86 72 0 rpc.mountd < 180 root 76 32 0 /sbin/getty tty6 VC linux < 178 root 76 32 0 /sbin/getty tty4 VC linux # 87 root 58 0 0 # 78 bin 68 0 0 #14277 root 60 0 0 í `ø$R î H / PID USER SIZE RSS %CPU Process NameïCloseàE«`¤~< ð Kill ProcessàE»`4~h ñSet Update Interval...àE«`Ð~