当实例启动时,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);
}
但这只是给出状态,而不是状态检查。