summaryrefslogtreecommitdiffstats
path: root/perl-install/commands.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-08-23 13:01:55 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-08-23 13:01:55 +0000
commit673787cbdab4a47b0b3cb987866c57704d7bdee9 (patch)
tree32255ffefd59a78b5e798e18a4f790b032449c1b /perl-install/commands.pm
parent57ea24fde5f61bb54bee187847f1119b5c79f9f3 (diff)
downloaddrakx-673787cbdab4a47b0b3cb987866c57704d7bdee9.tar
drakx-673787cbdab4a47b0b3cb987866c57704d7bdee9.tar.gz
drakx-673787cbdab4a47b0b3cb987866c57704d7bdee9.tar.bz2
drakx-673787cbdab4a47b0b3cb987866c57704d7bdee9.tar.xz
drakx-673787cbdab4a47b0b3cb987866c57704d7bdee9.zip
no_comment
Diffstat (limited to 'perl-install/commands.pm')
-rw-r--r--perl-install/commands.pm42
1 files changed, 23 insertions, 19 deletions
diff --git a/perl-install/commands.pm b/perl-install/commands.pm
index 9b06743fa..4a4340f2f 100644
--- a/perl-install/commands.pm
+++ b/perl-install/commands.pm
@@ -246,25 +246,29 @@ sub cp {
&$cp(@_);
}
-#sub ps {
-# @_ and die "usage: ps\n";
-# my ($pid, $cmd);
-#
-# local (*STDOUT_TOP, *STDOUT);
-# format STDOUT_TOP =
-# PID CMD
-#.
-# format =
-#@>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-#$pid, $cmd
-#.
-#
-# foreach $pid (sort {$a <=> $b} grep { /\d+/ } all('/proc')) {
-# (($cmd) = cat_("/proc/$pid/cmdline")) =~ s/\0/ /g;
-# $cmd ||= (split ' ', (cat_("/proc/$pid/stat"))[0])[1];
-# write STDOUT
-# }
-#}
+sub ps {
+ @_ and die "usage: ps\n";
+ my ($pid, $cpu, $cmd);
+ my $uptime = int first(cat_("/proc/uptime"));
+ my $hertz = 100;
+
+ local (*STDOUT_TOP);
+ format STDOUT_TOP =
+ PID CMD
+.
+ format =
+@>>>> @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$pid, $cpu, $cmd
+.
+
+ foreach $pid (sort {$a <=> $b} grep { /\d+/ } all('/proc')) {
+ my @l = split(' ', cat_("/proc/$pid/stat"));
+ $cpu = sprintf "%2.1f", max(0, min(99, ($l[13] + $l[14]) * 100 / $hertz / ($uptime - $l[21] / $hertz)));
+ (($cmd) = cat_("/proc/$pid/cmdline")) =~ s/\0/ /g;
+ $cmd ||= (split ' ', (cat_("/proc/$pid/stat"))[0])[1];
+ write STDOUT;
+ }
+}
sub dd {