First import
git-svn-id: http://photonzero.com/dotfiles/trunk@1 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
commit
83d40113d2
60 changed files with 4264 additions and 0 deletions
24
bin/ps_warriors
Executable file
24
bin/ps_warriors
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$cnt = ($ARGV[0] eq "-n" && $ARGV[1] =~ /^\d+$/) ? $ARGV[1] : 20;
|
||||
|
||||
opendir(PROC, "/proc");
|
||||
while ($_ = readdir(PROC)) {
|
||||
next if (/curproc/);
|
||||
$id = (stat("/proc/$_"))[4];
|
||||
next unless defined $id;
|
||||
$procs{$id}++;
|
||||
}
|
||||
closedir(PROC);
|
||||
|
||||
$procs{$<}--;
|
||||
@ids = reverse sort { $procs{$a} <=> $procs{$b} } keys(%procs);
|
||||
|
||||
format STDOUT =
|
||||
@>>> @<<<<<<<
|
||||
$procs{$id}, (getpwuid($id))[0]
|
||||
.
|
||||
|
||||
for $id (($cnt) ? @ids[0..($cnt-1)] : @ids) {
|
||||
write;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue