@@ -42,9 +42,9 @@ var ErrUnsupportedVer = errors.New("API version of the client is not supported b
42
42
43
43
// NginxClient lets you access NGINX Plus API.
44
44
type NginxClient struct {
45
- apiVersion int
46
- apiEndpoint string
47
45
httpClient * http.Client
46
+ apiEndpoint string
47
+ apiVersion int
48
48
checkAPI bool
49
49
}
50
50
@@ -54,38 +54,38 @@ type versions []int
54
54
55
55
// UpstreamServer lets you configure HTTP upstreams.
56
56
type UpstreamServer struct {
57
- ID int `json:"id,omitempty"`
58
- Server string `json:"server"`
59
57
MaxConns * int `json:"max_conns,omitempty"`
60
58
MaxFails * int `json:"max_fails,omitempty"`
61
- FailTimeout string `json:"fail_timeout,omitempty"`
62
- SlowStart string `json:"slow_start,omitempty"`
63
- Route string `json:"route,omitempty"`
64
59
Backup * bool `json:"backup,omitempty"`
65
60
Down * bool `json:"down,omitempty"`
66
- Drain bool `json:"drain,omitempty"`
67
61
Weight * int `json:"weight,omitempty"`
62
+ Server string `json:"server"`
63
+ FailTimeout string `json:"fail_timeout,omitempty"`
64
+ SlowStart string `json:"slow_start,omitempty"`
65
+ Route string `json:"route,omitempty"`
68
66
Service string `json:"service,omitempty"`
67
+ ID int `json:"id,omitempty"`
68
+ Drain bool `json:"drain,omitempty"`
69
69
}
70
70
71
71
// StreamUpstreamServer lets you configure Stream upstreams.
72
72
type StreamUpstreamServer struct {
73
- ID int `json:"id,omitempty"`
74
- Server string `json:"server"`
75
73
MaxConns * int `json:"max_conns,omitempty"`
76
74
MaxFails * int `json:"max_fails,omitempty"`
77
- FailTimeout string `json:"fail_timeout,omitempty"`
78
- SlowStart string `json:"slow_start,omitempty"`
79
75
Backup * bool `json:"backup,omitempty"`
80
76
Down * bool `json:"down,omitempty"`
81
77
Weight * int `json:"weight,omitempty"`
78
+ Server string `json:"server"`
79
+ FailTimeout string `json:"fail_timeout,omitempty"`
80
+ SlowStart string `json:"slow_start,omitempty"`
82
81
Service string `json:"service,omitempty"`
82
+ ID int `json:"id,omitempty"`
83
83
}
84
84
85
85
type apiErrorResponse struct {
86
- Error apiError
87
86
RequestID string `json:"request_id"`
88
87
Href string
88
+ Error apiError
89
89
}
90
90
91
91
func (resp * apiErrorResponse ) toString () string {
@@ -94,14 +94,14 @@ func (resp *apiErrorResponse) toString() string {
94
94
}
95
95
96
96
type apiError struct {
97
- Status int
98
97
Text string
99
98
Code string
99
+ Status int
100
100
}
101
101
102
102
type internalError struct {
103
- apiError
104
103
err string
104
+ apiError
105
105
}
106
106
107
107
// Error allows internalError to match the Error interface.
@@ -119,34 +119,34 @@ func (internalError *internalError) Wrap(err string) *internalError {
119
119
// Stats represents NGINX Plus stats fetched from the NGINX Plus API.
120
120
// https://nginx.org/en/docs/http/ngx_http_api_module.html
121
121
type Stats struct {
122
- NginxInfo NginxInfo
123
- Caches Caches
124
- Processes Processes
125
- Connections Connections
126
- Slabs Slabs
127
- HTTPRequests HTTPRequests
128
- SSL SSL
129
- ServerZones ServerZones
130
122
Upstreams Upstreams
123
+ ServerZones ServerZones
131
124
StreamServerZones StreamServerZones
132
125
StreamUpstreams StreamUpstreams
133
- StreamZoneSync * StreamZoneSync
134
- LocationZones LocationZones
135
- Resolvers Resolvers
136
- HTTPLimitRequests HTTPLimitRequests
126
+ Slabs Slabs
127
+ Caches Caches
137
128
HTTPLimitConnections HTTPLimitConnections
138
129
StreamLimitConnections StreamLimitConnections
130
+ HTTPLimitRequests HTTPLimitRequests
131
+ Resolvers Resolvers
132
+ LocationZones LocationZones
133
+ StreamZoneSync * StreamZoneSync
139
134
Workers []* Workers
135
+ NginxInfo NginxInfo
136
+ SSL SSL
137
+ Connections Connections
138
+ HTTPRequests HTTPRequests
139
+ Processes Processes
140
140
}
141
141
142
142
// NginxInfo contains general information about NGINX Plus.
143
143
type NginxInfo struct {
144
144
Version string
145
145
Build string
146
146
Address string
147
- Generation uint64
148
147
LoadTimestamp string `json:"load_timestamp"`
149
148
Timestamp string
149
+ Generation uint64
150
150
ProcessID uint64 `json:"pid"`
151
151
ParentProcessID uint64 `json:"ppid"`
152
152
}
@@ -194,8 +194,8 @@ type Slabs map[string]Slab
194
194
195
195
// Slab represents slab related stats.
196
196
type Slab struct {
197
- Pages Pages
198
197
Slots Slots
198
+ Pages Pages
199
199
}
200
200
201
201
// Pages represents the slab memory usage stats.
@@ -358,21 +358,21 @@ type Upstreams map[string]Upstream
358
358
359
359
// Upstream represents upstream related stats.
360
360
type Upstream struct {
361
+ Zone string
361
362
Peers []Peer
363
+ Queue Queue
362
364
Keepalives int
363
365
Zombies int
364
- Zone string
365
- Queue Queue
366
366
}
367
367
368
368
// StreamUpstreams is a map of stream upstream stats by upstream name.
369
369
type StreamUpstreams map [string ]StreamUpstream
370
370
371
371
// StreamUpstream represents stream upstream related stats.
372
372
type StreamUpstream struct {
373
+ Zone string
373
374
Peers []StreamPeer
374
375
Zombies int
375
- Zone string
376
376
}
377
377
378
378
// Queue represents queue related stats for an upstream.
@@ -384,54 +384,54 @@ type Queue struct {
384
384
385
385
// Peer represents peer (upstream server) related stats.
386
386
type Peer struct {
387
- ID int
388
387
Server string
389
388
Service string
390
389
Name string
391
- Backup bool
392
- Weight int
390
+ Selected string
391
+ Downstart string
393
392
State string
394
- Active uint64
393
+ Responses Responses
395
394
SSL SSL
396
- MaxConns int `json:"max_conns "`
395
+ HealthChecks HealthChecks `json:"health_checks "`
397
396
Requests uint64
398
- Responses Responses
397
+ ID int
398
+ MaxConns int `json:"max_conns"`
399
399
Sent uint64
400
400
Received uint64
401
401
Fails uint64
402
402
Unavail uint64
403
- HealthChecks HealthChecks `json:"health_checks"`
403
+ Active uint64
404
404
Downtime uint64
405
- Downstart string
406
- Selected string
405
+ Weight int
407
406
HeaderTime uint64 `json:"header_time"`
408
407
ResponseTime uint64 `json:"response_time"`
408
+ Backup bool
409
409
}
410
410
411
411
// StreamPeer represents peer (stream upstream server) related stats.
412
412
type StreamPeer struct {
413
- ID int
414
413
Server string
415
414
Service string
416
415
Name string
417
- Backup bool
418
- Weight int
416
+ Selected string
417
+ Downstart string
419
418
State string
420
- Active uint64
421
419
SSL SSL
422
- MaxConns int `json:"max_conns "`
420
+ HealthChecks HealthChecks `json:"health_checks "`
423
421
Connections uint64
422
+ Received uint64
423
+ ID int
424
424
ConnectTime int `json:"connect_time"`
425
425
FirstByteTime int `json:"first_byte_time"`
426
426
ResponseTime uint64 `json:"response_time"`
427
427
Sent uint64
428
- Received uint64
428
+ MaxConns int `json:"max_conns"`
429
429
Fails uint64
430
430
Unavail uint64
431
- HealthChecks HealthChecks `json:"health_checks"`
431
+ Active uint64
432
432
Downtime uint64
433
- Downstart string
434
- Selected string
433
+ Weight int
434
+ Backup bool
435
435
}
436
436
437
437
// HealthChecks represents health check related stats for a peer.
0 commit comments