@@ -88,6 +88,7 @@ type Stats struct {
88
88
Upstreams Upstreams
89
89
StreamServerZones StreamServerZones
90
90
StreamUpstreams StreamUpstreams
91
+ StreamZoneSync StreamZoneSync
91
92
}
92
93
93
94
// NginxInfo contains general information about NGINX Plus.
@@ -149,6 +150,27 @@ type StreamServerZone struct {
149
150
Sent uint64
150
151
}
151
152
153
+ // StreamZoneSync represents the sync information per each shared memory zone and the sync information per node in a cluster
154
+ type StreamZoneSync struct {
155
+ Zones map [string ]SyncZone
156
+ Status StreamZoneSyncStatus
157
+ }
158
+
159
+ // SyncZone represents the syncronization status of a shared memory zone
160
+ type SyncZone struct {
161
+ RecordsPending uint64 `json:"records_pending"`
162
+ RecordsTotal uint64 `json:"records_total"`
163
+ }
164
+
165
+ // StreamZoneSyncStatus represents the status of a shared memory zone
166
+ type StreamZoneSyncStatus struct {
167
+ BytesIn uint64 `json:"bytes_in"`
168
+ MsgsIn uint64 `json:"msgs_in"`
169
+ MsgsOut uint64 `json:"msgs_out"`
170
+ BytesOut uint64 `json:"bytes_out"`
171
+ NodesOnline uint64 `json:"nodes_online"`
172
+ }
173
+
152
174
// Responses represents HTTP response related stats.
153
175
type Responses struct {
154
176
Responses1xx uint64 `json:"1xx"`
@@ -728,6 +750,11 @@ func (client *NginxClient) GetStats() (*Stats, error) {
728
750
return nil , fmt .Errorf ("failed to get stats: %v" , err )
729
751
}
730
752
753
+ streamZoneSync , err := client .getStreamZoneSync ()
754
+ if err != nil {
755
+ return nil , fmt .Errorf ("failed to get stats: %v" , err )
756
+ }
757
+
731
758
return & Stats {
732
759
NginxInfo : * info ,
733
760
Connections : * cons ,
@@ -737,6 +764,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
737
764
StreamServerZones : * streamZones ,
738
765
Upstreams : * upstreams ,
739
766
StreamUpstreams : * streamUpstreams ,
767
+ StreamZoneSync : * streamZoneSync ,
740
768
}, nil
741
769
}
742
770
@@ -822,6 +850,22 @@ func (client *NginxClient) getStreamUpstreams() (*StreamUpstreams, error) {
822
850
return & upstreams , nil
823
851
}
824
852
853
+ func (client * NginxClient ) getStreamZoneSync () (* StreamZoneSync , error ) {
854
+ var streamZoneSync StreamZoneSync
855
+ err := client .get ("stream/zone_sync" , & streamZoneSync )
856
+ if err != nil {
857
+ if err , ok := err .(* internalError ); ok {
858
+
859
+ if err .Code == pathNotFoundCode {
860
+ return & streamZoneSync , nil
861
+ }
862
+ }
863
+ return nil , fmt .Errorf ("failed to get stream zone sync: %v" , err )
864
+ }
865
+
866
+ return & streamZoneSync , err
867
+ }
868
+
825
869
// KeyValPairs are the key-value pairs stored in a zone.
826
870
type KeyValPairs map [string ]string
827
871
0 commit comments