@@ -109,6 +109,7 @@ func (internalError *internalError) Wrap(err string) *internalError {
109109type Stats struct {
110110 NginxInfo NginxInfo
111111 Connections Connections
112+ Slabs Slabs
112113 HTTPRequests HTTPRequests
113114 SSL SSL
114115 ServerZones ServerZones
@@ -140,6 +141,32 @@ type Connections struct {
140141 Idle uint64
141142}
142143
144+ // Slabs is map of slab stats by zone name.
145+ type Slabs map [string ]Slab
146+
147+ // Slab represents slab related stats.
148+ type Slab struct {
149+ Pages Pages
150+ Slots Slots
151+ }
152+
153+ // Pages represents the slab memory usage stats.
154+ type Pages struct {
155+ Used uint64
156+ Free uint64
157+ }
158+
159+ // Slots is a map of slots by slot size
160+ type Slots map [string ]Slot
161+
162+ // Slot represents slot related stats.
163+ type Slot struct {
164+ Used uint64
165+ Free uint64
166+ Reqs uint64
167+ Fails uint64
168+ }
169+
143170// HTTPRequests represents HTTP request related stats.
144171type HTTPRequests struct {
145172 Total uint64
@@ -907,7 +934,12 @@ func determineStreamUpdates(updatedServers []StreamUpstreamServer, nginxServers
907934func (client * NginxClient ) GetStats () (* Stats , error ) {
908935 info , err := client .getNginxInfo ()
909936 if err != nil {
910- return nil , fmt .Errorf ("failed to get stats %v" , err )
937+ return nil , fmt .Errorf ("failed to get stats: %v" , err )
938+ }
939+
940+ slabs , err := client .getSlabs ()
941+ if err != nil {
942+ return nil , fmt .Errorf ("failed to get stats: %v" , err )
911943 }
912944
913945 cons , err := client .getConnections ()
@@ -962,6 +994,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
962994
963995 return & Stats {
964996 NginxInfo : * info ,
997+ Slabs : * slabs ,
965998 Connections : * cons ,
966999 HTTPRequests : * requests ,
9671000 SSL : * ssl ,
@@ -984,6 +1017,15 @@ func (client *NginxClient) getNginxInfo() (*NginxInfo, error) {
9841017 return & info , nil
9851018}
9861019
1020+ func (client * NginxClient ) getSlabs () (* Slabs , error ) {
1021+ var slabs Slabs
1022+ err := client .get ("slabs" , & slabs )
1023+ if err != nil {
1024+ return nil , fmt .Errorf ("failed to get slabs: %v" , err )
1025+ }
1026+ return & slabs , nil
1027+ }
1028+
9871029func (client * NginxClient ) getConnections () (* Connections , error ) {
9881030 var cons Connections
9891031 err := client .get ("connections" , & cons )
0 commit comments