summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG14
-rw-r--r--WISHLIST4
-rwxr-xr-xloadbars56
3 files changed, 53 insertions, 21 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a57a70f..c50f79d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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)
diff --git a/WISHLIST b/WISHLIST
index 46f1d9f..9a9ee12 100644
--- a/WISHLIST
+++ b/WISHLIST
@@ -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
diff --git a/loadbars b/loadbars
index d014f8b..1995bb0 100755
--- a/loadbars
+++ b/loadbars
@@ -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};