diff --git a/proxy/api.go b/proxy/api.go index 0eab2a6..8969da5 100644 --- a/proxy/api.go +++ b/proxy/api.go @@ -53,6 +53,7 @@ func convertUpstream(u *rpc.RPCClient) map[string]interface{} { "accepts": atomic.LoadUint64(&u.Accepts), "rejects": atomic.LoadUint64(&u.Rejects), "lastSubmissionAt": atomic.LoadInt64(&u.LastSubmissionAt), + "failsCount": atomic.LoadUint64(&u.FailsCount), } return upstream } diff --git a/rpc/rpc.go b/rpc/rpc.go index cfce3ce..63f096f 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" "sync" + "sync/atomic" "time" ) @@ -23,6 +24,7 @@ type RPCClient struct { Rejects uint64 LastSubmissionAt int64 client *http.Client + FailsCount uint64 } type GetBlockReply struct { @@ -160,6 +162,9 @@ func (r *RPCClient) Sick() bool { func (r *RPCClient) markSick() { r.Lock() + if !r.sick { + atomic.AddUint64(&r.FailsCount, 1) + } r.sickRate++ r.successRate = 0 if r.sickRate >= 5 { diff --git a/www/index.html b/www/index.html index cd03a4d..a55e162 100644 --- a/www/index.html +++ b/www/index.html @@ -78,6 +78,7 @@

Upstream

Url Accepted Rejected + Fails {{#each upstreams}} {{#if sick}} @@ -93,6 +94,7 @@

Upstream

{{url}} {{formatNumber accepts}} {{formatNumber rejects}} + {{failsCount}} {{/each}}