IBM Books

Administration Guide


Using dsh to run parallel management commands

You can use the PSSP dsh command from a single point of control to execute commands on:

You do not have to limit the target nodes to those nodes on your SP system. |The dsh command uses the remote command process named and |enabled by the RCMD_PGM and the DSH_REMOTE_CMD environment variables as |explained below. The dsh command can execute commands on any |host in your network to which you can issue remote commands. Using dsh rather than an rsh loop offers better performance because the commands can run concurrently.

Note:
|The -a and -aG option defaults to using the |initial_hostname attribute from the SDR. If the HN_METHOD environment |variable is set to reliable (export HN_METHOD=reliable), the reliable_hostname |attribute will be used from the SDR. |

|PSSP 3.4 supports three environment variables to let you pick |whether you want the PSSP software to use AIX rsh and |rcp remote commands or a secure remote command process for parallel |commands like dsh, pcp, and others. The following are the environment |variables and how to use them: |

|RCMD_PGM
|Enable use of the executables named by the DSH_REMOTE_CMD and |REMOTE_COPY_CMD environment variables. The default is |rsh. Set to secrshell to enable a secure remote |command process.

|DSH_REMOTE_CMD
|Specify the path and name of the remote command executable. The |default with rsh is /bin/rsh. The default with |secrshell is /bin/ssh.

|REMOTE_COPY_CMD
|Specify the path and name of the remote copy command executable. |The default with rsh is /bin/rcp. The default |with secrshell is /bin/scp. |

|Like the restricted root access option, a secure remote command process |can also be enabled by using the SP Site environment SMIT menu or |the spsitenv command. It is extremely important to keep |these environment variables consistent and set to the remote command process |you want to use. See Secure remote command process for more information.

Specifying input to dsh

The dsh command provides several ways for you to specify input:

  1. dsh reads lines from standard input and executes each line as a command |by the remote command process enabled with the RCMD_PGM and the |DSH_REMOTE_CMD environment variables. Specify commands in rsh syntax. Pipes, filters, output redirection, and paths can be used on the remote nodes in the same way they are used in rsh.

    The following dsh command targets three nodes, reads commands from stdin, and filters the output of the ps command remotely:

    $ dsh -w host1,host2,host3
    dsh> ps -ef "|" grep root
    
    Note:
    Any input line beginning with an exclamation point is passed directly to the shell on the local host.
  2. dsh accepts commands specified on the command line. For example, to issue the ps command on three nodes and filter the results remotely, specify:
    dsh -w host1,host2,host3 ps -ef "|" grep root
    

Targeting nodes for dsh

The dsh command sends the included commands to a node set called the working collective. The dsh process assembles the working collective from the first existence of one of these sources:

  1. A list of hostnames you specify on the command line with the -a, -G, -w, -N flags.
  2. The contents of a file you specify in the WCOLL environment variable.

If neither of these exist, an error has occurred and no commands are issued.

You can have commands run on the working collective concurrently or in sequence. Default processing is done concurrently, but you can specify a maximum number of nodes for concurrent execution to prevent system degradation. When this maximum number, or fan out is reached, results from outstanding |remote commands are awaited before any further commands are run. These results are displayed as soon as they return from the remotely executed commands.

This example specifies a maximum of 8 concurrent commands even though the working collective is defined as the entire system partition.

dsh -f 8 -a  cat /var/adm/SPlogs/sysman/"*"config.log"*" | pg

Note:
Because dsh starts processes for each host in the working collective, there might be cases where a smaller fan out will result in less contention for resources on the local machine, and thus better overall performance, than the greater concurrence of a larger fan out.

Output from dsh

The dsh process displays information, that returned from the commands, grouped by hostname. The stdout data of the remotely executed commands goes to the stdout of the dsh command. The stderr of remotely executed commands goes to the stderr of the dsh command.

All lines of data in the dsh command stderr and stdout results are prefixed by the name of the host that sent them. You can format dsh stderr and stdout lines by piping them to the dshbak command, which strips off the hostnames and displays the lines grouped by host in alphabetic sequence, as shown in this example:

dsh -w host1,host2,host3 cat /etc/passwd 2>&1 | dshbak

Another example follows using a group of nodes:

dsh -N bis_nodes cat /etc/bootptab 2>&1 | dshbak

Alternatively, the dshbak command can be specified with the -c option. This causes any identical output from two or more nodes to be shown only once, with the hostnames displayed above the output. Remember, however, that the most efficient way to filter large amounts of output from parallel commands is to filter on the nodes before the output is returned to the workstation from which the parallel command was issued.

Error handling

No special error recovery is provided for the dsh command on remote hosts. If dsh finds that a node in the working collective is down, no further commands will be sent to that node unless you specify the -c (continue) flag on the command line. If hosts are down, the underlying |remote command will time out in approximately 2.5 minutes.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]