

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 檢視會影響 Amazon EC2 執行個體的排程事件
<a name="viewing_scheduled_events"></a>

除了在電子郵件中接收排程事件的通知，您可以檢查排程事件。

------
#### [ Console ]

**檢視執行個體的排程事件**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 儀表板會在**排程事件**下方顯示任何與事件相關聯的資源。  
![\[使用儀表板檢視事件。\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/images/dashboard-scheduled-events.png)

1. 如需更多詳細資訊，在導覽窗格中選擇**事件**。此時會顯示任何與事件相關聯的資源。您可以依特性 (例如事件類型、資源類型和可用區域) 進行篩選。  
![\[使用 Events (事件) 頁面檢視事件。\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/images/events-instance-scheduled-stop.png)

------
#### [ AWS CLI ]

**檢視執行個體的排程事件**  
使用 [describe-instance-status](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-status.html) 命令。

```
aws ec2 describe-instance-status \
    --instance-id i-1234567890abcdef0 \
    --query "InstanceStatuses[].Events"
```

下列範例輸出顯示重新開機事件。

```
[
    "Events": [
        {
            "InstanceEventId": "instance-event-0d59937288b749b32",
            "Code": "system-reboot",
            "Description": "The instance is scheduled for a reboot",
            "NotAfter": "2019-03-15T22:00:00.000Z",
            "NotBefore": "2019-03-14T20:00:00.000Z",
            "NotBeforeDeadline": "2019-04-05T11:00:00.000Z"
         }

    ]
]
```

下列為顯示執行個體淘汰事件的範例輸出。

```
[
    "Events": [
        {
            "InstanceEventId": "instance-event-0e439355b779n26",                        
            "Code": "instance-stop",
            "Description": "The instance is running on degraded hardware",
            "NotBefore": "2015-05-23T00:00:00.000Z"
        }
    ]
]
```

------
#### [ PowerShell ]

**檢視執行個體的排程事件**  
使用下列 [Get-EC2InstanceStatus](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceStatus.html) 命令。

```
(Get-EC2InstanceStatus -InstanceId i-1234567890abcdef0).Events
```

下列為顯示執行個體淘汰事件的範例輸出。

```
Code         : instance-stop
Description  : The instance is running on degraded hardware
NotBefore    : 5/23/2015 12:00:00 AM
```

------
#### [ Instance metadata ]

**使用執行個體中繼資料檢視您執行個體的排程事件**  
您可以使用執行個體中繼資料服務第 2 版或執行個體中繼資料服務第 1 版，從[執行個體中繼資料](ec2-instance-metadata.md)擷取有關執行個體之作用中維護事件的資訊。

**IMDSV2**

```
[ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/events/maintenance/scheduled
```

**IMDSv1**

```
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/events/maintenance/scheduled
```

以下範例輸出包含排程系統重新開機事件的資訊 (採用 JSON 格式)。

```
[ 
  {
    "NotBefore" : "21 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "21 Jan 2019 09:17:23 GMT",
    "State" : "active"
  } 
]
```

**使用執行個體中繼資料檢視執行個體已完成或已取消事件的事件歷史記錄**  
您可以使用執行個體中繼資料服務第 2 版或執行個體中繼資料服務第 1 版，從[執行個體中繼資料](ec2-instance-metadata.md)擷取有關已完成或已取消之執行個體事件的資訊。

**IMDSV2**

```
[ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/events/maintenance/history
```

**IMDSv1**

```
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/events/maintenance/history
```

以下範例輸出包含已取消之系統重新開機事件和已完成之系統重新開機事件的資訊 (採用 JSON 格式)。

```
[ 
  {
    "NotBefore" : "21 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "[Canceled] scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "21 Jan 2019 09:17:23 GMT",
    "State" : "canceled"
  }, 
  {
    "NotBefore" : "29 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "[Completed] scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "29 Jan 2019 09:17:23 GMT",
    "State" : "completed"
  }
]
```

------
#### [ AWS Health ]

您可以使用 AWS Health 儀板表 來了解可能影響執行個體的事件。會將問題 Health 儀板表 整理成三個群組：開啟問題、排程變更和其他通知。排定的變更包含進行中或即將進行的項目。

如需詳細資訊，請參閱「指南」中的「AWS Health **[AWS Health 儀板表入門](https://docs.aws.amazon.com/health/latest/ug/getting-started-health-dashboard.html)」。

------