-
Notifications
You must be signed in to change notification settings - Fork 106
/
metrics.go
54 lines (39 loc) · 887 Bytes
/
metrics.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
46
47
48
49
50
51
52
53
54
package loadtest
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"time"
"github.com/AudiusProject/audius-protocol/mediorum/server"
)
// !! metrics.go is WIP - will revisit !!
func RunM(tc *TestClient) {
for {
time.Sleep(time.Second * 2)
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
for i, peer := range tc.UpPeers {
resp, err := tc.HttpClient.Get(fmt.Sprintf("%s/internal/metrics", peer.Host))
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
fmt.Println(resp.Status)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
}
results := server.Metrics{}
if err := json.Unmarshal(body, &results); err != nil {
fmt.Println("ERR Can not unmarshal JSON", err)
return
}
fmt.Printf("[%3d] %+v\n", i, results)
}
}
}