What is this?

This package provides commands for show/kill process on Windows2000/XP. ps command can get some details such as %cpu, PPID, exe file path, memory etc...

License

BSD-Style License

Source & Binary

http://reddog.s35.xrea.com/software/process1.0.zip

Command

ps ?options?
kill ?pid?

ps options

Example1

package require Process
# Show Process List
ps -exe -%cpu -%size
ps -exe -ppid
kill 1024
...

Example2

proc plist {} {
	puts [format {%4s %-8s  %6s  %6s   %5s %s} \
			PID USER %CPU %MEM SIZE CMD]
	foreach {pid user pcpu pmem mem exe} \
		[ps -user -%cpu -%size -size -exe -plainlist] {
		if {$pcpu < 0} {set pcpu 0}
		if {$pmem < 0} {set pmem 0}
		puts [format {%4d %-8s %6.1f%% %6.1f%% %5dKB %s} \
			$pid $user $pcpu $pmem [expr $mem/1024] $exe]
	}
}
plist
 PID USER        %CPU    %MEM    SIZE CMD
   0             0.0%    0.0%    -1KB [System Process]
   8             0.0%    0.0%   252KB System
 156 SYSTEM      0.0%    0.1%   436KB SMSS.EXE
 180             0.0%    0.0%    -1KB CSRSS.EXE
 176 SYSTEM      0.0%    0.7%  3728KB WINLOGON.EXE
 228 SYSTEM      0.0%    1.0%  5368KB SERVICES.EXE
 240 SYSTEM      0.0%    0.2%  1056KB LSASS.EXE
 420 SYSTEM      0.0%    0.5%  2600KB svchost.exe
 448 SYSTEM      0.0%    0.6%  3348KB spoolsv.exe
 484 SYSTEM      0.0%    1.0%  5360KB svchost.exe
 512 SYSTEM      0.0%    0.7%  3616KB mdm.exe
 624 SYSTEM      0.0%    0.6%  3064KB NAVAPSVC.EXE
 ...

Example3

package require tablelist
package require Process

set lvar {}

button .update -text Update -command {
	set lvar [ps -%cpu 500 -size -exe]
	catch {.table sortbycolumn [.table sortcolumn] -[.table sortorder]}
	update
}
scrollbar .y -command {.table yview}
tablelist::tablelist .table -listvariable lvar \
	-showarrow yes -yscrollcommand {.y set} \
	-labelcommand tablelist::sortByColumn \
	-columns {6 PID 10 %CPU 10 Memory 32 Name} -width 70
.table columnconfigure 0 -align right -sortmode integer
.table columnconfigure 1 -align right -sortmode real -formatcommand formatPer
.table columnconfigure 2 -align right -sortmode integer -formatcommand  formatSize
.table columnconfigure 3 -sortmode ascii

pack .update -side bottom -fill x
pack .table -side left -expand yes -fill both
pack .y -side right -fill y

proc formatPer {var} {
	if {$var < 0} {
		return {}
	}
	return "[format %3.2f $var] %"
}

proc formatSize {var} {
	if {$var < 0} {
		return {}
	}
	return "[expr $var / 1024] KB"
}
process1.gif

CategoryTclTk CategorySoft Tclでプロセス管理


Attach file: fileprocess1.gif 421 download [Information]

|New|Edit|Freeze|Diff|History|Attach|Copy|Rename|
Last-modified: 2012-04-22 (Sun) 21:58:42
HTML convert time: 0.009 sec.