examine specific field from /proc/*/stat
This commit is contained in:
parent
547a30b20b
commit
69b670a970
21
exp/proc_stat.pl
Normal file
21
exp/proc_stat.pl
Normal file
@ -0,0 +1,21 @@
|
||||
#!perl
|
||||
|
||||
use strict;
|
||||
#examine specific field from /proc/*/stat
|
||||
my $field = shift;
|
||||
|
||||
my $proc = "/proc";
|
||||
opendir DH, $proc or die;
|
||||
chdir $proc;
|
||||
local $/;
|
||||
|
||||
while (my $pid = readdir DH) {
|
||||
next unless $pid =~ /^\d+$/;
|
||||
open FH, "$pid/stat" or next;
|
||||
my $data = <FH>;
|
||||
close FH;
|
||||
my(@fields) = split /\s+/, $data;
|
||||
print "$pid $fields[1] -> $fields[$field]\n";
|
||||
}
|
||||
|
||||
closedir DH;
|
Loading…
Reference in New Issue
Block a user