command/agent: HTTP check: Any 2xx is OK, 429 is WARNING

pull/592/head
Nicholas Capo 2015-01-12 21:58:57 +00:00
parent fb5ba8d97d
commit 6a2d763d5c
1 changed files with 8 additions and 12 deletions

View File

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