summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul.buetow@1und1.de>2013-06-19 17:43:48 +0200
committerPaul Buetow <paul.buetow@1und1.de>2013-06-19 17:43:48 +0200
commitdb1dce493c95ba220a30ef19435241b0654317b9 (patch)
treeb0c3382b5b55b23daab788ed2d34c3651ab051d6
parent3898840f21bddb1c33c89ac4cea30879436ec6b5 (diff)
shell expansion works now!
-rw-r--r--docs/loadbars.112
-rw-r--r--docs/loadbars.pod12
-rw-r--r--docs/loadbars.txt11
-rwxr-xr-xloadbars26
4 files changed, 51 insertions, 10 deletions
diff --git a/docs/loadbars.1 b/docs/loadbars.1
index 2494a07..d14a025 100644
--- a/docs/loadbars.1
+++ b/docs/loadbars.1
@@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "LOADBARS 1"
-.TH LOADBARS 1 "2013-06-17" "loadbars 0.6.0.99" "User Commands"
+.TH LOADBARS 1 "2013-06-19" "loadbars 0.6.0.99" "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -133,9 +133,10 @@
loadbars \- A small and humble tool to observe server loads
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
+loadbars [\s-1LIST\s0 \s-1OF\s0 \s-1HOSTNAMES\s0] [\s-1OPTIONS\s0]
.SS "Tested platforms"
.IX Subsection "Tested platforms"
-This version of loadbars has only been tested on Debian GNU/Linux Squeeze.
+This version of loadbars has only been tested on Debian GNU/Linux Wheezy.
.SS "I like flying elephants"
.IX Subsection "I like flying elephants"
For any startup params help check out \-\-help on command line or 'h' during program
@@ -147,6 +148,11 @@ loadbars \-\-extended 1 \-\-showcores 1 \-\-height 300 \-\-hosts localhost
loadbars \-\-hosts localhost,server1.example.com,server2.example.com
.PP
loadbars \-\-cluster foocluster (foocluster is in /etc/clusters [ClusterSSH])
+.SS "More examples, using bash expansion"
+.IX Subsection "More examples, using bash expansion"
+loadbars servername{01,02,03}.example.com
+.PP
+loadbars servername{01..50}.example.com \-\-showcores 1
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Loadbars is a small script that can be used to observe \s-1CPU\s0 loads of several remote servers at once in real time. It connects with \s-1SSH\s0 (using \s-1SSH\s0 public/private key auth) to several servers at once and vizualizes all server CPUs and memory statistics right next each other (either summarized or each core separately). Loadbars is not a tool for collecting \s-1CPU\s0 loads and drawing graphs for later analysis. However, since such tools require a significant amount of time before producing results, Loadbars lets you observe the current state immediately. Loadbars does not remember or record any load information. It just shows the current \s-1CPU\s0 usages like top or vmstat does.
@@ -176,8 +182,6 @@ to = Total \s-1CPU\s0 usage, which is (100% \- id)
.PP
pk = Max us+sy peak of last avg. samples (extended)
.PP
-avg = System load average; desc. order: 1, 5 and 15 min. avg.
-.PP
1px horizontal line: Maximum sy+us+io of last 'avg' samples (extended)
.SS "Memory stuff"
.IX Subsection "Memory stuff"
diff --git a/docs/loadbars.pod b/docs/loadbars.pod
index fac961c..ef3f3e6 100644
--- a/docs/loadbars.pod
+++ b/docs/loadbars.pod
@@ -4,9 +4,11 @@ loadbars - A small and humble tool to observe server loads
=head1 SYNOPSIS
+loadbars [LIST OF HOSTNAMES] [OPTIONS]
+
=head2 Tested platforms
-This version of loadbars has only been tested on Debian GNU/Linux Squeeze.
+This version of loadbars has only been tested on Debian GNU/Linux Wheezy.
=head2 I like flying elephants
@@ -21,6 +23,12 @@ loadbars --hosts localhost,server1.example.com,server2.example.com
loadbars --cluster foocluster (foocluster is in /etc/clusters [ClusterSSH])
+=head2 More examples, using shell expansion
+
+loadbars servername{01,02,03}.example.com
+
+loadbars servername{01..50}.example.com --showcores 1
+
=head1 DESCRIPTION
Loadbars is a small script that can be used to observe CPU loads of several remote servers at once in real time. It connects with SSH (using SSH public/private key auth) to several servers at once and vizualizes all server CPUs and memory statistics right next each other (either summarized or each core separately). Loadbars is not a tool for collecting CPU loads and drawing graphs for later analysis. However, since such tools require a significant amount of time before producing results, Loadbars lets you observe the current state immediately. Loadbars does not remember or record any load information. It just shows the current CPU usages like top or vmstat does.
@@ -52,8 +60,6 @@ to = Total CPU usage, which is (100% - id)
pk = Max us+sy peak of last avg. samples (extended)
-avg = System load average; desc. order: 1, 5 and 15 min. avg.
-
1px horizontal line: Maximum sy+us+io of last 'avg' samples (extended)
=head2 Memory stuff
diff --git a/docs/loadbars.txt b/docs/loadbars.txt
index f06aa92..7d096b1 100644
--- a/docs/loadbars.txt
+++ b/docs/loadbars.txt
@@ -2,9 +2,11 @@ NAME
loadbars - A small and humble tool to observe server loads
SYNOPSIS
+ loadbars [LIST OF HOSTNAMES] [OPTIONS]
+
Tested platforms
This version of loadbars has only been tested on Debian GNU/Linux
- Squeeze.
+ Wheezy.
I like flying elephants
For any startup params help check out --help on command line or 'h'
@@ -18,6 +20,11 @@ SYNOPSIS
loadbars --cluster foocluster (foocluster is in /etc/clusters
[ClusterSSH])
+ More examples, using bash expansion
+ loadbars servername{01,02,03}.example.com
+
+ loadbars servername{01..50}.example.com --showcores 1
+
DESCRIPTION
Loadbars is a small script that can be used to observe CPU loads of
several remote servers at once in real time. It connects with SSH (using
@@ -55,8 +62,6 @@ INFO
pk = Max us+sy peak of last avg. samples (extended)
- avg = System load average; desc. order: 1, 5 and 15 min. avg.
-
1px horizontal line: Maximum sy+us+io of last 'avg' samples (extended)
Memory stuff
diff --git a/loadbars b/loadbars
index 6f6bc55..c8b89c0 100755
--- a/loadbars
+++ b/loadbars
@@ -38,6 +38,10 @@ say( 'Loadbars ' . get_version . ' ' . Loadbars::Constants->COPYRIGHT );
Loadbars::Config::read;
+my @hosts_extra;
+push @hosts_extra, shift @ARGV while @ARGV and $ARGV[0] !~ /^-/;
+
+
GetOptions( 'help|?' => \$usage, $dispatch->('options') );
if ( defined $usage ) {
@@ -52,6 +56,8 @@ my @hosts = map {
defined $b ? "$b:$a" : $a;
} split ',', $$hosts;
+push @hosts, @hosts_extra;
+
if ( @hosts || defined $Loadbars::Main::C{cluster} ) {
push @hosts, Loadbars::Config::get_cluster_hosts $C{cluster}
if defined $C{cluster};
@@ -64,6 +70,26 @@ else {
exit Loadbars::Constants->E_NOHOST;
}
+# Expand a host 'hostname[08..10,13].example.com' to
+# hostname08.example.com
+# hostname09.example.com
+# hostname10.example.com
+# hostname13.example.com
+
+=cut
+my @expanded_hosts;
+
+for my $host (@hosts) {
+ my @expands = $host =~ /\[(.+\)\].*/g;
+
+ k
+
+ } else {
+ push @expanded_hosts, $host;
+ }
+}
+=cut
+
my @threads = Loadbars::Main::threads_create @hosts;
Loadbars::Main::loop $dispatch, @threads;