diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-08-23 13:01:55 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-08-23 13:01:55 +0000 |
commit | 673787cbdab4a47b0b3cb987866c57704d7bdee9 (patch) | |
tree | 32255ffefd59a78b5e798e18a4f790b032449c1b /perl-install/commands.pm | |
parent | 57ea24fde5f61bb54bee187847f1119b5c79f9f3 (diff) | |
download | drakx-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.pm | 42 |
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 { |