- The added line is THIS COLOR.
- The deleted line is THIS COLOR.
*** What is this? [#oe481973]
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 [#o750eabc]
BSD-Style License
*** Source & Binary [#yfe08456]
http://reddog.s35.xrea.com/software/process1.0.zip
*** Command [#k2d7e660]
ps ?options?
kill ?pid?
*** ps options [#cb116ea6]
- -exe ~
exefile name
- -path ~
exefile full path (long name)
- -ppid ~
parent process id
- -priority ~
priority base
- -thread ~
thread count
- -ctime ~
created datetime. If we cannot get it, it will be 0.
- -ktime ~
kernel time. If we cannot get it, it will be 0.
- -utime ~
user time. If we cannot get it, it will be 0.
- -%cpu ~
Percentage of CPU usage from created time to the present time. If we cannot get it, it will be {}.
- -%cpu msec ~
Percentage of CPU usage in milli seconds. If we cannot get it, it will be {}.
- -%size ~
Percentage of real memory (working set) used. If we cannot get it, it will be {}.
- -%vsize ~
Percentage of virtual memory (page file) used. If we cannot get it, it will be {}.
- -size ~
real memory size (byte)
- -peaksize ~
real memory peal size (byte)
- -vsize ~
virtual memory size (byte)
- -peakvsize~
virtual memory peak size (byte)
- -pagefault ~
pagefault count
- -user ~
account user name
- -domain ~
account domain name
- -version ~
exe version
*** Sample(How to use) [#f7a8886e]
*** Example1 [#ob241f99]
package require Process
# Show Process List
ps -exe -%cpu -%size
ps -exe -ppid
kill 1024
...
*** Example2 [#fa342965]
# Format Data
foreach d [ps -exe -%cpu -%size -size] {
foreach {pid name pcpu pmem mem} $d {
if {$pcpu eq {}} {set pcpu 0}
if {$pmem eq {}} {set pmem 0}
puts [format {%4d %-16s %6.1f%% %6.1f%% %10dKB} \
$pid $name $pcpu $pmem [expr $mem/1024]]
}
}
***Example3 [#z44d4c20]
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 eq {}} {
return {}
}
return "[format %3.2f $var] %"
}
proc formatSize {var} {
if {$var eq {}} {
return {}
}
return "[expr $var / 1024] KB"
}
#ref(process1.gif,nolink,left)
----
[[CategoryTclTk]] [[CategorySoft]]
[[Tclでプロセス管理]]
HTML convert time: 0.007 sec.