Revert "closes #6"

This reverts commit 46df5bc0bf.
This commit is contained in:
Denis Zheleztsov 2017-01-13 13:20:56 +03:00
parent 46df5bc0bf
commit ce6a6ddd83
2 changed files with 0 additions and 62 deletions

View File

@ -133,20 +133,6 @@ func (s ServerConf) ServeHTTP(z ZooNode, fqdn string) {
w.Write(state)
})
// Get metrics
http.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
m, err := GetMetrics(z)
if err != nil {
w.WriteHeader(500)
return
}
metrics, err := json.MarshalIndent(m, "", " ")
if err != nil {
log.Fatal(err)
}
w.Write(metrics)
})
wr := wrr{
fqdn,
z,

View File

@ -1,48 +0,0 @@
package rbmd
import (
"encoding/json"
"runtime"
"strings"
)
//Metrics metrics statistic
type Metrics struct {
Goroutines int `json:"goroutines"`
Nodes int `json:"nodes"`
MountsTotal int `json:"mountstotal"`
Cgocall int64 `json:"cgocall"`
}
// GetMetrics ...
func GetMetrics(z ZooNode) (Metrics, error) {
var q Quorum
var m Metrics
curQuorum, _, err := z.Conn.Get(strings.Join([]string{z.Path, "log", "quorum"}, "/"))
if err != nil {
return m, err
}
err = json.Unmarshal(curQuorum, &q)
if err != nil {
return m, err
}
m.Nodes = len(q.Quorum)
m.Goroutines = runtime.NumGoroutine()
m.Cgocall = runtime.NumCgoCall()
m.MountsTotal = GetTotalMounts(q.Quorum)
return m, nil
}
// GetTotalMounts ...
func GetTotalMounts(n []Node) int {
mounts := 0
for _, node := range n {
mounts = mounts + len(node.Mounts)
}
return mounts
}