Sun N1 System Manager 1.3 Discovery and Administration Guide

Issuing Remote Commands on Servers and Server Groups

This section describes how to issue remote commands on managed server and groups.

To issue a remote command on a managed server or group, use the start server or start group command with the command subcommand. For syntax and parameter details, type help start server or help start group at the N1–ok command line.

ProcedureTo Issue Remote Commands on a Managed Server or a Group

This procedure describes how to issue a remote command. A remote command is a UNIX command that is sent to a managed server to be run on that managed server.

Before You Begin

You must add the base management feature before you can issue remote commands on servers or server groups. See Adding and Upgrading Base Management and OS Monitoring Features for details.

Steps
  1. Log in to the N1 System Manager.

  2. Use one of the following commands:


    N1-ok> start server server command "command"
    

    The remote command is issued on the managed server. See start server in Sun N1 System Manager 1.3 Command Line Reference Manual for details.


    N1-ok> start group group command "command"
    

    The remote command is issued on the group. See start group in Sun N1 System Manager 1.3 Command Line Reference Manual for details.

  3. View the Remote Command job.


    N1-ok> show job job
    

    The Remote Command output appears in the Results section.


Example 5–20 Issuing a Remote Command on a Managed Server

The following example shows how to issue a remote command on a server by using the start command.


N1-ok> start server hdco25 command "/bin/ls -l /"

Job "23" started.

The following example shows how to view the results of the remote command by using the show command.


N1-ok> show job 23

Job ID:   23
Date:     2005-02-15T08:31:20-0700
Type:     Remote Command
Status:   Completed
Command:  start server hdco25 command "/bin/ls -l /"
Owner:    root
Errors:   0
Warnings: 0

Step 1:     
Type:        103
Description: native procedure /bin/sh /opt/sun/n1gc/bin/remotecmd.sh
:[RCMD_KEY]
Start:       2005-02-15T08:31:22-0700
Completion:  2005-02-15T08:31:26-0700
Result:      Complete
Exception:   No Data Available

.
.
.

Result :        
Server:          hdco25
Status:          0
Message:         Command executed successfully. Command: /bin/ls -l /
Standard Output: total 321
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 bin -> ./usr/bin
drwxr-xr-x   4 root     sys          512 Feb 11 13:25 boot
drwxr-xr-x   3 root     sys          512 Feb 11 14:27 cr
drwxr-xr-x  15 root     sys         4096 Feb 11 14:09 dev
drwxr-xr-x   5 root     sys          512 Feb 11 14:06 devices
drwxr-xr-x  58 root     root        4096 Feb 14 12:36 etc
drwxr-xr-x   2 root     sys          512 Feb 11 13:46 export
dr-xr-xr-x   1 root     root           1 Feb 11 14:11 home
drwxr-xr-x  12 root     sys          512 Feb 11 13:25 kernel
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 lib -> ./usr/lib


Example 5–21 Issuing a Remote Command With a Timeout

Timeouts are measured in seconds. The default timeout is two hours. If you want to turn the timeout off, use a value of zero seconds. The following example shows how to issue a remote command with a timeout that is set to 20 seconds.


N1-ok> start server hdco25 command "/root/sleep.sh 60" timeout 20

Job "10" started.

The following example shows how to view the results of the remote command by using the show command.


N1-ok> show job 10

Job ID:   10
Date:     2005-02-15T16:46:45-0700
Type:     Remote Command
Status:   Completed
Command:  start server hdco25 command "/root/sleep.sh 60" timeout 20
Owner:    root
Errors:   0
Warnings: 0

Step 1:     
Type:        103
Description: native procedure /bin/sh /opt/sun/n1gc/bin/remotecmd.sh
:[RCMD_KEY]
Start:       2005-02-15T16:46:48-0700
Completion:  2005-02-15T16:47:10-0700
Result:      Complete
Exception:   No Data Available
.
.
.
Result:        
Server:          hdco25
Status:          -2
Message:         Command running on hdco25 did not finish within the
specified time limit of 20 seconds. Command: /root/sleep.sh 60
Standard Output: Sleeping for 60 seconds...


Example 5–22 Issuing a Remote Command on a Group

The following example shows how to issue a remote command on a server group by using the start group command.


N1-ok> start group g1 command "/bin/ls -l /"

Job "24" started.

The following example shows how view the results of the remote command by using the show job command.


N1-ok> show job 24

Job ID:   24
Date:     2005-02-15T08:31:20-0700
Type:     Remote Command
Status:   Completed
Command:	 start group g1 command "/bin/ls -l /"
Owner:    root
Errors:   0
Warnings: 0

Step 1:     
Type:        103
Description: native procedure /bin/sh /opt/sun/n1gc/bin/remotecmd.sh
:[RCMD_KEY]
Start:       2005-02-15T08:31:22-0700
Completion:  2005-02-15T08:31:26-0700
Result:      Complete
Exception:   No Data Available

.
.
.

Result :        
Server:          server1
Status:          0
Message:         Command executed successfully. Command: /bin/ls -l /
Standard Output: total 321
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 bin -> ./usr/bin
drwxr-xr-x   4 root     sys          512 Feb 11 13:25 boot
drwxr-xr-x   3 root     sys          512 Feb 11 14:27 cr
drwxr-xr-x  15 root     sys         4096 Feb 11 14:09 dev
drwxr-xr-x   5 root     sys          512 Feb 11 14:06 devices
drwxr-xr-x  58 root     root        4096 Feb 14 12:36 etc
drwxr-xr-x   2 root     sys          512 Feb 11 13:46 export
dr-xr-xr-x   1 root     root           1 Feb 11 14:11 home
drwxr-xr-x  12 root     sys          512 Feb 11 13:25 kernel
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 lib -> ./usr/lib
Server:          server2
Status:          0
Message:         Command executed successfully. Command: /bin/ls -l /
Standard Output: total 321
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 bin -> ./usr/bin
drwxr-xr-x   4 root     sys          512 Feb 11 13:25 boot
drwxr-xr-x   3 root     sys          512 Feb 11 14:27 cr
drwxr-xr-x  15 root     sys         4096 Feb 11 14:09 dev
drwxr-xr-x   5 root     sys          512 Feb 11 14:06 devices
drwxr-xr-x  58 root     root        4096 Feb 14 12:36 etc
drwxr-xr-x   2 root     sys          512 Feb 11 13:46 export
dr-xr-xr-x   1 root     root           1 Feb 11 14:11 home
drwxr-xr-x  12 root     sys          512 Feb 11 13:25 kernel
lrwxrwxrwx   1 root     root           9 Feb 11 13:21 lib -> ./usr/lib