调用DescribeInvocationResults查看一条或多条云助手命令的执行结果,即在ECS实例中的实际执行结果。

接口说明

  • 当您执行命令后,不代表命令一定成功执行,并且一定有预期的命令效果。您需要通过本接口查看实际的具体执行结果,以实际输出结果为准。
  • 您可以查询最近4周的执行信息,执行信息的保留上限为10万条。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String DescribeInvocationResults

系统规定参数。取值:DescribeInvocationResults

RegionId String cn-hangzhou

地域ID。您可以调用DescribeRegions查看最新的阿里云地域列表。

ResourceGroupId String rg-bp67acfmxazb4p****

命令执行的资源组ID。传入该参数后,需要在执行命令时指定ResourceGroupId,支持筛选出对应的命令执行结果。

InvokeId String t-hz0jdfwd9f****

命令执行ID。您可以通过接口DescribeInvocations查询InvokeId。

InstanceId String i-bp1i7gg30r52z2em****

实例ID。

CommandId String c-hz0jdfwcsr****

命令ID。

InvokeRecordStatus String Running

命令执行状态。取值范围:

  • Running:运行中。
    • 定时执行:未手动停止定时执行命令前,执行状态一直为进行中。
    • 单次执行:一旦有进行中的命令进程,总的执行状态就为进行中。
  • Finished:已完成。
    • 定时执行:命令进程不可能为执行完成。
    • 单次执行:所有实例全部完成执行。或者手动停止部分实例的命令进程,其余实例全部执行完成。
  • Failed:执行失败。
    • 定时执行:命令进程不可能为执行失败。
    • 单次执行:所有实例全部执行失败。
  • PartialFailed:部分执行失败。
    • 定时执行:命令进程不可能为部分失败。
    • 单次执行:部分实例有执行失败的命令进程,则总执行状态为部分失败。
  • Stopped:命令执行已停止。
  • Stopping:正在停止执行的命令。
IncludeHistory Boolean false

是否返回命令定时执行的历史记录。取值范围:

  • true:表示返回命令定时执行的结果。当取值为true时,参数InvokeId的取值不能为空,且必须为立即执行或系统下一次启动后执行的命令执行ID。
  • false:表示不返回。

默认值为false。

ContentEncoding String PlainText

设置返回数据中CommandContent字段和Output字段的编码方式,取值范围:

  • PlainText:返回原始命令内容和输出信息。
  • Base64:返回Base64编码后的命令内容和输出信息。

默认值为Base64。

PageNumber Long 1

当前页码。

起始值为1。

默认值为1。

PageSize Long 1

分页查询时设置的每页行数。

最大值为50。

默认值为10。

Tag.N.Key String TestKey

命令执行的标签键。N的取值范围为1~20。一旦传入该值,则不允许为空字符串。

使用一个标签过滤资源,查询到该标签下的资源数量不能超过1000个;使用多个标签过滤资源,查询到同时绑定了多个标签的资源数量不能超过1000个。如果资源数量超过1000个,您需要使用ListTagResources接口进行查询。

最多支持64个字符,不能以aliyunacs:开头,不能包含http://https://

Tag.N.Value String TestValue

命令执行的标签值。N的取值范围为1~20。该值可以为空字符串。

最多支持128个字符,不能包含http://https://

返回数据

名称 类型 示例值 描述
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE*****

请求ID。

Invocation Object

命令执行结果的集合。

PageSize Long 1

分页查询时设置的每页行数。

PageNumber Long 1

当前页码。

TotalCount Long 1

命令总个数。

InvocationResults Array of InvocationResult

命令执行结果集。

InvocationResult
InvocationStatus String Success

单台实例的命令进度状态,可能值:

  • Pending:系统正在校验或发送命令。
  • Invalid:指定命令类型或参数有误。
  • Aborted:向实例发送命令失败。实例必须在运行中,且命令可以1分钟内发送完成。
  • Running:命令正在实例上执行。
  • Success:
    • 单次执行的命令:命令执行完成,且退出码为0。
    • 定时执行的命令:上一次执行成功且退出码为0,且指定的执行时间已结束。
  • Failed:
    • 单次执行的命令:命令执行完成,且退出码非0。
    • 定时执行的命令:上一次执行成功且退出码非0,且指定的执行时间将中止。
  • Error:命令执行时发生异常无法继续。
  • Timeout:命令执行超时。
  • Cancelled:命令的执行动作已经取消,命令未曾启动。
  • Stopping:正在停止执行的命令。
  • Terminated:命令执行时被终止。
  • Scheduled:
    • 单次执行的命令:不适用,不会出现。
    • 定时执行的命令:等待执行。
Repeats Integer 0

命令在该实例上执行的次数。

  • 若执行方式为立即执行,则值为0或1。
  • 若执行方式为定时执行,则值为执行过多少次。
CommandId String c-hz0jdfwcsr****

命令ID。

InstanceId String i-bp1i7gg30r52z2em****

实例ID。

Output String MTU6MzA6MDEK

命令执行后的输出信息。

  • 若ContentEncoding指定PlainText,返回原始输出信息。
  • 若ContentEncoding指定Base64,返回Base64编码后的输出信息。
Dropped Integer 0

Output字段中文字长度超出24 KB后,截断并丢弃的文字长度。

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

若调用了StopInvocation以停止命令执行,表示调用的时间。

ExitCode Long 0

命令的退出码。

  • Linux实例为Shell命令的退出码。
  • Windows实例为Bat或者PowerShell命令的退出码。
StartTime String 2019-12-20T06:15:55Z

命令在实例中开始执行的时间。

ErrorInfo String the specified instance does not exists

命令的下发失败或执行失败原因的详情,可能值:

  • 空:命令执行正常。
  • the specified instance does not exists:指定的实例不存在或已释放。
  • 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 exists:指定的账号不存在。
  • the specified directory does not exists:指定的目录不存在。
  • the cron job expression is invalid:指定的执行时间表达式不合法。
  • the aliyun service is not running on the instance:云助手Agent未运行。
  • the aliyun service in the instance does not response:云助手Agent无响应。
  • the aliyun service in the instance is upgrading now:云助手Agent正在升级中。
  • the aliyun service in the instance need upgrade:云助手Agent需要升级。
  • 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:命令执行结束,退出码非0。
  • the specified instance has been released:下发文件期间,该实例被释放。
ErrorCode String InstanceNotExists

命令下发失败或执行失败原因的代码,可能值:

  • 空:命令执行正常。
  • InstanceNotExists:指定的实例不存在或已释放。
  • InstanceReleased:执行命令期间,该实例被释放。
  • InstanceNotRunning:命令执行时,该实例不在运行中。
  • CommandNotApplicable:命令不适用于指定的实例。
  • AccountNotExists:指定的账号不存在。
  • DirectoryNotExists:指定的目录不存在。
  • BadCronExpression:指定的执行时间表达式不合法。
  • ClientNotRunning:云助手Agent未运行。
  • ClientNotResponse:云助手Agent无响应。
  • ClientIsUpgrading:云助手Agent正在升级中。
  • ClientNeedUpgrade:云助手Agent需要升级。
  • DeliveryTimeout:发送命令超时。
  • ExecutionTimeout:命令执行超时。
  • ExecutionException:命令执行发生异常。
  • ExecutionInterrupted:命令执行被中断。
  • ExitCodeNonzero:命令执行结束,退出码非0。
FinishedTime String 2019-12-20T06:15:56Z

命令执行的完成时间。如果命令执行出现超时情况,命令执行的完成时间以StartTime延迟执行命令的超时时间Timeout为准。

InvokeId String t-hz0jdfwd9f****

命令执行ID。

InvokeRecordStatus String Running

命令执行状态。可能值:

  • Running:运行中。
    • 定时执行:未手动停止定时执行命令前,执行状态一直为进行中。
    • 单次执行:一旦有进行中的命令进程,总的执行状态就为进行中。
  • Finished:已完成。
    • 定时执行:命令进程不可能为执行完成。
    • 单次执行:所有实例全部完成执行。或者手动停止部分实例的命令进程,其余实例全部执行完成。
  • Failed:执行失败。
    • 定时执行:命令进程不可能为执行失败。
    • 单次执行:所有实例全部执行失败。
  • PartialFailed:部分执行失败。
    • 定时执行:命令进程不可能为部分失败。
    • 单次执行:部分实例有执行失败的命令进程,则总执行状态为部分失败。
  • Stopped:命令执行已停止。
  • Stopping:正在停止执行的命令。
Username String test

在ECS实例中执行命令的用户名称。

ContainerId String ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****

容器ID。

ContainerName String test-container

容器名称。

Tags Array of Tag

命令执行的标签信息。

Tag
TagKey String owner

命令执行的标签键。

TagValue String zhangsan

命令执行的标签值。

示例

请求示例

http(s)://ecs.aliyuncs.com/?Action=DescribeInvocationResults
&RegionId=cn-hangzhou
&InstanceId=i-bp1i7gg30r52z2em****
&PageNumber=1
&PageSize=1
&公共请求参数

正常返回示例

XML格式

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

<DescribeInvocationResultsResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE*****</RequestId>
    <Invocation>
        <InvocationResults>
            <InvocationResult>
                <Dropped>0</Dropped>
                <InvocationStatus>Success</InvocationStatus>
                <InstanceId>i-bp1i7gg30r52z2em****</InstanceId>
                <ExitCode>0</ExitCode>
                <ErrorInfo>the specified instance does not exists</ErrorInfo>
                <StartTime>2019-12-20T06:15:55Z</StartTime>
                <Repeats>0</Repeats>
                <InvokeRecordStatus>Running</InvokeRecordStatus>
                <FinishedTime>2019-12-20T06:15:56Z</FinishedTime>
                <Output>MTU6MzA6MDEK</Output>
                <CommandId>c-hz0jdfwcsr****</CommandId>
                <ErrorCode>InstanceNotExists</ErrorCode>
                <InvokeId>t-hz0jdfwd9f****</InvokeId>
                <StopTime>2020-01-19T09:15:47Z</StopTime>
                <Username>test</Username>
                <ContainerId>ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****</ContainerId>
                <ContainerName>test-container</ContainerName>
                <Tags>
                    <TagKey>owner</TagKey>
                    <TagValue>zhangsan</TagValue>
                </Tags>
            </InvocationResult>
        </InvocationResults>
        <TotalCount>1</TotalCount>
        <PageSize>1</PageSize>
        <PageNumber>1</PageNumber>
    </Invocation>
</DescribeInvocationResultsResponse>

JSON格式

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

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE*****",
  "Invocation" : {
    "InvocationResults" : {
      "InvocationResult" : [ {
        "Dropped" : 0,
        "InvocationStatus" : "Success",
        "InstanceId" : "i-bp1i7gg30r52z2em****",
        "ExitCode" : 0,
        "ErrorInfo" : "the specified instance does not exists",
        "StartTime" : "2019-12-20T06:15:55Z",
        "Repeats" : 0,
        "InvokeRecordStatus" : "Running",
        "FinishedTime" : "2019-12-20T06:15:56Z",
        "Output" : "MTU6MzA6MDEK",
        "CommandId" : "c-hz0jdfwcsr****",
        "ErrorCode" : "InstanceNotExists",
        "InvokeId" : "t-hz0jdfwd9f****",
        "StopTime" : "2020-01-19T09:15:47Z",
        "Username" : "test",
        "ContainerId" : "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
        "ContainerName" : "test-container",
        "Tags" : [ {
          "TagKey" : "owner",
          "TagValue" : "zhangsan"
        } ]
      } ]
    },
    "TotalCount" : 1,
    "PageSize" : 1,
    "PageNumber" : 1
  }
}

错误码

HttpCode 错误码 错误信息 描述
400 RegionId.ApiNotSupported The api is not supported in this region. 指定地域下不支持调用 API。请检查 RegionId 参数取值是否正确。
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. 标签中存在重复的键,请保持键的唯一性。
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. 指定的标签键参数有误。
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. 指定的标签值参数有误。
400 MissingParameter.TagKey You must specify Tag.N.Key. 请指定标签键。
400 InvalidParam.PageNumber The specified parameter is invalid. 指定的 PageNumber 参数无效。
400 InvalidParam.PageSize The specified parameter is invalid. 指定的 PageSize 参数无效。
403 Operation.Forbidden The operation is not permitted. 该操作是不被允许的。
500 InternalError.Dispatch An error occurred when you dispatched the request. 发送请求时发生错误,请稍后重试。
500 ServiceUnavailable The request has failed due to a temporary failure of the server. 请求后端超时。
500 InternalError The request processing has failed due to some unknown error. 内部错误,请重试。

访问错误中心查看更多错误码。