Python Boto - 如何为 Route 53 创建健康检查

0 投票
1 回答
1272 浏览
提问于 2025-04-18 07:09

我想知道怎么用Python的boto库为Route53创建一个健康检查。网上没有例子,文档也很少,真让人头疼。http://boto.readthedocs.org/en/latest/ref/route53.html

那么,如果给我一个IP地址、端口和路径,我该怎么办呢?

1 个回答

1

虽然 boto 的文档不太完善,但你可以通过 代码AWSAPI 来理解它。

看看 boto.route53.healthcheck.HealthCheck,然后按照下面的方式来实现:

route = boto.connect_route53()
hc = boto.route53.healthcheck.HealthCheck(...)
route = create_health_check(hc)

... 的内容可以通过 HealthCheck 的 帮助页面 来填写:

Help on HealthCheck in module boto.route53.healthcheck object:

class HealthCheck(__builtin__.object)
 |  An individual health check
 |  
 |  Methods defined here:
 |  
 |  __init__(self, ip_addr, port, hc_type, resource_path, fqdn=None, string_match=None, request_interval=30, failure_threshold=3)
 |      HealthCheck object
 |      
 |      :type ip_addr: str
 |      :param ip_addr: IP Address
 |      
 |      :type port: int
 |      :param port: Port to check
 |      
 |      :type hc_type: str
 |      :param ip_addr: One of HTTP | HTTPS | HTTP_STR_MATCH | HTTPS_STR_MATCH | TCP
 |      
 |      :type resource_path: str
 |      :param resource_path: Path to check
 |      
 |      :type fqdn: str
 |      :param fqdn: domain name of the endpoint to check
 |      
 |      :type string_match: str
 |      :param string_match: if hc_type is HTTP_STR_MATCH or HTTPS_STR_MATCH, the string to search for in the response body from the specified resource
 |      
 |      :type request_interval: int
 |      :param request_interval: The number of seconds between the time that Amazon Route 53 gets a response from your endpoint and the time that it sends the next health-check request.
 |      
 |      :type failure_threshold: int
 |      :param failure_threshold: The number of consecutive health checks that an endpoint must pass or fail for Amazon Route 53 to change the current status of the endpoint from unhealthy to healthy or vice versa.
 |  
 |  to_xml(self)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  POSTXMLBody = '\n        <HealthCheckConfig>\n            <IPAddr...il...
 |  
 |  XMLFQDNPart = '<FullyQualifiedDomainName>%(fqdn)s</FullyQualifiedDomai...
 |  
 |  XMLRequestIntervalPart = '<RequestInterval>%(request_interval)d</Reque...
 |  
 |  XMLStringMatchPart = '<SearchString>%(string_match)s</SearchString>'
 |  
 |  valid_request_intervals = (10, 30)

撰写回答