@@ -494,6 +494,19 @@ type HTTPLimitConnections map[string]LimitConnection
494
494
// StreamLimitConnections represents limit connections related stats
495
495
type StreamLimitConnections map [string ]LimitConnection
496
496
497
+ // Workers represents worker connections related stats
498
+ type Workers struct {
499
+ ID int
500
+ ProcessID uint64 `json:"pid"`
501
+ HTTP WorkersHTTP `json:"http"`
502
+ Connections Connections
503
+ }
504
+
505
+ // WorkersHTTP represents HTTP worker connections
506
+ type WorkersHTTP struct {
507
+ HTTPRequests HTTPRequests `json:"requests"`
508
+ }
509
+
497
510
// NewNginxClient creates an NginxClient with the latest supported version.
498
511
func NewNginxClient (httpClient * http.Client , apiEndpoint string ) (* NginxClient , error ) {
499
512
return NewNginxClientWithVersion (httpClient , apiEndpoint , APIVersion )
@@ -1186,6 +1199,11 @@ func (client *NginxClient) GetStats() (*Stats, error) {
1186
1199
return nil , fmt .Errorf ("failed to get stats: %w" , err )
1187
1200
}
1188
1201
1202
+ workers , err := client .GetWorkers ()
1203
+ if err != nil {
1204
+ return nil , fmt .Errorf ("failed to get stats: %w" , err )
1205
+ }
1206
+
1189
1207
return & Stats {
1190
1208
NginxInfo : * info ,
1191
1209
Caches : * caches ,
@@ -1204,6 +1222,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
1204
1222
HTTPLimitRequests : * limitReqs ,
1205
1223
HTTPLimitConnections : * limitConnsHTTP ,
1206
1224
StreamLimitConnections : * limitConnsStream ,
1225
+ Workers : * workers ,
1207
1226
}, nil
1208
1227
}
1209
1228
@@ -1639,3 +1658,16 @@ func (client *NginxClient) GetStreamConnectionsLimit() (*StreamLimitConnections,
1639
1658
}
1640
1659
return & limitConns , nil
1641
1660
}
1661
+
1662
+ // GetWorkers returns workers stats.
1663
+ func (client * NginxClient ) GetWorkers () (* Workers , error ) {
1664
+ var workers Workers
1665
+ if client .version < 8 {
1666
+ return & workers , nil
1667
+ }
1668
+ err := client .get ("workers" , & workers )
1669
+ if err != nil {
1670
+ return nil , fmt .Errorf ("failed to get workers: %w" , err )
1671
+ }
1672
+ return & workers , nil
1673
+ }
0 commit comments