Sun N1 System Manager 1.1 Administration Guide

Issuing Remote Commands on Servers and Server Groups

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

To issue a remote command on a server or server group, use the start command with the server or group keyword and 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 Server or a Server Group

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

Before You Begin

You must add the OS monitoring feature before you can issue remote commands on servers or server groups. See To Add the OS Monitoring Feature.

Steps
  1. Log in to the N1 System Manager.

    See To Access the N1 System Manager Command Line for details.

  2. Type one of the following commands:


    N1-ok> start server server command "command"
    

    The remote command is issued on the server. See start server in Sun N1 System Manager 1.1 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.1 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 4–17 Issuing a Remote Command on a Server

The following command-line 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 command-line example shows how 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
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 4–18 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, type a value of zero into the command. 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 command-line example shows how 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
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 4–19 Issuing a Remote Command on a Server Group

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


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

Job "24" started.

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


N1-ok> show job 24

Job ID:   24
Date:     2005-02-15T08:31:20-0700
Type:     Remote Command
Status:   Completed
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

See Also

Example 5–12