Skip to content

Commit 120a16d

Browse files
committed
Merge pull request #93 from grg350/master
Adding support for "stats slabs" statistics
2 parents 7feed83 + dc35cd8 commit 120a16d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

memcache.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,37 @@ def get_stats(self, stat_args=None):
345345

346346
return(data)
347347

348+
def get_slab_stats(self):
349+
data = []
350+
for s in self.servers:
351+
if not s.connect():
352+
continue
353+
if s.family == socket.AF_INET:
354+
name = '%s:%s (%s)' % (s.ip, s.port, s.weight)
355+
elif s.family == socket.AF_INET6:
356+
name = '[%s]:%s (%s)' % (s.ip, s.port, s.weight)
357+
else:
358+
name = 'unix:%s (%s)' % (s.address, s.weight)
359+
serverData = {}
360+
data.append((name, serverData))
361+
s.send_cmd('stats slabs')
362+
readline = s.readline
363+
while 1:
364+
line = readline()
365+
if not line or line.strip() == 'END':
366+
break
367+
item = line.split(' ', 2)
368+
if line.startswith('STAT active_slabs') or line.startswith('STAT total_malloced'):
369+
serverData[item[1]]=item[2]
370+
else:
371+
# 0 = STAT, 1 = ITEM, 2 = Value
372+
slab = item[1].split(':', 2)
373+
# 0 = Slab #, 1 = Name
374+
if slab[0] not in serverData:
375+
serverData[slab[0]] = {}
376+
serverData[slab[0]][slab[1]] = item[2]
377+
return data
378+
348379
def get_slabs(self):
349380
data = []
350381
for s in self.servers:

0 commit comments

Comments
 (0)