All Products
Search
Document Center

Elastic Compute Service:DescribeInvocations

Last Updated:Nov 29, 2023

Queries the list of tasks and execution status of Cloud Assistant commands.

Usage notes

  • After you run a command, the command may not succeed or return the expected results. You can call this operation to query the execution results.
  • You can query the information about command tasks within the last four weeks. Up to 100,000 pieces of task information can be retained.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action String Yes DescribeInvocations

The operation that you want to perform. Set the value to DescribeInvocations.

RegionId String Yes cn-hangzhou

The region ID of the command. You can call the DescribeRegions operation to query the most recent region list.

ResourceGroupId String No rg-bp67acfmxazb4p****

The ID of the resource group. After you set this parameter, command execution results in the specified resource group are queried.

InvokeId String No t-hz0jdfwd9f****

The ID of the command task.

CommandId String No c-hz0jdfwcsr****

The ID of the command. You can call the DescribeCommands operation to query all available command IDs.

CommandName String No CommandTestName

The name of the command. If this parameter and InstanceId are both specified, this parameter does not take effect.

CommandType String No RunShellScript

The type of the command. Valid values:

  • RunBatScript: batch command, applicable to Windows instances
  • RunPowerShellScript: PowerShell command, applicable to Windows instances
  • RunShellScript: shell command, applicable to Linux instances
Timed Boolean No true

Specifies whether the command is to be automatically run. Valid values:

  • true: The command is run by calling the RunCommand or InvokeCommand operation with RepeatMode set to Period, NextRebootOnly, or EveryReboot.
  • false: The command meets the following requirements:
    • The command is run by calling the RunCommand or InvokeCommand operation with RepeatMode set to Once.
    • The command has tasks that are canceled, stopped, or completed.

Default value: false.

InvokeStatus String No Finished

The overall execution status of the command task. The value of this parameter depends on the execution states on all involved instances. Valid values:

  • Running:
    • Scheduled task: Before you manually stop the scheduled execution of the command, the overall execution state is always Running.
    • One-time task: If the command is being run on instances, the overall execution state is Running.
  • Finished:
    • Scheduled task: The overall execution state can never be Finished.
    • One-time task: The execution is complete on all instances. or the execution is manually stopped on some instances and is complete on the other instances.
  • Success: If the execution state on at least one instance is Success and the execution state on the other instances is Stopped or Success, the overall execution state is Success.
    • Task that is set to run immediately: The execution is complete, and the exit code is 0.
    • Scheduled task: The last execution was completed, and the exit code was 0. The specified period ended.
  • Failed:
    • Scheduled task: The overall execution state can never be Failed.
    • One-time task: The execution fails on all instances.
  • Stopped: The task is stopped.
  • Stopping: The task is being stopped.
  • PartialFailed: The task fails on some instances. If InstanceId is specified, InvokeStatus does not take effect.
InstanceId String No i-bp1i7gg30r52z2em****

The ID of the instance. When you specify this parameter, the system queries all execution records of all commands that run on the instance.

ContentEncoding String No PlainText

The encoding mode of the CommandContent and Output values in the response. Valid values:

  • PlainText: returns the original command content and command outputs.
  • Base64: returns the Base64-encoded command content and command outputs.

Default value: Base64.

IncludeOutput Boolean No false

Specifies whether to return the command outputs in the response.

  • true: returns the command outputs. When this parameter is set to true, you must specify InvokeId, InstanceId, or both.
  • false: does not return the command outputs.

Default value: false.

PageNumber Long No 1

The page number.

Pages start from page 1.

Default value: 1.

PageSize Long No 10

The number of entries per page.

Valid values: 1 to 50.

Default value: 10.

RepeatMode String No Once

The execution mode of the command. If this parameter and InstanceId are both specified, this parameter does not take effect. Valid values:

  • Once: The command is immediately run.
  • Period: The command is run on a schedule.
  • NextRebootOnly: The command is run the next time the instance starts.
  • EveryReboot: The command is run every time the instance starts.

This parameter is empty by default, which indicates that commands run in all modes are queried.

Tag.N.Key String No TestKey

The key of tag N of the command task. Valid values of N: 1 to 20. The tag key cannot be an empty string.

If you specify a single tag to query resources, up to 1,000 resources to which the tag is added are returned. If you specify multiple tags to query resources, up to 1,000 resources to which all specified tags are added are returned. To query more than 1,000 resources to which the specified tags are added, call the ListTagResources operation.

The tag key can be up to 64 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.

Tag.N.Value String No TestValue

The value of tag N of the command task. Valid values of N: 1 to 20. The tag value can be an empty string.

The tag value can be up to 128 characters in length and cannot contain http:// or https://.

Response parameters

Parameter

Type

Example

Description

PageSize Long 10

The number of entries per page.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

PageNumber Long 1

The page number.

TotalCount Long 1

The total number of commands.

Invocations Array of Invocation

The queried command tasks.

Invocation
CreationTime String 2020-01-19T09:15:46Z

The time when the command task was created.

Frequency String 0 */20 * * * *

The schedule on which the command is run.

InvocationStatus String Running

The overall execution status of the command task. The value of this parameter depends on the execution states on all the involved instances. Valid values:

  • Pending: The command was being verified or sent. If the execution state is Pending on at least one instance, the overall execution state is Pending.
  • Scheduled: The command that is set to run on a schedule was sent and waiting to be run. If the execution state is Scheduled on at least one instance, the overall execution state is Scheduled.
  • Running: The command was being run on the instances. If the execution state is Running on at least one instance, the overall execution state is Running.
  • Success: If the execution state on at least one instance is Success and the execution state on the other instances is Stopped or Success, the overall execution state is Success.
    • Task that is set to run immediately: The command task was completed, and the exit code was 0.
    • Scheduled task: The last execution was completed, and the exit code was 0. The specified period ended.
  • Failed: If the execution state on all instances is Stopped or Failed, the overall execution state is Failed. If the execution state on an instance is one of the following values, Failed is returned as the overall execution state:
    • Invalid: The command is invalid.
    • Aborted: The command failed to be sent.
    • Failed: The command task was completed, but the exit code was not 0.
    • Timeout: The execution timed out.
    • Error: An error occurred when the command was being run.
  • Stopping: The command task was being stopped. If the execution state of at least one instance is Stopping, the overall execution state is Stopping.
  • Stopped: The command task was stopped. If the execution state on all instances is Stopped, the overall execution state is Stopped. If the execution state on an instance is one of the following values, Stopped is returned as the overall execution state:
    • Cancelled: The command task was canceled.
    • Terminated: The command task was terminated.
  • PartialFailed: The command task succeeded on some instances and failed on other instances. When the execution state is Success on some instances and is Failed or Stopped on the other instances, the overall execution state is PartialFailed.
Note InvokeStatus in the response functions similarly to this parameter. We recommend that you check the value of this parameter.
RepeatMode String Once

The execution mode of the command. Valid values:

  • Once: The command is immediately run.
  • Period: The command is run on a schedule.
  • NextRebootOnly: The command is run the next time the instance starts.
  • EveryReboot: The command is run every time the instance starts.
CommandId String c-hz0jdfwcsr****

The ID of the command.

CommandType String RunShellScript

The type of the command.

InvokeStatus String Finished

The overall execution status of the command task.

Note We recommend that you ignore this parameter and check the value of InvocationStatus in the response for the overall execution state.
Parameters String {}

The custom parameters in the command.

Timed Boolean false

Indicates whether the command is to be automatically run.

CommandContent String cnBtIC1xYSB8IGdyZXAgdnNm****

The content of the command.

  • If ContentEncoding is set to PlainText in the request, the original command content is returned.
  • If ContentEncoding is set to Base64 in the request, the Base64-encoded command content is returned.
CommandName String CommandTestName

The name of the command.

CommandDescription String testDescription

The description of the command.

InvokeId String t-hz0jdfwd9f****

The ID of the command task.

Username String test

The username that was used to run the command on the instance.

WorkingDir String /home/

The execution path of the command.

Timeout Long 60

The maximum timeout period for command executions on the instance. Unit: seconds.

When a command cannot be run, a timeout error occurs. When a command execution times out, Cloud Assistant Agent forcefully terminates the command process by canceling the process ID (PID).

ContainerId String ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****

The ID of the container.

ContainerName String test-container

The name of the container.

InvokeInstances Array of InvokeInstance

The instances on which the command was run.

InvokeInstance
CreationTime String 2019-12-20T06:15:54Z

The time when the command started to run on the instance.

UpdateTime String 2020-01-19T09:15:47Z

The time when the execution status was updated.

FinishTime String 2019-12-20T06:15:56Z

The time when the command process ended.

InvocationStatus String Success

The execution state on a single instance. Valid values:

  • Pending: The command was being verified or sent.
  • Invalid: The specified command type or parameter was invalid.
  • Aborted: The command failed to be sent. To send a command to an instance, make sure that the instance is in the Running state and the command can be sent within 1 minute.
  • Running: The command was being run on the instance.
  • Success:
    • Command that is set to run only once: The execution was complete, and the exit code was 0.
    • Command that is set to run on a schedule: The previous execution was complete, and the exit code was 0. The specified period ended.
  • Failed:
    • Command that is set to run only once: The execution was complete, but the exit code was not 0.
    • Command that is set to run on a schedule: The previous execution was complete, but the exit code was not 0. The specified period was about to end.
  • Error: The execution cannot proceed due to an exception.
  • Timeout: The execution timed out.
  • Cancelled: The execution was canceled, and the command was not run.
  • Stopping: The command task was being stopped.
  • Terminated: The execution was terminated while the command was being run.
  • Scheduled:
    • Command that is set to run only once: The overall execution state can never be Scheduled.
    • Command that is set to run on a schedule: The command was waiting to be run.
Repeats Integer 0

The number of times that the command was run on the instance.

  • If the command is set to run only once, the value is 0 or 1.
  • If the command is set to run on a schedule, the value is the number of times that the command was run.
InstanceId String i-bp1i7gg30r52z2em****

The ID of the instance.

Output String OutPutTestmsg

The command output.

  • If ContentEncoding is set to PlainText in the request, the original command output is returned.
  • If ContentEncoding is set to Base64 in the request, the Base64-encoded command output is returned.
Dropped Integer 0

The size of the Output text that is truncated and discarded when the Output value exceeds 24 KB in size.

StopTime String 2020-01-19T09:15:47Z

The time when the command task was stopped. If you call the StopInvocation operation to stop the command task, the value of this parameter is the time when the operation is called.

ExitCode Long 0

The exit code of the execution. Valid values:

  • For Linux instances, the exit code is the exit code of the shell process.
  • For Windows instances, the exit code is the exit code of the batch or PowerShell process.
StartTime String 2019-12-20T06:15:55Z

The time when the command started to be run on the instance.

ErrorInfo String the specified instance does not exists

The reason why the command failed to be sent or run. Valid values:

  • If this parameter is empty, the command was run normally.
  • the specified instance does not exist
  • the instance has released when create task
  • the instance is not running when create task
  • the command is not applicable
  • the specified account does not exist
  • the specified directory does not exist
  • the cron job expression is invalid
  • the aliyun service is not running on the instance
  • the aliyun service in the instance does not response
  • the aliyun service in the instance is upgrading now
  • the aliyun service in the instance need upgrade
  • the command delivery has been timeout
  • the command execution has been timeout
  • the command execution got an exception
  • the command execution has been interrupted
  • the command execution exit code is not zero
  • the specified instance has been released
Timed Boolean false

Indicates whether the command is to be automatically run.

ErrorCode String InstanceNotExists

The code that indicates why the command failed to be sent or run. Valid values:

  • If this parameter is empty, the command was run normally.
  • InstanceNotExists: The instance did not exist or was released.
  • InstanceReleased: The instance was released while the command was being run.
  • InstanceNotRunning: The instance was not running when the command started to be run.
  • CommandNotApplicable: The command was not applicable to the specified instance.
  • AccountNotExists: The specified account did not exist.
  • DirectoryNotExists: The specified directory did not exist.
  • BadCronExpression: The cron expression used to specify a schedule was invalid.
  • ClientNotRunning: Cloud Assistant Agent was not running.
  • ClientNotResponse: Cloud Assistant Agent did not respond.
  • ClientIsUpgrading: Cloud Assistant Agent was being upgraded.
  • ClientNeedUpgrade: Cloud Assistant Agent must be upgraded.
  • DeliveryTimeout: The request to send the command timed out.
  • ExecutionTimeout: The execution timed out.
  • ExecutionException: An exception occurred while the command was being run.
  • ExecutionInterrupted: The command task was interrupted.
  • ExitCodeNonzero: The command task was completed, but the exit code was not 0.
InstanceInvokeStatus String Finished

The execution state on a single instance.

Note We recommend that you ignore this parameter and check the value of InvocationStatus in the response for the overall execution state.
Tags Array of Tag

The tags of the command task.

Tag
TagKey String owner

The tag key of the command task.

TagValue String zhangsan

The tag value of the command task.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=DescribeInvocations
&RegionId=cn-hangzhou
&InvokeId=t-hz0jdfwd9f****
&CommandId=c-hz0jdfwcsr****
&CommandName=CommandTestName
&CommandType=RunShellScript
&Timed=true
&InvokeStatus=Finished
&InstanceId=i-bp1i7gg30r52z2em****
&PageNumber=1
&PageSize=10
&RepeatMode=Once
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeInvocationsResponse>
    <PageSize>10</PageSize>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
    <PageNumber>1</PageNumber>
    <TotalCount>1</TotalCount>
    <Invocations>
        <Invocation>
            <CreationTime>2020-01-19T09:15:46Z</CreationTime>
            <Frequency>0 */20 * * * *</Frequency>
            <InvocationStatus>Running</InvocationStatus>
            <RepeatMode>Once</RepeatMode>
            <CommandId>c-hz0jdfwcsr****</CommandId>
            <CommandType>RunShellScript</CommandType>
            <InvokeStatus>Finished</InvokeStatus>
            <Parameters>{}</Parameters>
            <Timed>false</Timed>
            <CommandContent>cnBtIC1xYSB8IGdyZXAgdnNm****</CommandContent>
            <CommandName>CommandTestName</CommandName>
            <CommandDescription>testDescription</CommandDescription>
            <InvokeId>t-hz0jdfwd9f****</InvokeId>
            <Username>test</Username>
            <WorkingDir>/home/</WorkingDir>
            <Timeout>60</Timeout>
            <ContainerId>ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****</ContainerId>
            <ContainerName>test-container</ContainerName>
            <InvokeInstances>
                <InvokeInstance>
                    <CreationTime>2019-12-20T06:15:54Z</CreationTime>
                    <UpdateTime>2020-01-19T09:15:47Z</UpdateTime>
                    <FinishTime>2019-12-20T06:15:56Z</FinishTime>
                    <InvocationStatus>Success</InvocationStatus>
                    <Repeats>0</Repeats>
                    <InstanceId>i-bp1i7gg30r52z2em****</InstanceId>
                    <Output>OutPutTestmsg</Output>
                    <Dropped>0</Dropped>
                    <StopTime>2020-01-19T09:15:47Z</StopTime>
                    <ExitCode>0</ExitCode>
                    <StartTime>2019-12-20T06:15:55Z</StartTime>
                    <ErrorInfo>the specified instance does not exists</ErrorInfo>
                    <Timed>false</Timed>
                    <ErrorCode>InstanceNotExists</ErrorCode>
                    <InstanceInvokeStatus>Finished</InstanceInvokeStatus>
                </InvokeInstance>
                <Tags>
                    <TagKey>owner</TagKey>
                    <TagValue>zhangsan</TagValue>
                </Tags>
            </InvokeInstances>
        </Invocation>
    </Invocations>
</DescribeInvocationsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "PageSize" : 10,
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "PageNumber" : 1,
  "TotalCount" : 1,
  "Invocations" : {
    "Invocation" : [ {
      "CreationTime" : "2020-01-19T09:15:46Z",
      "Frequency" : "0 */20 * * * *",
      "InvocationStatus" : "Running",
      "RepeatMode" : "Once",
      "CommandId" : "c-hz0jdfwcsr****",
      "CommandType" : "RunShellScript",
      "InvokeStatus" : "Finished",
      "Parameters" : "{}",
      "Timed" : false,
      "CommandContent" : "cnBtIC1xYSB8IGdyZXAgdnNm****",
      "CommandName" : "CommandTestName",
      "CommandDescription" : "testDescription",
      "InvokeId" : "t-hz0jdfwd9f****",
      "Username" : "test",
      "WorkingDir" : "/home/",
      "Timeout" : 60,
      "ContainerId" : "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
      "ContainerName" : "test-container",
      "InvokeInstances" : {
        "InvokeInstance" : [ {
          "CreationTime" : "2019-12-20T06:15:54Z",
          "UpdateTime" : "2020-01-19T09:15:47Z",
          "FinishTime" : "2019-12-20T06:15:56Z",
          "InvocationStatus" : "Success",
          "Repeats" : 0,
          "InstanceId" : "i-bp1i7gg30r52z2em****",
          "Output" : "OutPutTestmsg",
          "Dropped" : 0,
          "StopTime" : "2020-01-19T09:15:47Z",
          "ExitCode" : 0,
          "StartTime" : "2019-12-20T06:15:55Z",
          "ErrorInfo" : "the specified instance does not exists",
          "Timed" : false,
          "ErrorCode" : "InstanceNotExists",
          "InstanceInvokeStatus" : "Finished"
        } ],
        "Tags" : [ {
          "TagKey" : "owner",
          "TagValue" : "zhangsan"
        } ]
      }
    } ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 RegionId.ApiNotSupported The api is not supported in this region. This operation cannot be performed in the specified region. Check whether the value of the RegionId parameter is valid.
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. The tag key already exists. Tag keys must be unique.
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. Invalid Tag.N.Key value.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. Invalid Tag.N.Value value.
400 MissingParameter.TagKey You must specify Tag.N.Key. Tag.N.Key is required.
400 InvalidParam.PageNumber The specified parameter is invalid. Invalid PageNumber value.
400 InvalidParam.PageSize The specified parameter is invalid. Invalid PageSize value.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
500 InternalError.Dispatch An error occurred when you dispatched the request. An error occurred when the request was being sent. Try again later.

For a list of error codes, see Service error codes.