

• AWS Systems Manager CloudWatch 控制面板在 2026 年 4 月 30 日之后将不再可用。客户可以像现在一样继续使用 Amazon CloudWatch 控制台来查看、创建和管理其 Amazon CloudWatch 控制面板。有关更多信息，请参阅 [Amazon CloudWatch 控制面板文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

# 获取更改日历的状态
<a name="change-calendar-getstate"></a>

您可以在 Change Calendar（AWS Systems Manager 中的一项工具）中获取日历的整体状态或者日历在特定时间的状态。您还可以显示日历状态下次从 `OPEN` 更改为 `CLOSED`（或反之）的时间。

**注意**  
有关将 Change Calendar 与 Amazon EventBridge 集成以自动监控日历状态变化的信息，请参阅[Change Calendar 与 Amazon EventBridge 集成](monitoring-systems-manager-event-examples.md#change-calendar-eventbridge-integration)。EventBridge 集成在日历状态转换时提供事件驱动的通知，补充基于轮询的 `GetCalendarState` API 操作方法。

您只能使用 `GetCalendarState` API 操作完成此任务。本节中的过程使用 AWS Command Line Interface (AWS CLI)。

**获取更改日历的状态**
+ 运行以下命令，以显示一个或多个日历在特定时间的状态。`--calendar-names` 参数是必需项，但 `--at-time` 是可选项。将每个*示例资源占位符*替换为您自己的信息。

------
#### [ Linux & macOS ]

  ```
  aws ssm get-calendar-state \
      --calendar-names "Calendar_name_or_document_ARN_1" "Calendar_name_or_document_ARN_2" \
      --at-time "ISO_8601_time_format"
  ```

  示例如下：

  ```
  aws ssm get-calendar-state \
      --calendar-names "arn:aws:ssm:us-east-2:123456789012:document/MyChangeCalendarDocument" "arn:aws:ssm:us-east-2:123456789012:document/SupportOffHours" \
      --at-time "2020-07-30T11:05:14-0700"
  ```

------
#### [ Windows ]

  ```
  aws ssm get-calendar-state ^
      --calendar-names "Calendar_name_or_document_ARN_1" "Calendar_name_or_document_ARN_2" ^
      --at-time "ISO_8601_time_format"
  ```

  示例如下：

  ```
  aws ssm get-calendar-state ^
      --calendar-names "arn:aws:ssm:us-east-2:123456789012:document/MyChangeCalendarDocument" "arn:aws:ssm:us-east-2:123456789012:document/SupportOffHours" ^
      --at-time "2020-07-30T11:05:14-0700"
  ```

------

  此命令会返回如下信息。

  ```
  {
      "State": "OPEN",
      "AtTime": "2020-07-30T16:18:18Z",
      "NextTransitionTime": "2020-07-31T00:00:00Z"
  }
  ```

  结果显示指定日历条目（由您的账户拥有或与您的账户共享）在 `--at-time` 的值所指定时间的日历状态（无论日历的类型为 `DEFAULT_OPEN` 还是 `DEFAULT_CLOSED`），以及下一次转换的时间。如果您不添加 `--at-time` 参数，则使用当前时间。
**注意**  
如果在一个请求中指定了多个日历，则仅当该请求中的所有日历都处于打开状态时，该命令才会返回 `OPEN` 的状态。如果该请求中的一个或多个日历处于关闭状态，则返回的状态为 `CLOSED`。