From 69b670a9707a621b46051ee899db3d66891bf5e6 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 28 Nov 2005 21:12:54 +0000 Subject: [PATCH] examine specific field from /proc/*/stat --- exp/proc_stat.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 exp/proc_stat.pl diff --git a/exp/proc_stat.pl b/exp/proc_stat.pl new file mode 100644 index 00000000..f956952e --- /dev/null +++ b/exp/proc_stat.pl @@ -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 = ; + close FH; + my(@fields) = split /\s+/, $data; + print "$pid $fields[1] -> $fields[$field]\n"; +} + +closedir DH;