From e9cd93d2728be6380858e4d939fd9a68c2880e14 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Thu, 17 Nov 2011 22:52:37 +0100 Subject: Some cleanup --- loadbars.pl | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/loadbars.pl b/loadbars.pl index 186b20a..d8da582 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -26,7 +26,7 @@ use threads::shared; use constant { DEPTH => 8, - VERSION => 'loadbars v0.2.1.1-devel', + VERSION => 'loadbars v0.2.2-devel', Copyright => '2010-2011 (c) Paul Buetow ', BLACK => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0x00), BLUE => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0xff), @@ -294,31 +294,6 @@ sub main_loop ($@) { $int -= 0.1; $C{inter} = $int > 0 ? $int : 0.1; $displayinfo = "Set graph update interval to $C{inter}"; - -=cut - } elsif ($key_name eq 'down') { - my $height = $C{height} + 10; - $app->resize($C{width},$height); - $C{height} = $height; - $displayinfo = "Set graph height to $C{height}"; - } elsif ($key_name eq 'up') { - my $height = $C{height}; - $height -= 10; - $C{height} = $height > 1 ? $height : 1; - $app->resize($C{width},$C{height}); - $displayinfo = "Set graph height to $C{height}"; - - } elsif ($key_name eq 'right') { - $C{width} += 10; - $app->resize($C{width},$C{height}); - $displayinfo = "Set graph width to $C{width}"; - } elsif ($key_name eq 'left') { - my $width = $C{width}; - $width -= 10; - $C{width} = $width > 1 ? $width : 1; - $app->resize($C{width},$C{height}); - $displayinfo = "Set graph width to $C{width}"; -=cut } } }; -- cgit v1.2.3 From fe81b56c6ff3cce9261d0d9a6d854bc8412f15a0 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Thu, 17 Nov 2011 23:04:32 +0100 Subject: Initial max values --- loadbars.pl | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/loadbars.pl b/loadbars.pl index d8da582..10c9b91 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -169,16 +169,25 @@ sub normalize_loads (%) { sub get_cpuaverage ($@) { my ($factor, @loads) = @_; - my %cpuaverage; + my (%cpumax, %cpuaverage); for my $l (@loads) { - $cpuaverage{$_} += $l->{$_} for keys %$l; + for (keys %$l) { + $cpuaverage{$_} += $l->{$_}; + + $cpumax{$_} = $l->{$_} + if not exists $cpumax{$_} or $cpumax{$_} < $l->{$_}; + } } my $div = @loads / $factor; - $cpuaverage{$_} /= $div for keys %cpuaverage; - return %cpuaverage; + for (keys %cpuaverage) { + $cpuaverage{$_} /= $div; + $cpumax{$_} /= $factor; + } + + return (\%cpumax, \%cpuaverage); } sub draw_background ($$) { @@ -347,12 +356,12 @@ sub main_loop ($@) { push @{$last_loads{$key}}, \%loads; shift @{$last_loads{$key}} while @{$last_loads{$key}} >= $C{average}; - my %cpuaverage = get_cpuaverage $C{factor}, @{$last_loads{$key}}; + my ($cpumaxmax, $cpuaverage) = get_cpuaverage $C{factor}, @{$last_loads{$key}}; my %heights = map { - $_ => defined $cpuaverage{$_} ? $cpuaverage{$_} * ($C{height}/100) : 1 + $_ => defined $cpuaverage->{$_} ? $cpuaverage->{$_} * ($C{height}/100) : 1 - } keys %cpuaverage; + } keys %$cpuaverage; my $is_host_summary = exists $is_host_summary{$host}; @@ -396,12 +405,12 @@ sub main_loop ($@) { $rect_iowait->x($x); $rect_iowait->y($y); - my $system_n_user = sum @cpuaverage{qw(user system)}; + my $system_n_user = sum @{$cpuaverage}{qw(user system)}; $app->fill($rect_iowait, Loadbars::BLACK); $app->fill($rect_nice, Loadbars::GREEN); $app->fill($rect_system, Loadbars::BLUE); - $app->fill($rect_system, $cpuaverage{system} > Loadbars::SYSTEM_PURPLE + $app->fill($rect_system, $cpuaverage->{system} > Loadbars::SYSTEM_PURPLE ? Loadbars::PURPLE : Loadbars::BLUE); $app->fill($rect_user, $system_n_user > Loadbars::USER_WHITE ? Loadbars::WHITE @@ -427,9 +436,9 @@ sub main_loop ($@) { $C{togglecpu} ? $current_barnum + 1: $current_corenum); } - $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage{nice}, 'ni'); - $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage{user}, 'us'); - $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage{system}, 'sy'); + $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage->{nice}, 'ni'); + $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage->{user}, 'us'); + $app->print($x, $y+=$space, sprintf '%d%s', $cpuaverage->{system}, 'sy'); $app->print($x, $y+=$space, sprintf '%d%s', $system_n_user, 'su'); unless ($is_host_summary) { -- cgit v1.2.3 From 3cf0d909609148c23544a906af21545fac147513 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Thu, 17 Nov 2011 23:41:25 +0100 Subject: Add a grey horizontal line of 1 px which represent the max sy+us cpu --- WISHLIST | 1 - loadbars.pl | 32 ++++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/WISHLIST b/WISHLIST index 6485a2f..2a71f48 100644 --- a/WISHLIST +++ b/WISHLIST @@ -1,4 +1,3 @@ -* Small white bar which shows peak cpu load * Stats for other stuff (e.g. memory, inodes..., disk usage) * Dynamic/online resizing of the window * Rudimentary support for /etc/clusters, the Cluster-SSH configuration file diff --git a/loadbars.pl b/loadbars.pl index 10c9b91..e072dfe 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -35,7 +35,7 @@ use constant { PURPLE => SDL::Color->new(-r => 0xa0, -g => 0x20, -b => 0xf0), RED => SDL::Color->new(-r => 0xff, -g => 0x00, -b => 0x00), WHITE => SDL::Color->new(-r => 0xff, -g => 0xff, -b => 0xff), - GREY => SDL::Color->new(-r => 0x3b, -g => 0x3b, -b => 0x3b), + 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, @@ -58,7 +58,7 @@ my %C : shared; # Setting defaults %C = ( title => Loadbars::VERSION . ' (press h for help)', - average => 30, + average => 15, togglecpu => 1, cpuregexp => 'cpu', factor => 1, @@ -169,14 +169,14 @@ sub normalize_loads (%) { sub get_cpuaverage ($@) { my ($factor, @loads) = @_; - my (%cpumax, %cpuaverage); + my (%cpucurrent, %cpuaverage); for my $l (@loads) { for (keys %$l) { $cpuaverage{$_} += $l->{$_}; - $cpumax{$_} = $l->{$_} - if not exists $cpumax{$_} or $cpumax{$_} < $l->{$_}; + $cpucurrent{$_} = $l->{$_} + if not exists $cpucurrent{$_} or $cpucurrent{$_} < $l->{$_}; } } @@ -184,10 +184,10 @@ sub get_cpuaverage ($@) { for (keys %cpuaverage) { $cpuaverage{$_} /= $div; - $cpumax{$_} /= $factor; + $cpucurrent{$_} /= $factor; } - return (\%cpumax, \%cpuaverage); + return (\%cpucurrent, \%cpuaverage); } sub draw_background ($$) { @@ -356,13 +356,18 @@ sub main_loop ($@) { push @{$last_loads{$key}}, \%loads; shift @{$last_loads{$key}} while @{$last_loads{$key}} >= $C{average}; - my ($cpumaxmax, $cpuaverage) = get_cpuaverage $C{factor}, @{$last_loads{$key}}; + my ($cpucurrent, $cpuaverage) = get_cpuaverage $C{factor}, @{$last_loads{$key}}; my %heights = map { $_ => defined $cpuaverage->{$_} ? $cpuaverage->{$_} * ($C{height}/100) : 1 } keys %$cpuaverage; + my %currentheights = map { + $_ => defined $cpucurrent->{$_} ? $cpucurrent->{$_} * ($C{height}/100) : 1 + + } keys %$cpucurrent; + my $is_host_summary = exists $is_host_summary{$host}; my $rect_separator = undef; @@ -370,6 +375,7 @@ sub main_loop ($@) { my $rect_system = get_rect $rects, "$key;system"; my $rect_iowait = get_rect $rects, "$key;iowait"; my $rect_nice = get_rect $rects, "$key;nice"; + my $rect_max = get_rect $rects, "$key;max"; unless ($is_host_summary || $C{togglecpu}) { $current_corenum = 0; @@ -405,11 +411,17 @@ sub main_loop ($@) { $rect_iowait->x($x); $rect_iowait->y($y); + $rect_max->width($width); + $rect_max->height(1); + $rect_max->x($x); + $rect_max->y($C{height} - $currentheights{system} - $currentheights{user}); + my $system_n_user = sum @{$cpuaverage}{qw(user system)}; $app->fill($rect_iowait, Loadbars::BLACK); $app->fill($rect_nice, Loadbars::GREEN); - $app->fill($rect_system, Loadbars::BLUE); + #$app->fill($rect_system, Loadbars::BLUE); + $app->fill($rect_max, Loadbars::GREY); $app->fill($rect_system, $cpuaverage->{system} > Loadbars::SYSTEM_PURPLE ? Loadbars::PURPLE : Loadbars::BLUE); @@ -419,7 +431,6 @@ sub main_loop ($@) { : ($system_n_user > Loadbars::USER_YELLOW0 ? Loadbars::YELLOW0 : (Loadbars::YELLOW))))); - my ($y, $space) = (5, $font_height); my @loadavg = split ';', $AVGSTATS{$host}; $is_host_summary{$host} = 1 if defined $loadavg[0]; @@ -510,6 +521,7 @@ Explanation colors: Orange: User usage if system & user cpu is >70% White: Usage usage if system & user cpu is >99% Green: Nice cpu usage + Grey 1px horizintal: Maximum sy+us cpu of last 'avg' samples Explanation text display: ni = Nice cpu usage in % us = User cpu usage in % -- cgit v1.2.3 From 664bba80b91f03966d1b2fe9101e34327dcd1974 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Thu, 17 Nov 2011 23:44:18 +0100 Subject: Typo --- loadbars.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loadbars.pl b/loadbars.pl index e072dfe..8148830 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -521,7 +521,7 @@ Explanation colors: Orange: User usage if system & user cpu is >70% White: Usage usage if system & user cpu is >99% Green: Nice cpu usage - Grey 1px horizintal: Maximum sy+us cpu of last 'avg' samples + Grey 1px horizontal: Maximum sy+us cpu of last 'avg' samples Explanation text display: ni = Nice cpu usage in % us = User cpu usage in % -- cgit v1.2.3 From be34edcee2100053803dbc56a182a6f17e65b83d Mon Sep 17 00:00:00 2001 From: "Paul Buetow (lxpbuetow)" Date: Fri, 18 Nov 2011 14:46:17 +0100 Subject: Horizontal max. line is now colored --- loadbars.pl | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/loadbars.pl b/loadbars.pl index 8148830..98992f5 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -169,14 +169,14 @@ sub normalize_loads (%) { sub get_cpuaverage ($@) { my ($factor, @loads) = @_; - my (%cpucurrent, %cpuaverage); + my (%cpumax, %cpuaverage); for my $l (@loads) { for (keys %$l) { $cpuaverage{$_} += $l->{$_}; - $cpucurrent{$_} = $l->{$_} - if not exists $cpucurrent{$_} or $cpucurrent{$_} < $l->{$_}; + $cpumax{$_} = $l->{$_} + if not exists $cpumax{$_} or $cpumax{$_} < $l->{$_}; } } @@ -184,10 +184,10 @@ sub get_cpuaverage ($@) { for (keys %cpuaverage) { $cpuaverage{$_} /= $div; - $cpucurrent{$_} /= $factor; + $cpumax{$_} /= $factor; } - return (\%cpucurrent, \%cpuaverage); + return (\%cpumax, \%cpuaverage); } sub draw_background ($$) { @@ -356,17 +356,17 @@ sub main_loop ($@) { push @{$last_loads{$key}}, \%loads; shift @{$last_loads{$key}} while @{$last_loads{$key}} >= $C{average}; - my ($cpucurrent, $cpuaverage) = get_cpuaverage $C{factor}, @{$last_loads{$key}}; + my ($cpumax, $cpuaverage) = get_cpuaverage $C{factor}, @{$last_loads{$key}}; my %heights = map { $_ => defined $cpuaverage->{$_} ? $cpuaverage->{$_} * ($C{height}/100) : 1 } keys %$cpuaverage; - my %currentheights = map { - $_ => defined $cpucurrent->{$_} ? $cpucurrent->{$_} * ($C{height}/100) : 1 + my %maxheights = map { + $_ => defined $cpumax->{$_} ? $cpumax->{$_} * ($C{height}/100) : 1 - } keys %$cpucurrent; + } keys %$cpumax; my $is_host_summary = exists $is_host_summary{$host}; @@ -414,14 +414,23 @@ sub main_loop ($@) { $rect_max->width($width); $rect_max->height(1); $rect_max->x($x); - $rect_max->y($C{height} - $currentheights{system} - $currentheights{user}); + $rect_max->y($C{height} - $maxheights{system} - $maxheights{user}); my $system_n_user = sum @{$cpuaverage}{qw(user system)}; + my $max_system_n_user = sum @{$cpumax}{qw(user system)}; $app->fill($rect_iowait, Loadbars::BLACK); $app->fill($rect_nice, Loadbars::GREEN); - #$app->fill($rect_system, Loadbars::BLUE); - $app->fill($rect_max, Loadbars::GREY); + $app->fill($rect_max, $max_system_n_user > Loadbars::USER_WHITE ? Loadbars::WHITE + : ($max_system_n_user > Loadbars::USER_RED ? Loadbars::RED + : ($max_system_n_user > Loadbars::USER_ORANGE ? Loadbars::ORANGE + : ($max_system_n_user > Loadbars::USER_YELLOW0 ? Loadbars::YELLOW0 + : (Loadbars::YELLOW))))); + $app->fill($rect_user, $system_n_user > Loadbars::USER_WHITE ? Loadbars::WHITE + : ($system_n_user > Loadbars::USER_RED ? Loadbars::RED + : ($system_n_user > Loadbars::USER_ORANGE ? Loadbars::ORANGE + : ($system_n_user > Loadbars::USER_YELLOW0 ? Loadbars::YELLOW0 + : (Loadbars::YELLOW))))); $app->fill($rect_system, $cpuaverage->{system} > Loadbars::SYSTEM_PURPLE ? Loadbars::PURPLE : Loadbars::BLUE); @@ -521,7 +530,7 @@ Explanation colors: Orange: User usage if system & user cpu is >70% White: Usage usage if system & user cpu is >99% Green: Nice cpu usage - Grey 1px horizontal: Maximum sy+us cpu of last 'avg' samples + 1px horizontal line: Maximum sy+us cpu of last 'avg' samples Explanation text display: ni = Nice cpu usage in % us = User cpu usage in % -- cgit v1.2.3 From 50266f273c81f1d46b3025fed4dfbbb71f04f9e5 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (lxpbuetow)" Date: Fri, 18 Nov 2011 15:12:36 +0100 Subject: Change default settings --- loadbars.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/loadbars.pl b/loadbars.pl index 98992f5..ad7bb45 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -67,8 +67,8 @@ my %C : shared; inter => 0.1, samples => 1000, sshopts => '', - width => 1200, - height => 200, + width => 1250, + height => 150, ); # Quick n dirty helpers @@ -203,7 +203,14 @@ sub draw_background ($$) { } sub create_threads (@) { - return map { $_->detach(); $_ } map { threads->create('thread_get_stats', $_) } @_; + return map { + $_->detach(); + $_; + + } map { + threads->create('thread_get_stats', $_); + + } @_; } sub main_loop ($@) { -- cgit v1.2.3 From b6668e0d62823fbefd8770128f5d5a3055813f2d Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Sat, 19 Nov 2011 12:04:29 +0100 Subject: Release v0.2.2 --- CHANGELOG | 8 ++++++++ loadbars.pl | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cd10155..ba1ffff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +Sat Nov 19 11:54:51 CET 2011 +* Released v0.2.2 +* Added a 1px horizontal line to each bar which represent the max. peak + of user and system cpu load of the last N samples (max. of the last 15 + samples by default, it can be configured using --average) +* Default value for --average has been decreased from 30 to 15 sample + values + Fr 12. Aug 21:41:46 CEST 2011 * Released v0.2.1 diff --git a/loadbars.pl b/loadbars.pl index ad7bb45..9136911 100755 --- a/loadbars.pl +++ b/loadbars.pl @@ -26,7 +26,7 @@ use threads::shared; use constant { DEPTH => 8, - VERSION => 'loadbars v0.2.2-devel', + VERSION => 'loadbars v0.2.2', Copyright => '2010-2011 (c) Paul Buetow ', BLACK => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0x00), BLUE => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0xff), @@ -555,7 +555,7 @@ END togglecpu => { menupos => 1, help => 'Toggle CPUs (0 or 1)', mode => 7, type => 'i' }, togglecpu_hot => { menupos => 2, cmd => '1', help => 'Toggle CPUs', mode => 1 }, - average => { menupos => 3, help => 'Set number of samples for calculating avg.', mode => 6, type => 'i' }, + average => { menupos => 3, help => 'Num of samples for avg. (more fluent animations)', mode => 6, type => 'i' }, average_hot_up => { menupos => 4, cmd => 'a', help => 'Increases number of samples for calculating avg. by 1', mode => 1 }, average_hot_dn => { menupos => 5, cmd => 'y', help => 'Decreases number of samples for calculating avg. by 1', mode => 1 }, -- cgit v1.2.3