summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README42
-rwxr-xr-xloadbars76
2 files changed, 70 insertions, 48 deletions
diff --git a/README b/README
index 6ceae46..37d7954 100644
--- a/README
+++ b/README
@@ -24,23 +24,25 @@ Versioning schema: a.b.c[.d], where
It's not a release if there is a -devel suffix. It's a development
version (in the trunk) then.
-Explanation colors:
- Blue: System cpu usage
- Purple: System usage if it's >30%
- Yellow: User cpu usage
- Darker yellow: User usage if system & user cpu is >50%
- Orange: User usage if system & user cpu is >70%
- Red: User usage if system & user cpu is >90%
- White: Usage usage if system & user cpu is >99%
- Green: Nice cpu usage
-
-Explanation text display:
- ni = Nice cpu usage in %
- us = User cpu usage in %
- sy = System cpu sage in %
- su = System & user cpu usage in %
- avg = System load average (desc. order: 1, 5 and 15 min. avg.)
-
-
-
-
+Explanations:
+ id = Idle cpu usage in % (extended)
+ Color: Black
+ st = CPU stolen from VM in % (extended)
+ Color: Red
+ ir = IRQ usage in % (extended)
+ Color: White
+ sr = Soft IRQ usage in % (extended)
+ Color: White
+ ni = Nice cpu usage in %
+ Color: Green
+ io = IOwait cpu sage in % (extended)
+ Color: Purple
+ us = User cpu usage in %
+ Color: Yellow, dark yellow if al>50%, orange if al>50%
+ sy = System cpu sage in %
+ Blue, purple if >30%
+ al = 100% minus id
+ pk = Max al peak of last avg. samples (extended)
+ avg = System load average; desc. order: 1, 5 and 15 min. avg. (extended)
+ 1px horizontal line: Maximum sy+us+io of last 'avg' samples (extended)
+(extended) means: text display only if extended mode is turned on
diff --git a/loadbars b/loadbars
index 5083583..e8bb3a1 100755
--- a/loadbars
+++ b/loadbars
@@ -31,7 +31,8 @@ use constant {
CSSH_MAX_RECURSION => 10,
COLOR_DEPTH => 8,
BLACK => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0x00),
- BLUE => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0xff),
+ BLUE0=> SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0xff),
+ BLUE => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0x88),
GREEN => SDL::Color->new(-r => 0x00, -g => 0x90, -b => 0x00),
ORANGE => SDL::Color->new(-r => 0xff, -g => 0x70, -b => 0x00),
PURPLE => SDL::Color->new(-r => 0xa0, -g => 0x20, -b => 0xf0),
@@ -41,7 +42,7 @@ use constant {
GREY => SDL::Color->new(-r => 0xaa, -g => 0xaa, -b => 0xaa),
YELLOW0 => SDL::Color->new(-r => 0xff, -g => 0xa0, -b => 0x00),
YELLOW => SDL::Color->new(-r => 0xff, -g => 0xc0, -b => 0x00),
- SYSTEM_PURPLE => 30,
+ SYSTEM_BLUE0 => 30,
USER_ORANGE => 70,
USER_YELLOW0 => 50,
NULL => 0,
@@ -72,7 +73,7 @@ my %C : shared;
samples => 1000,
sshopts => '',
width => 1250,
- height => 220,
+ height => 230,
);
# Quick n dirty helpers
@@ -84,12 +85,19 @@ sub null ($) { my $arg = shift; return defined $arg ? $arg : 0 }
sub set_togglecpu_regexp () { $C{cpuregexp} = $C{togglecpu} ? 'cpu' : 'cpu ' }
sub error ($) { die shift, "\n" }
+sub norm ($) {
+ my $n = shift;
+
+ return $n if $C{factor} != 0;
+ return $n > 100 ? 100 : ($n < 0 ? 0 : $n);
+}
+
sub parse_cpu_line ($) {
my $line = shift;
my ($name, %load);
- ($name, @load{qw(user nice system idle iowait irq softirq)}) = split ' ', $line;
- $load{TOTAL} = sum @load{qw(user nice system idle iowait irq softirq)};
+ ($name, @load{qw(user nice system idle iowait irq softirq steal)}) = split ' ', $line;
+ $load{TOTAL} = sum @load{qw(user nice system idle iowait irq softirq steal)};
return ($name, \%load);
}
@@ -383,6 +391,7 @@ sub main_loop ($@) {
my $rect_separator = undef;
my $rect_idle = get_rect $rects, "$key;idle";
+ my $rect_steal = get_rect $rects, "$key;steal";
my $rect_irq = get_rect $rects, "$key;irq";
my $rect_softirq = get_rect $rects, "$key;softirq";
my $rect_nice = get_rect $rects, "$key;nice";
@@ -427,16 +436,22 @@ sub main_loop ($@) {
$rect_iowait->y($y);
$y -= $heights{softirq};
- $rect_iowait->width($width);
- $rect_iowait->height($heights{softirq});
- $rect_iowait->x($x);
- $rect_iowait->y($y);
+ $rect_softirq->width($width);
+ $rect_softirq->height($heights{softirq});
+ $rect_softirq->x($x);
+ $rect_softirq->y($y);
$y -= $heights{irq};
- $rect_iowait->width($width);
- $rect_iowait->height($heights{irq});
- $rect_iowait->x($x);
- $rect_iowait->y($y);
+ $rect_irq->width($width);
+ $rect_irq->height($heights{irq});
+ $rect_irq->x($x);
+ $rect_irq->y($y);
+
+ $y -= $heights{steal};
+ $rect_steal->width($width);
+ $rect_steal->height($heights{steal});
+ $rect_steal->x($x);
+ $rect_steal->y($y);
$y -= $heights{idle};
$rect_idle->width($width);
@@ -448,6 +463,7 @@ sub main_loop ($@) {
my $max_all = 0;
$app->fill($rect_idle, Loadbars::BLACK);
+ $app->fill($rect_steal, Loadbars::RED);
$app->fill($rect_irq, Loadbars::WHITE);
$app->fill($rect_softirq, Loadbars::WHITE);
$app->fill($rect_iowait, Loadbars::PURPLE);
@@ -464,8 +480,7 @@ sub main_loop ($@) {
$rect_peak->x($x);
$rect_peak->y($C{height} - $maxheights{system} - $maxheights{user});
- $max_all = sum @{$cpumax}{qw(user system iowait irq softirq)};
- $max_all = 100 if $max_all > 100;
+ $max_all = sum @{$cpumax}{qw(user system iowait irq softirq steal)};
$app->fill($rect_peak, $max_all > Loadbars::USER_ORANGE ? Loadbars::ORANGE
: ($max_all > Loadbars::USER_YELLOW0 ? Loadbars::YELLOW0
@@ -475,7 +490,7 @@ sub main_loop ($@) {
$app->fill($rect_user, $all > Loadbars::USER_ORANGE ? Loadbars::ORANGE
: ($all > Loadbars::USER_YELLOW0 ? Loadbars::YELLOW0
: (Loadbars::YELLOW)));
- $app->fill($rect_system, $cpuaverage->{system} > Loadbars::SYSTEM_PURPLE ? Loadbars::PURPLE
+ $app->fill($rect_system, $cpuaverage->{system} > Loadbars::SYSTEM_BLUE0 ? Loadbars::BLUE0
: Loadbars::BLUE);
my ($y, $space) = (5, $font_height);
@@ -495,19 +510,20 @@ sub main_loop ($@) {
}
if ($C{extended}) {
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{idle}, 'id');
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{irq}, 'ir');
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{softirq}, 'sr');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{idle}, 'id');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{steal}, 'st');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{irq}, 'ir');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{softirq}, 'sr');
}
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{nice}, 'ni');
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{iowait}, 'io') if $C{extended};
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{user}, 'us');
- $app->print($x, $y+=$space, sprintf '%02d%s', $cpuaverage->{system}, 'sy');
- $app->print($x, $y+=$space, sprintf '%02d%s', $all, 'al');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{nice}, 'ni');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{iowait}, 'io') if $C{extended};
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{user}, 'us');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $cpuaverage->{system}, 'sy');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $all, 'al');
if ($C{extended}) {
- $app->print($x, $y+=$space, sprintf '%02d%s', $max_all, 'pk');
+ $app->print($x, $y+=$space, sprintf '%02d%s', norm $max_all, 'pk');
unless ($is_host_summary) {
if (defined $loadavg[0]) {
@@ -525,12 +541,14 @@ sub main_loop ($@) {
$app->update(
$rect_nice,
+ $rect_steal,
$rect_irq,
$rect_softirq,
$rect_iowait,
$rect_idle,
+ $rect_system,
$rect_user,
- $rect_system);
+ );
$app->update($rect_separator) if defined $rect_separator;
@@ -581,6 +599,8 @@ sub dispatch_table () {
Explanations:
id = Idle cpu usage in % (extended)
Color: Black
+ st = CPU stolen from VM in % (extended)
+ Color: Red
ir = IRQ usage in % (extended)
Color: White
sr = Soft IRQ usage in % (extended)
@@ -593,8 +613,8 @@ Explanations:
Color: Yellow, dark yellow if al>50%, orange if al>50%
sy = System cpu sage in %
Blue, purple if >30%
- al = sy+us+io+ir+sr
- pk = Max sy+us+io+ir+sr peak of last avg. samples (extended)
+ al = 100% minus id
+ pk = Max al peak of last avg. samples (extended)
avg = System load average; desc. order: 1, 5 and 15 min. avg. (extended)
1px horizontal line: Maximum sy+us+io of last 'avg' samples (extended)
(extended) means: text display only if extended mode is turned on