forked from sensu/uchiwa
-
Notifications
You must be signed in to change notification settings - Fork 3
/
structs.go
204 lines (177 loc) · 5.82 KB
/
structs.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package structs
import "time"
// AuditLog is a structure for holding a log of the audit
type AuditLog struct {
Date time.Time `json:"date"`
Action string `json:"action"`
Level string `json:"level"`
Output string `json:"output,omitempty"`
RemoteAddr string `json:"remoteaddr"`
URL string `json:"url,omitempty"`
User string `json:"user"`
}
// Auth struct contains the generic configuration and details
// about the authentication
type Auth struct {
Driver string
PrivateKey string
PublicKey string
}
// CheckExecution struct contains the payload for issuing a
// check execution request to a Sensu API
type CheckExecution struct {
Check string `json:"check"`
Dc string `json:"dc"`
Subscribers []string `json:"subscribers"`
}
// Data is a structure for holding public data fetched from the Sensu APIs and exposed by the endpoints
type Data struct {
Aggregates []interface{}
Checks []interface{}
Clients []interface{}
Dc []*Datacenter
Events []interface{}
Health Health
Metrics Metrics
SEMetrics SEMetrics
SERawMetrics SERawMetrics `json:"-"`
Silenced []interface{}
Stashes []interface{}
Subscriptions []Subscription
}
// Datacenter is a structure for holding the information about a datacenter
type Datacenter struct {
Name string `json:"name"`
Info Info `json:"info"`
Metrics map[string]int `json:"metrics"`
}
// Generic is a structure for holding a generic element
type Generic struct {
Dc string `json:"dc"`
}
// GenericCheck is a structure for holding a generic check
type GenericCheck struct {
Dc string `json:"dc"`
Output string `json:"output"`
Status int `json:"status"`
Subscribers []string `json:"subscribers"`
}
// GenericClient is a structure for holding a generic client
type GenericClient struct {
Dc string `json:"dc"`
Name string `json:"name"`
Subscriptions []string `json:"subscriptions"`
}
// GenericEvent is a structure for holding a generic event
type GenericEvent struct {
Check GenericCheck `json:"check"`
Client GenericClient `json:"client"`
Dc string `json:"dc"`
}
// Health is a structure for holding health informaton about Sensu & Uchiwa
type Health struct {
Sensu map[string]SensuHealth `json:"sensu"`
Uchiwa string `json:"uchiwa"`
}
// SensuHealth is a structure for holding health information about a specific sensu datacenter
type SensuHealth struct {
Output string `json:"output"`
Status int `json:"status"`
}
// Info is a structure for holding the /info API information
type Info struct {
Redis Redis `json:"redis"`
Sensu Sensu `json:"sensu"`
Servers []InfoServer `json:"servers"`
Transport transport `json:"transport"`
}
type InfoServer struct {
ID string `json:"id"`
Hostname string `json:"hostname"`
Address string `json:"address"`
IsLeader bool `json:"is_leader,omitempty"`
Metrics map[string]map[string]float32 `json:"metrics"`
Sensu map[string]interface{} `json:"sensu,omitempty"`
Tasks []string `json:"tasks,omitempty"`
Timestamp int `json:"timestamp"`
}
// Redis is a structure for holding the redis status
type Redis struct {
Connected bool `json:"connected"`
}
// Metrics is a structure for holding the metrics of the Sensu objects
type Metrics struct {
Aggregates StatusMetrics `json:"aggregates"`
Checks StatusMetrics `json:"checks"`
Clients StatusMetrics `json:"clients"`
Datacenters StatusMetrics `json:"datacenters"`
Events StatusMetrics `json:"events"`
Silenced StatusMetrics `json:"silenced"`
Stashes StatusMetrics `json:"stashes"`
}
// StatusMetrics is a structure for holding the status count
type StatusMetrics struct {
Critical int `json:"critical"`
Healthy int `json:"healthy"`
Silenced int `json:"silenced"`
Total int `json:"total"`
Unknown int `json:"unknown"`
Warning int `json:"warning"`
}
// SEMetrics is a structure for holding the Sensu Enterprise metrics
type SEMetrics struct {
Clients *SEMetric `json:"clients"`
Events []*SEMetric `json:"events"`
KeepalivesAVG60 *SEMetric `json:"keepalives_avg_60"`
Requests *SEMetric `json:"requests"`
Results *SEMetric `json:"results"`
}
// SEMetric is a structure for holding a Sensu Enterprise metric
type SEMetric struct {
Data []XY `json:"data"`
Name string `json:"name"`
}
// SERawMetrics ...
type SERawMetrics struct {
Clients []*SERawMetric
Events []*SERawMetric
KeepalivesAVG60 []*SERawMetric
Requests []*SERawMetric
Results []*SERawMetric
}
// SERawMetric ...
type SERawMetric struct {
Name string
Points [][]interface{} `json:"points"`
}
// Sensu is a structure for holding the sensu version
type Sensu struct {
EnterpriseVersion string `json:"enterprise_version,omitempty"`
Settings map[string]string `json:"settings,omitempty"`
Version string `json:"version"`
}
type transport struct {
Connected bool `json:"connected"`
Keepalives transportStatus `json:"keepalives"`
Results transportStatus `json:"results"`
}
type transportStatus struct {
Messages int `json:"messages"`
Consumers int `json:"consumers"`
}
// Subscription is a structure for holding a single subscription
type Subscription struct {
Dc string `json:"dc"`
Name string `json:"name"`
}
// XPagination is a structure for holding the x-pagination HTTP header
type XPagination struct {
Limit int
Offset int
Total int
}
// XY is a structure for holding the coordinates of Sensu Enterprise metrics points
type XY struct {
X float64 `json:"x"`
Y float64 `json:"y"`
}