diff options
-rw-r--r-- | ctdb/doc/onnode.1 | 347 | ||||
-rw-r--r-- | ctdb/doc/onnode.1.html | 69 | ||||
-rw-r--r-- | ctdb/doc/onnode.1.xml | 126 | ||||
-rwxr-xr-x | ctdb/tools/onnode | 43 |
4 files changed, 495 insertions, 90 deletions
diff --git a/ctdb/doc/onnode.1 b/ctdb/doc/onnode.1 index 926df4d1455..9923867989a 100644 --- a/ctdb/doc/onnode.1 +++ b/ctdb/doc/onnode.1 @@ -1,79 +1,372 @@ .\" Title: onnode -.\" Author: -.\" Generator: DocBook XSL Stylesheets v1.72.0 <http://docbook.sf.net/> -.\" Date: 07/10/2007 -.\" Manual: -.\" Source: +.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] +.\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/> +.\" Date: 07/10/2008 +.\" Manual: [FIXME: manual] +.\" Source: [FIXME: source] +.\" Language: English .\" -.TH "ONNODE" "1" "07/10/2007" "" "" +.TH "ONNODE" "1" "07/10/2008" "[FIXME: source]" "[FIXME: manual]" +.\" ----------------------------------------------------------------- +.\" * (re)Define some macros +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" toupper - uppercase a string (locale-aware) +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de toupper +.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ +\\$* +.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz +.. +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" SH-xref - format a cross-reference to an SH section +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de SH-xref +.ie n \{\ +.\} +.toupper \\$* +.el \{\ +\\$* +.\} +.. +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" SH - level-one heading that works better for non-TTY output +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de1 SH +.\" put an extra blank line of space above the head in non-TTY output +.if t \{\ +.sp 1 +.\} +.sp \\n[PD]u +.nr an-level 1 +.set-an-margin +.nr an-prevailing-indent \\n[IN] +.fi +.in \\n[an-margin]u +.ti 0 +.HTML-TAG ".NH \\n[an-level]" +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +\." make the size of the head bigger +.ps +3 +.ft B +.ne (2v + 1u) +.ie n \{\ +.\" if n (TTY output), use uppercase +.toupper \\$* +.\} +.el \{\ +.nr an-break-flag 0 +.\" if not n (not TTY), use normal case (not uppercase) +\\$1 +.in \\n[an-margin]u +.ti 0 +.\" if not n (not TTY), put a border/line under subheading +.sp -.6 +\l'\n(.lu' +.\} +.. +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" SS - level-two heading that works better for non-TTY output +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de1 SS +.sp \\n[PD]u +.nr an-level 1 +.set-an-margin +.nr an-prevailing-indent \\n[IN] +.fi +.in \\n[IN]u +.ti \\n[SN]u +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.ps \\n[PS-SS]u +\." make the size of the head bigger +.ps +2 +.ft B +.ne (2v + 1u) +.if \\n[.$] \&\\$* +.. +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" BB/BE - put background/screen (filled box) around block of text +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de BB +.if t \{\ +.sp -.5 +.br +.in +2n +.ll -2n +.gcolor red +.di BX +.\} +.. +.de EB +.if t \{\ +.if "\\$2"adjust-for-leading-newline" \{\ +.sp -1 +.\} +.br +.di +.in +.ll +.gcolor +.nr BW \\n(.lu-\\n(.i +.nr BH \\n(dn+.5v +.ne \\n(BHu+.5v +.ie "\\$2"adjust-for-leading-newline" \{\ +\M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[] +.\} +.el \{\ +\M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[] +.\} +.in 0 +.sp -.5v +.nf +.BX +.in +.sp .5v +.fi +.\} +.. +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" BM/EM - put colored marker in margin next to block of text +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.de BM +.if t \{\ +.br +.ll -2n +.gcolor red +.di BX +.\} +.. +.de EM +.if t \{\ +.br +.di +.ll +.gcolor +.nr BH \\n(dn +.ne \\n(BHu +\M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[] +.in 0 +.nf +.BX +.in +.fi +.\} +.. +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.SH "NAME" +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "Name" onnode \- run commands on ctdb nodes -.SH "SYNOPSIS" -.HP 24 -\fBonnode NODE COMMAND ...\fR +.SH "Synopsis" +.fam C +.HP \w'\fBonnode\ [OPTION]\ \&.\&.\&.\ NODES\ COMMAND\ \&.\&.\&.\fR\ 'u +\fBonnode [OPTION] \&.\&.\&. NODES COMMAND \&.\&.\&.\fR +.fam .SH "DESCRIPTION" .PP -onnode is a utility to run commands on a specific node of a CTDB cluster, or on all nodes. +onnode is a utility to run commands on a specific node of a CTDB cluster, or on all nodes\&. .PP -The NODE option specifies which node to run a command on. You can specify a numeric node number (from 0 to N\-1) or the special node 'all'. +The NODES option specifies which node to run a command on\&. You can specify a numeric node number (from 0 to N\-1) or the special node \'all\'\&. You can also specify lists of nodes, separated by commas, and ranges of numeric node numbers, separated by dashes\&. If nodes are specified multiple times then the command will be executed multiple times on those nodes\&. The order of nodes is significant\&. .PP -The COMMAND can be any shell command. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command. +The COMMAND can be any shell command\&. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command\&. +.SH "OPTIONS" .PP -If the COMMAND starts with a /, then the command is run via the 'at' service. Otherwise the command is run in the foreground. +\-c +.RS 4 +Execute COMMAND in the current working directory on each node\&. +.RE +.PP +\-p +.RS 4 +Run commands in parallel on the specified nodes\&. In this mode +.RE +.PP +\-q +.RS 4 +Do not print node addresses\&. Normally, onnode prints informational node addresses if more than one node is specified\&. This overrides \-v\&. +.RE +.PP +\-v +.RS 4 +Print a node addresses even if only one node is specified\&. Normally, onnode prints informational node addresses when more than one node is specified\&. +.RE +.PP +\-h, \-\-help +.RS 4 +Show a short usage guide\&. +.RE .SH "EXAMPLES" .PP The following command would show the process ID of ctdb on all nodes .sp +.if n \{\ .RS 4 +.\} +.fam C +.ps -1 .nf -onnode all pidof ctdbd - +.if t \{\ +.sp -1 +.\} +.BB lightgray adjust-for-leading-newline +.sp -1 + + onnode all pidof ctdbd + +.EB lightgray adjust-for-leading-newline +.if t \{\ +.sp 1 +.\} +.fi +.fam +.ps +1 +.if n \{\ +.RE +.\} +.PP +The following command would show the last 5 lines of log on each node, preceded by the node\'s hostname +.sp +.if n \{\ +.RS 4 +.\} +.fam C +.ps -1 +.nf +.if t \{\ +.sp -1 +.\} +.BB lightgray adjust-for-leading-newline +.sp -1 + + onnode all "hostname; tail \-5 /var/log/log\&.ctdb" + +.EB lightgray adjust-for-leading-newline +.if t \{\ +.sp 1 +.\} .fi +.fam +.ps +1 +.if n \{\ .RE +.\} .PP -The following command would show the last 5 lines of log on each node, preceded by the nodes hostname +The following command would restart the ctdb service on all nodes\&. .sp +.if n \{\ .RS 4 +.\} +.fam C +.ps -1 .nf -onnode all "hostname; tail \-5 /var/log/log.ctdb" - +.if t \{\ +.sp -1 +.\} +.BB lightgray adjust-for-leading-newline +.sp -1 + + onnode all service ctdb restart + +.EB lightgray adjust-for-leading-newline +.if t \{\ +.sp 1 +.\} .fi +.fam +.ps +1 +.if n \{\ .RE +.\} .PP -The following command would restart the ctdb service on all nodes. +The following command would run \&./foo in the current working directory, in parallel, on nodes 0, 2, 3 and 4\&. .sp +.if n \{\ .RS 4 +.\} +.fam C +.ps -1 .nf -onnode all service ctdb restart - +.if t \{\ +.sp -1 +.\} +.BB lightgray adjust-for-leading-newline +.sp -1 + + onnode \-c \-p 0,2\-4 \&./foo + +.EB lightgray adjust-for-leading-newline +.if t \{\ +.sp 1 +.\} .fi +.fam +.ps +1 +.if n \{\ +.RE +.\} +.SH "FILES" +.PP +/etc/ctdb/nodes +.RS 4 +Contains a list of each node\'s IP address or hostname\&. +.RE +.PP +/etc/ctdb/onnode\&.conf +.RS 4 +If this file exists it is sourced by onnode\&. The main purpose is to allow the administrator to set $SSH to something other than "ssh"\&. In this case the \-t option is ignored\&. For example, the administrator may choose to use use rsh instead of ssh\&. .RE .SH "SEE ALSO" .PP ctdbd(1), ctdb(1), -\fI\%http://ctdb.samba.org/\fR +\m[blue]\fB\%http://ctdb.samba.org/\fR\m[] .SH "COPYRIGHT/LICENSE" .sp +.if n \{\ .RS 4 +.\} +.fam C +.ps -1 .nf +.if t \{\ +.sp -1 +.\} +.BB lightgray adjust-for-leading-newline +.sp -1 + Copyright (C) Andrew Tridgell 2007 Copyright (C) Ronnie sahlberg 2007 +Copyright (C) Martin Schwenke 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. +your option) any later version\&. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\&. See the GNU +General Public License for more details\&. You should have received a copy of the GNU General Public License -along with this program; if not, see http://www.gnu.org/licenses/. +along with this program; if not, see http://www\&.gnu\&.org/licenses/\&. +.EB lightgray adjust-for-leading-newline +.if t \{\ +.sp 1 +.\} .fi +.fam +.ps +1 +.if n \{\ .RE +.\} diff --git a/ctdb/doc/onnode.1.html b/ctdb/doc/onnode.1.html index 57ddfec37b5..1e9ca3eb7e4 100644 --- a/ctdb/doc/onnode.1.html +++ b/ctdb/doc/onnode.1.html @@ -1,34 +1,65 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>onnode</title><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="onnode.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>onnode — run commands on ctdb nodes</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">onnode NODE COMMAND ...</code> </p></div></div><div class="refsect1" lang="en"><a name="id2490457"></a><h2>DESCRIPTION</h2><p> +<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>onnode</title><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="onnode.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>onnode — run commands on ctdb nodes</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">onnode [OPTION] ... NODES COMMAND ...</code> </p></div></div><div class="refsect1" lang="en"><a name="id2507976"></a><h2>DESCRIPTION</h2><p> onnode is a utility to run commands on a specific node of a CTDB cluster, or on all nodes. </p><p> - The NODE option specifies which node to run a command on. You + The NODES option specifies which node to run a command on. You can specify a numeric node number (from 0 to N-1) or the special - node 'all'. + node 'all'. You can also specify lists of nodes, separated by + commas, and ranges of numeric node numbers, separated by dashes. + If nodes are specified multiple times then the command will be + executed multiple times on those nodes. The order of nodes is + significant. </p><p> The COMMAND can be any shell command. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command. - </p><p> - If the COMMAND starts with a /, then the command is run via the - 'at' service. Otherwise the command is run in the foreground. - </p></div><div class="refsect1" lang="en"><a name="id2487793"></a><h2>EXAMPLES</h2><p> + </p></div><div class="refsect1" lang="en"><a name="id2508002"></a><h2>OPTIONS</h2><div class="variablelist"><dl><dt><span class="term">-c</span></dt><dd><p> + Execute COMMAND in the current working directory on each + node. + </p></dd><dt><span class="term">-p</span></dt><dd><p> + Run commands in parallel on the specified nodes. In this + mode + </p></dd><dt><span class="term">-q</span></dt><dd><p> + Do not print node addresses. Normally, onnode prints + informational node addresses if more than one node is + specified. This overrides -v. + </p></dd><dt><span class="term">-v</span></dt><dd><p> + Print a node addresses even if only one node is specified. + Normally, onnode prints informational node addresses when + more than one node is specified. + </p></dd><dt><span class="term">-h, --help</span></dt><dd><p> + Show a short usage guide. + </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2511603"></a><h2>EXAMPLES</h2><p> The following command would show the process ID of ctdb on all nodes - </p><pre class="screen"> -onnode all pidof ctdbd - </pre><p> + </p><pre class="screen"> + onnode all pidof ctdbd + </pre><p> The following command would show the last 5 lines of log on each - node, preceded by the nodes hostname - </p><pre class="screen"> -onnode all "hostname; tail -5 /var/log/log.ctdb" - </pre><p> + node, preceded by the node's hostname + </p><pre class="screen"> + onnode all "hostname; tail -5 /var/log/log.ctdb" + </pre><p> The following command would restart the ctdb service on all nodes. - </p><pre class="screen"> -onnode all service ctdb restart - </pre></div><div class="refsect1" lang="en"><a name="id2488691"></a><h2>SEE ALSO</h2><p> - ctdbd(1), ctdb(1), <a href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a> - </p></div><div class="refsect1" lang="en"><a name="id2488704"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br> + </p><pre class="screen"> + onnode all service ctdb restart + </pre><p> + The following command would run ./foo in the current working + directory, in parallel, on nodes 0, 2, 3 and 4. + </p><pre class="screen"> + onnode -c -p 0,2-4 ./foo + </pre></div><div class="refsect1" lang="en"><a name="id2511652"></a><h2>FILES</h2><div class="variablelist"><dl><dt><span class="term">/etc/ctdb/nodes</span></dt><dd><p> + Contains a list of each node's IP address or hostname. + </p></dd><dt><span class="term">/etc/ctdb/onnode.conf</span></dt><dd><p> + If this file exists it is sourced by onnode. The main + purpose is to allow the administrator to set $SSH to + something other than "ssh". In this case the -t option is + ignored. For example, the administrator may choose to use + use rsh instead of ssh. + </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2511691"></a><h2>SEE ALSO</h2><p> + ctdbd(1), ctdb(1), <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a> + </p></div><div class="refsect1" lang="en"><a name="id2511704"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br> Copyright (C) Andrew Tridgell 2007<br> Copyright (C) Ronnie sahlberg 2007<br> +Copyright (C) Martin Schwenke 2008<br> <br> This program is free software; you can redistribute it and/or modify<br> it under the terms of the GNU General Public License as published by<br> diff --git a/ctdb/doc/onnode.1.xml b/ctdb/doc/onnode.1.xml index e044e5fc426..7bea709b65d 100644 --- a/ctdb/doc/onnode.1.xml +++ b/ctdb/doc/onnode.1.xml @@ -15,7 +15,7 @@ <refsynopsisdiv> <cmdsynopsis> - <command>onnode NODE COMMAND ...</command> + <command>onnode [OPTION] ... NODES COMMAND ...</command> </cmdsynopsis> </refsynopsisdiv> @@ -25,44 +25,127 @@ cluster, or on all nodes. </para> <para> - The NODE option specifies which node to run a command on. You + The NODES option specifies which node to run a command on. You can specify a numeric node number (from 0 to N-1) or the special - node 'all'. + node 'all'. You can also specify lists of nodes, separated by + commas, and ranges of numeric node numbers, separated by dashes. + If nodes are specified multiple times then the command will be + executed multiple times on those nodes. The order of nodes is + significant. </para> <para> The COMMAND can be any shell command. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command. </para> - <para> - If the COMMAND starts with a /, then the command is run via the - 'at' service. Otherwise the command is run in the foreground. - </para> + </refsect1> + + <refsect1><title>OPTIONS</title> + + <variablelist> + <varlistentry><term>-c</term> + <listitem> + <para> + Execute COMMAND in the current working directory on each + node. + </para> + </listitem> + </varlistentry> + + <varlistentry><term>-p</term> + <listitem> + <para> + Run commands in parallel on the specified nodes. In this + mode + </para> + </listitem> + </varlistentry> + + <varlistentry><term>-q</term> + <listitem> + <para> + Do not print node addresses. Normally, onnode prints + informational node addresses if more than one node is + specified. This overrides -v. + </para> + </listitem> + </varlistentry> + + <varlistentry><term>-v</term> + <listitem> + <para> + Print a node addresses even if only one node is specified. + Normally, onnode prints informational node addresses when + more than one node is specified. + </para> + </listitem> + </varlistentry> + + <varlistentry><term>-h, --help</term> + <listitem> + <para> + Show a short usage guide. + </para> + </listitem> + </varlistentry> + </variablelist> </refsect1> <refsect1><title>EXAMPLES</title> <para> The following command would show the process ID of ctdb on all nodes - </para> - <screen format="linespecific"> -onnode all pidof ctdbd - </screen> + </para> + <screen format="linespecific"> + onnode all pidof ctdbd + </screen> <para> The following command would show the last 5 lines of log on each - node, preceded by the nodes hostname - </para> - <screen format="linespecific"> -onnode all "hostname; tail -5 /var/log/log.ctdb" - </screen> + node, preceded by the node's hostname + </para> + <screen format="linespecific"> + onnode all "hostname; tail -5 /var/log/log.ctdb" + </screen> <para> The following command would restart the ctdb service on all nodes. - </para> - <screen format="linespecific"> -onnode all service ctdb restart - </screen> + </para> + <screen format="linespecific"> + onnode all service ctdb restart + </screen> - </refsect1> + <para> + The following command would run ./foo in the current working + directory, in parallel, on nodes 0, 2, 3 and 4. + </para> + <screen format="linespecific"> + onnode -c -p 0,2-4 ./foo + </screen> + </refsect1> + + <refsect1><title>FILES</title> + + <variablelist> + <varlistentry><term>/etc/ctdb/nodes</term> + <listitem> + <para> + Contains a list of each node's IP address or hostname. + </para> + </listitem> + </varlistentry> + + <varlistentry><term>/etc/ctdb/onnode.conf</term> + <listitem> + <para> + If this file exists it is sourced by onnode. The main + purpose is to allow the administrator to set $SSH to + something other than "ssh". In this case the -t option is + ignored. For example, the administrator may choose to use + use rsh instead of ssh. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> <refsect1><title>SEE ALSO</title> <para> @@ -73,6 +156,7 @@ onnode all service ctdb restart <literallayout> Copyright (C) Andrew Tridgell 2007 Copyright (C) Ronnie sahlberg 2007 +Copyright (C) Martin Schwenke 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode index a94dd1e2656..1e7e24690fa 100755 --- a/ctdb/tools/onnode +++ b/ctdb/tools/onnode @@ -8,6 +8,8 @@ # Based on an earlier script by Andrew Tridgell and Ronnie Sahlberg. +# Copyright (C) Andrew Tridgell 2007 + # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -26,17 +28,14 @@ prog=$(basename $0) usage () { cat >&2 <<EOF -Usage: onnode [ options ] <nodespec> <command> - - Options: +Usage: onnode [OPTION] ... <NODES> <COMMAND> ... + options: -c Run in current working directory on all nodes. -p Run command in parallel on specified nodes. Implies -t. - -t Force tty allocation on nodes. Improves buffering. - -v Print node address even for a single node. -q Do not print node addresses (overrides -v). - - <nodespec> all or a node number (0 base); or - list (comma separated) of <nodespec>; or + -v Print node address even for a single node. + <NODES> "all" or a node number (0 base); or + list (comma separated) of <NODES>; or range (hyphen separated) of node numbers. EOF exit 1 @@ -52,7 +51,6 @@ invalid_nodespec () # Defaults. current=false parallel=false -force_tty=false verbose=false quiet=false @@ -61,7 +59,7 @@ parse_options () # $POSIXLY_CORRECT means that the command passed to onnode can # take options and getopt won't reorder things to make them # options ot onnode. - temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cpqtv" -- "$@") + temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "chpqv" -l help -- "$@") [ $? != 0 ] && usage @@ -70,12 +68,11 @@ parse_options () while true ; do case "$1" in -c) current=true ; shift ;; - -p) parallel=true ; force_tty=true ; shift ;; + -p) parallel=true ; shift ;; -q) quiet=true ; shift ;; - -t) force_tty=true ; shift ;; -v) verbose=true ; shift ;; --) shift ; break ;; - *) usage ;; # Shouldn't happen, so this is reasonable. + -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable. esac done @@ -150,11 +147,7 @@ SSH_OPTS= [ -r /etc/ctdb/onnode.conf ] && . /etc/ctdb/onnode.conf [ -n "$SSH" ] || SSH=ssh if [ "$SSH" = "ssh" ] ; then - if $force_tty ; then - ssh_opts="-t" - else - ssh_opts="-n" - fi + ssh_opts="-n" else : # rsh? All bets are off! fi @@ -179,14 +172,18 @@ trap 'kill -TERM $pids 2>/dev/null' INT TERM # have been added to $pids and the script is interrupted. However, # the part of the window where it matter is very small. for n in $nodes ; do - if $verbose ; then - echo >&2 ; echo ">> NODE: $n <<" >&2 - fi - if $parallel ; then - $SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" & + if $verbose ; then + ($SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" 2>&1 | sed -e "s@^@[$n] @" )& + else + $SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" & + fi pids="${pids} $!" else + if $verbose ; then + echo >&2 ; echo ">> NODE: $n <<" >&2 + fi + $SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" fi done |