Run Cloud Assistant common commands

更新时间:
复制 MD 格式

Common commands are predefined Cloud Assistant commands from Alibaba Cloud for various scenarios, such as software installation, instance diagnosis, and key rotation. This topic describes how to view and run common commands.

Background

Created and maintained by Alibaba Cloud, common commands automate complex tasks such as server configuration, health checks, software installation, and system patching. They also include Cloud Assistant plug-ins, which are packages that contain scripts or executable programs.

Alibaba Cloud manages the content, publication, and updates for all common commands. You can view the command details, run them on your ECS instances, and track the execution results. For example, you can upgrade the Cloud Assistant Agent on a Linux instance, install Java, or check whether an instance requires a disk resize. By using common commands, you can simplify complex configurations and significantly improve your O&M efficiency.

Procedure

Use one of the following methods to view and run common commands.

ECS console

  1. Go to ECS console - ECS Cloud Assistant.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. Region

  3. On the ECS Cloud Assistant page, click the Common Commands tab.

    This tab lists the official common commands from Alibaba Cloud.

  4. Find the common command that you want to run and click Run.

    Note

    The Common Commands page displays only the latest version of each command. To view or run a previous version, find the command and click its command ID to go to the details page.

  5. In the Run Command panel, configure the parameters and click Run.

    The following table describes the main parameters.

    Section

    Parameter

    Description

    Command Information

    Command content

    Click View command content to review the script.

    Execution plan

    Select when to run the command. Valid values:

    • Immediate execution

    • After the next startup of the system

    • After each system startup

    • Timing execution

    For more information about execution plans, see execution plan details.

    Execution user

    The user that runs the command on the ECS instance, for example, root.

    By default, commands are run as the root user on Linux instances and as the System user on Windows instances.

    Timeout

    The timeout in seconds, which must be an integer between 10 and 86,400. If a command exceeds this timeout, it is forcibly terminated. The default is the timeout defined in the command.

    Command parameters

    If this section appears, enter the custom parameter values. The parameters displayed vary based on the command.

    Note

    If the command provider offers descriptions, default values, or allowed values, enter the parameters as prompted. If a parameter is required, you must enter a value to run the command.

    Select Instances

    -

    Select one or more instances on which to run the command. The instances must be in the Running state and have the Cloud Assistant Agent installed.

    Select Managed Instances

    -

    Select the managed instances on which to run the command. The instances must be in the Connected state and have the Cloud Assistant Agent installed.

    Note

    A managed instance is a non-Alibaba Cloud server managed by Cloud Assistant. For more information, see Managed instances.

    Note

    For more information about the parameters for running a command, see Run a command in the ECS console.

  6. On the Command execution result tab, find the successful execution record and click View in the Actions column.

    On the execution details page, if the execution status of the instance is Successfully Executed, you can view the output of the common command.执行结果

    Note

    If a command fails to run, check the error message and fix the issue based on the diagnostic information. For more information, see Common errors and solutions for failed executions.

OpenAPI

  1. View common commands.

    Call the DescribeCommands API operation to view common commands. You can also query for commands by name.

    When you view common commands, take note of the following parameters:

    • Name: The name of the command. For example, to view the common command ACS-ECS-DiskResize-Diagnostic-for-linux.sh in the China (Hangzhou) region, set the name to ACS-ECS-DiskResize-Diagnostic-for-linux.sh.

    • Provider: The provider of the common command. Set this to AlibabaCloud to query for all common commands provided by Alibaba Cloud.

  2. Run a common command.

    You can execute a Cloud Assistant common command by calling InvokeCommand with the CommandId parameter value returned in step 1 above, or by directly using the command name. The names of common commands are the same across different regions.

    When you run a common command, take note of the following parameter:

    CommandId: The ID of the command. For common commands, you can set this parameter to the command name to run the command. In this example, the value is ACS-ECS-DiskResize-Diagnostic-for-linux.sh.

    A successful call returns the InvokeId parameter, such as t-hz02kwqc9pg****, which is the ID of the command execution. You can then call the DescribeInvocations or DescribeInvocationResults operation to query the execution results.

    You can also view the detailed output on the execution details page in the console to check, for example, whether the Linux instance in this example requires a disk resize.

CLI

  1. View common commands by using Alibaba Cloud CLI.

    You can call the DescribeCommands operation to view common commands.

    • When the Provider parameter is set to AlibabaCloud, this indicates that all common commands provided by Alibaba Cloud are queried.

    • If this parameter is set to a specific provider, all common commands from that provider are queried.

      The following example shows how to query all common commands provided by Alibaba Cloud in the China (Hangzhou) region:

      aliyun ecs DescribeCommands \
      --region 'cn-hangzhou' \
      --RegionId 'cn-hangzhou' \
      --Provider 'AlibabaCloud'

      The following example shows how to query the common command ACS-ECS-DiskResize-Diagnostic-for-linux.sh in the China (Hangzhou) region. You can use this command to diagnose whether a Linux instance requires a disk resize.

      aliyun ecs DescribeCommands \
      --region 'cn-hangzhou' \
      --RegionId 'cn-hangzhou' \
      --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh'
  2. Run a common command by using Alibaba Cloud CLI.

    Call the InvokeCommand operation to run a Cloud Assistant common command on one or more ECS instances.

    For example, the common command ACS-ECS-DiskResize-Diagnostic-for-linux.sh is used to diagnose whether a Linux instance requires a disk resize operation. The following is an example:

    aliyun ecs InvokeCommand --RegionId 'cn-hangzhou' \
    --InstanceId.1 'i-bp1f4f6o8lv0wqof****' \
    --InstanceId.2 'i-bp137qu6142s3mhm****' \
    --CommandId 'ACS-ECS-DiskResize-Diagnostic-for-linux.sh' \
    --Timed 'false'

    After a successful call, you will obtain a return parameter named InvokeId (for example, t-hz03rj5u0jx****), which is the execution ID of the common command. You can call the DescribeInvocations or DescribeInvocationResults operation to query the execution results of the Cloud Assistant command. The following is an example:

    aliyun ecs DescribeInvocations --RegionId 'cn-hangzhou' \
    --InvokeId 't-hz03rj5u0jx****'

    You can also view the detailed output on the execution details page in the console to check, for example, whether the Linux instance in this example requires a disk resize.