diff options
| author | pbuetow (lxpbuetow) <puppet@mx.buetow.org> | 2011-12-27 12:33:24 +0100 |
|---|---|---|
| committer | pbuetow (lxpbuetow) <puppet@mx.buetow.org> | 2011-12-27 12:33:24 +0100 |
| commit | 7003029f282fcfc0e302bfd1ce2def3a7aef5b8f (patch) | |
| tree | 7092158cf2efa358cd2d5e04b1731037bfd65111 | |
| parent | 2d3408b4aa5c420c061f6b847f7b5044db40efc6 (diff) | |
| parent | dddacc0f9f02f40541db17d787642319e736e4ce (diff) | |
Release of v0.3.10.3.1
| -rw-r--r-- | CHANGELOG | 14 | ||||
| -rw-r--r-- | WISHLIST | 4 | ||||
| -rwxr-xr-x | loadbars | 56 |
3 files changed, 53 insertions, 21 deletions
@@ -1,5 +1,17 @@ +Tue Dec 27 12:28:40 CET 2011 +* Released v0.3.1 +* --cluster option (which reads the ClusterSSH config file /etc/clusters/) + also supports clusters of clusters. e.g.: + $ cat /etc/clusters + clusterA server01 server02 + clusterB clusterA server03 + So --cluster clusterB will connect to server01 server02 and server03 +* --hosts option supports username to be specified. E.g.: + # ./loadbars --hosts user1@server01,user2@server02 + will connect to server01 using user1 and server02 with user2. + Mon Dec 26 14:46:25 CET 2011 -* Releases v0.3.0 +* Released v0.3.0 * Peak CPU load is not displayed by default anymore. User 'p' command or the --togglepeak 1 startup option. * Peak CPU load is now also displayd in text format (marked as pk) @@ -1,5 +1,5 @@ -* Stats for other stuff (e.g. memory, inodes..., disk usage) +* Stats for memory +* Stats for network * Dynamic/online resizing of the window * Adding and removing hosts online * .deb for Debian and Ubuntu -* Allow sshusername@hostname in --hosts @@ -25,9 +25,11 @@ use threads; use threads::shared; use constant { - DEPTH => 8, - VERSION => 'loadbars v0.3.0-master', + DEPTH => 8, + VERSION => 'loadbars v0.3.1', Copyright => '2010-2011 (c) Paul Buetow <loadbars@mx.buetow.org>', + CSSH_CONFFILE => '/etc/clusters', + CSSH_MAX_RECURSION => 10, BLACK => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0x00), BLUE => SDL::Color->new(-r => 0x00, -g => 0x00, -b => 0xff), GREEN => SDL::Color->new(-r => 0x00, -g => 0x90, -b => 0x00), @@ -70,7 +72,7 @@ my %C : shared; samples => 1000, sshopts => '', width => 1250, - height => 200, + height => 150, ); # Quick n dirty helpers @@ -91,8 +93,9 @@ sub parse_cpu_line ($) { return ($name, \%load); } -sub thread_get_stats ($) { - my $host = shift; +sub thread_get_stats ($;$) { + my ($host, $user) = @_; + $user = defined $user ? "-l $user" : ''; my ($sigusr1, $quit) = (0, 0); my $loadavgexp = qr/(\d+\.\d{2}) (\d+\.\d{2}) (\d+\.\d{2})/; @@ -118,8 +121,10 @@ sub thread_get_stats ($) { done fi BASH + + my $cmd = $host eq 'localhost' ? $bash - : "ssh -o StrictHostKeyChecking=no $C{sshopts} $host '$bash'"; + : "ssh $user -o StrictHostKeyChecking=no $C{sshopts} $host '$bash'"; my $pid = open my $pipe, "$cmd |" or do { say "Warning: $!"; @@ -210,7 +215,7 @@ sub create_threads (@) { $_; } map { - threads->create('thread_get_stats', $_); + threads->create('thread_get_stats', split /:/); } @_; } @@ -218,14 +223,11 @@ sub create_threads (@) { sub main_loop ($@) { my ($dispatch, @threads) = @_; - # Planned for the future - my $statusbar_height = 0; - my $app = SDL::App->new( -title => $C{title}, -icon_title => $C{title}, -width => $C{width}, - -height => $C{height}+$statusbar_height, + -height => $C{height}, -depth => Loadbars::DEPTH, -resizeable => 0, ); @@ -686,11 +688,19 @@ END return (\$hosts, $closure); } -sub get_cluster_hosts ($) { - my $cluster = shift; - my $confile = '/etc/clusters'; +# Recursuve function +sub get_cluster_hosts ($;$); +sub get_cluster_hosts ($;$) { + my ($cluster, $recursion) = @_; + + unless (defined $recursion) { + $recursion = 1; - open my $fh, $confile or error "$!: $confile"; + } elsif ($recursion > CSSH_MAX_RECURSION) { + error "CSSH_MAX_RECURSION reached. Infinite circle loop in " . CSSH_CONFFILE . "?"; + } + + open my $fh, CSSH_CONFFILE or error "$!: " . CSSH_CONFFILE; my $hosts; while (<$fh>) { @@ -702,9 +712,16 @@ sub get_cluster_hosts ($) { close $fh; - error "No such cluster in $confile: $cluster" unless defined $hosts; + unless (defined $hosts) { + error "No such cluster in " . CSSH_CONFFILE . ": $cluster" + unless defined $recursion; + + return ($cluster); + } - return split /\s+/, $hosts; + my @hosts; + push @hosts, get_cluster_hosts $_, ($recursion + 1) for (split /\s+/, $hosts); + return @hosts; } sub main () { @@ -720,7 +737,10 @@ sub main () { set_togglecpu_regexp; - my @hosts = split ',', $$hosts; + my @hosts = map { + my ($a, $b) = split /\@/, $_; + defined $b ? "$b:$a" : $a; + } split ',', $$hosts; if (@hosts || defined $C{cluster}) { push @hosts, get_cluster_hosts $C{cluster} if defined $C{cluster}; |
