X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;ds=sidebyside;f=master%2Froot%2Fbin%2Fcpumon_light;fp=master%2Froot%2Fbin%2Fcpumon_light;h=0000000000000000000000000000000000000000;hb=90b53a74e6ab72a304e99b8b7dd12c2e3bd29edd;hp=af635c108028727331031ea671020e4a686ed009;hpb=b78665b6171ffb8f56d2c128d8eee8526df7f38a;p=debian6500.git diff --git a/master/root/bin/cpumon_light b/master/root/bin/cpumon_light deleted file mode 100755 index af635c1..0000000 --- a/master/root/bin/cpumon_light +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my @cpu_stat_t0 = proc_stat(); -sleep 1; -my @cpu_stat_t1 = proc_stat(); -my $total = 0; -for (my $cpu_i = 0; $cpu_i < (scalar @cpu_stat_t0); $cpu_i++) { - my @stat_t0 = split /\s+/, $cpu_stat_t0[$cpu_i]; - my @stat_t1 = split /\s+/, $cpu_stat_t1[$cpu_i]; - my ($t0_idle, $t1_idle) = ($stat_t0[3], $stat_t1[3]); - my ($t0_total, $t1_total) = (0, 0); - $t0_total += $_ foreach @stat_t0; - $t1_total += $_ foreach @stat_t1; - - my $load = ($t1_total - $t0_total == 0) ? 100: - int((100 * (($t1_total - $t0_total) - ($t1_idle - $t0_idle))/($t1_total - $t0_total)) + 0.5); - print " +" unless ($cpu_i == 0); - printf "% 5.1f%% ", $load; - $total += $load; -} -printf " = % 6.1f%%\n", $total; - -sub proc_stat() { - return grep {s/^cpu\d+\s//} read_file('/proc/stat'); -} - -sub read_file($) { - my ($file) = @_; - open FILE, "<$file"; - my @content = ; - close FILE; - return @content; -} -