forked from rif/telegraf-freeswitch
/
status.go
44 lines (36 loc) · 863 Bytes
/
status.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
package utils
import "encoding/json"
type Count struct {
Total int `json:"total"`
Active int `json:"active"`
Peak int `json:"peak"`
Peak5min int `json:"peak5Min"`
Limit int `json:"limit"`
}
type Rate struct {
Current int `json:"current"`
Max int `json:"max"`
Peak int `json:"peak"`
Peak5min int `json:"peak5Min"`
}
type StackSize struct {
Current int `json:"current"`
Max int `json:"max"`
}
type Sessions struct {
Count Count `json:"count"`
Rate Rate `json:"rate"`
}
type StatusResponse struct {
Sessions Sessions `json:"sessions"`
StackSize StackSize `json:"stackSizeKB"`
}
type Command struct {
Status string `json:"status"`
Response StatusResponse `json:"response"`
}
func LoadStatusJSON(data string) (*Command, error) {
c := &Command{}
err := json.Unmarshal([]byte(data), c)
return c, err
}