-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmonitor.go
68 lines (63 loc) · 1.95 KB
/
monitor.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ker
import (
"encoding/json"
"strconv"
)
// CPUMonitor retrives the cpu usage data in the given time
func (u *User) CPUMonitor(uuid string, startTime int, endTime int, unit string) (data ApiResponse) {
b := make(map[string]string)
b["uuid"] = uuid
b["startTime"] = strconv.Itoa(startTime)
b["endTime"] = strconv.Itoa(endTime)
b["unit"] = unit
ret, err := request("cpuMonitor", b, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}
// NetMonitor provide public external internet network statistics of specific virtual machine
// All outgoing internet traffic (e.g. website traffic)
func (u *User) NetMonitor(uuid string, startTime int, endTime int, unit string) (data ApiResponse) {
b := make(map[string]string)
b["uuid"] = uuid
b["startTime"] = strconv.Itoa(startTime)
b["endTime"] = strconv.Itoa(endTime)
b["unit"] = unit
ret, err := request("netMonitor", b, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}
// NatMonitor provide private internal network statistics of specific virtual machine
// All internal traffic are included (e.g. package source)
func (u *User) NatMonitor(uuid string, startTime int, endTime int, unit string) (data ApiResponse) {
b := make(map[string]string)
b["uuid"] = uuid
b["startTime"] = strconv.Itoa(startTime)
b["endTime"] = strconv.Itoa(endTime)
b["unit"] = unit
ret, err := request("natMonitor", b, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}
// IOMonitor gives IOPS data
func (u *User) IOMonitor(uuid string, startTime int, endTime int, unit string) (data ApiResponse) {
b := make(map[string]string)
b["uuid"] = uuid
b["startTime"] = strconv.Itoa(startTime)
b["endTime"] = strconv.Itoa(endTime)
b["unit"] = unit
ret, err := request("IOMonitor", b, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}