mirror of https://github.com/hashicorp/consul
command/agent: HTTP check: Any 2xx is OK, 429 is WARNING
parent
fb5ba8d97d
commit
6a2d763d5c
|
@ -321,25 +321,21 @@ func (c *CheckHTTP) check() {
|
|||
}
|
||||
resp.Body.Close()
|
||||
|
||||
switch resp.StatusCode {
|
||||
|
||||
// PASSING
|
||||
case http.StatusOK:
|
||||
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
|
||||
// PASSING (2xx)
|
||||
c.Logger.Printf("[DEBUG] http check '%v' is passing", c.CheckID)
|
||||
result := fmt.Sprintf("%s from %s", resp.Status, c.HTTP)
|
||||
c.Notify.UpdateCheck(c.CheckID, structs.HealthPassing, result)
|
||||
|
||||
} else if resp.StatusCode == 429 {
|
||||
// WARNING
|
||||
// 503 Service Unavailable
|
||||
// The server is currently unable to handle the request due to
|
||||
// a temporary overloading or maintenance of the server.
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
case http.StatusServiceUnavailable:
|
||||
// 429 Too Many Requests (RFC 6585)
|
||||
// The user has sent too many requests in a given amount of time.
|
||||
c.Logger.Printf("[WARN] check '%v' is now warning", c.CheckID)
|
||||
c.Notify.UpdateCheck(c.CheckID, structs.HealthWarning, resp.Status)
|
||||
|
||||
} else {
|
||||
// CRITICAL
|
||||
default:
|
||||
c.Logger.Printf("[WARN] check '%v' is now critical", c.CheckID)
|
||||
c.Notify.UpdateCheck(c.CheckID, structs.HealthCritical, resp.Status)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue