2
當某個實例啓動時,aws控制檯顯示兩列狀態和狀態檢查。運行狀態不是狀態的真實反映,因爲狀態檢查可能會失敗。AWS:如何獲取實例狀態檢查狀態,而不是狀態
任何人都有.net C#代碼檢查狀態檢查狀態的任何示例?
我最接近的是這樣的:
var request = new DescribeInstanceStatusRequest();
request.InstanceId = insts.Select(i => i.InstanceId).ToList();
DescribeInstanceStatusResponse response = ec2Client.DescribeInstanceStatus(request);
InstanceStatus instanceStatus = response.DescribeInstanceStatusResult.InstanceStatus[0];
Console.WriteLine("Availability zone - " + instanceStatus.AvailabilityZone);
Console.WriteLine("Instance State Code - " + instanceStatus.InstanceState.Code);
Console.WriteLine("Instance State Name - " + instanceStatus.InstanceState.Name);
foreach (InstanceStatusEvent statusEvent in instanceStatus.InstanceStatusEvent)
{
Console.WriteLine("Event Code - " + statusEvent.Code);
Console.WriteLine("Event Description - " + statusEvent.Description);
Console.WriteLine("Earliest Scheduled Start Time - " + statusEvent.NotBefore);
Console.WriteLine("Latest Scheduled End Time - " + statusEvent.NotAfter);
}
但只是給國家,而不是狀態檢查。
當前代碼打印什麼? – Undo
它打印「運行」,但這不是我所需要的,我需要「狀態檢查」字段狀態,因爲它們可能會失敗,並且實例init會出錯。 – user1013388