forked from open-falcon/falcon-plus
/
debug_http.go
45 lines (37 loc) · 1.12 KB
/
debug_http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package http
import (
"net/http"
"time"
"github.com/open-falcon/falcon-plus/modules/nodata/collector"
"github.com/open-falcon/falcon-plus/modules/nodata/config"
"github.com/open-falcon/falcon-plus/modules/nodata/sender"
)
func configDebugHttpRoutes() {
http.HandleFunc("/debug/collector/collect", func(w http.ResponseWriter, r *http.Request) {
start := time.Now().Unix()
cnt := collector.CollectDataOnce()
end := time.Now().Unix()
ret := make(map[string]int, 0)
ret["cnt"] = cnt
ret["time"] = int(end - start)
RenderDataJson(w, ret)
})
http.HandleFunc("/debug/config/sync", func(w http.ResponseWriter, r *http.Request) {
start := time.Now().Unix()
cnt := config.SyncNdConfigOnce()
end := time.Now().Unix()
ret := make(map[string]int, 0)
ret["cnt"] = cnt
ret["time"] = int(end - start)
RenderDataJson(w, ret)
})
http.HandleFunc("/debug/sender/send", func(w http.ResponseWriter, r *http.Request) {
start := time.Now().Unix()
cnt := sender.SendMockOnce()
end := time.Now().Unix()
ret := make(map[string]int, 0)
ret["cnt"] = cnt
ret["time"] = int(end - start)
RenderDataJson(w, ret)
})
}