@@ -109,6 +109,7 @@ func (internalError *internalError) Wrap(err string) *internalError {
109
109
type Stats struct {
110
110
NginxInfo NginxInfo
111
111
Connections Connections
112
+ Slabs Slabs
112
113
HTTPRequests HTTPRequests
113
114
SSL SSL
114
115
ServerZones ServerZones
@@ -140,6 +141,32 @@ type Connections struct {
140
141
Idle uint64
141
142
}
142
143
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
+
143
170
// HTTPRequests represents HTTP request related stats.
144
171
type HTTPRequests struct {
145
172
Total uint64
@@ -907,7 +934,12 @@ func determineStreamUpdates(updatedServers []StreamUpstreamServer, nginxServers
907
934
func (client * NginxClient ) GetStats () (* Stats , error ) {
908
935
info , err := client .getNginxInfo ()
909
936
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 )
911
943
}
912
944
913
945
cons , err := client .getConnections ()
@@ -962,6 +994,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
962
994
963
995
return & Stats {
964
996
NginxInfo : * info ,
997
+ Slabs : * slabs ,
965
998
Connections : * cons ,
966
999
HTTPRequests : * requests ,
967
1000
SSL : * ssl ,
@@ -984,6 +1017,15 @@ func (client *NginxClient) getNginxInfo() (*NginxInfo, error) {
984
1017
return & info , nil
985
1018
}
986
1019
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
+
987
1029
func (client * NginxClient ) getConnections () (* Connections , error ) {
988
1030
var cons Connections
989
1031
err := client .get ("connections" , & cons )
0 commit comments