2011年1月22日土曜日

python-memcachedでSlab統計を取得する

python-memcachedでSlab統計を取得するには、以下のコードを実行します。

# coding=UTF-8
import memcache
# memcachedに接続
mc = memcache.Client(['localhost:11211'], debug=0)

# Slab統計を取得
for slab in mc.get_slabs():
 print("----")
 print("server:"+slab[0]) 
 for slab, stats in slab[1].iteritems():
  print("slab:" + slab)
  for key, value in stats.iteritems():
   print(key + "=" + value)

補足
ubuntuでmemcachedのインストールは以下のコマンドでおこないます。
sudo apt-get install memcached

python-memcacheのインストールは以下のコマンドでおこないます。
sudo apt-get install python-memcache

動作環境
python 2.6.6, python-memcache 1.45-1, ubuntu 10.10

関連情報
http://www.tummy.com/Community/software/python-memcached/

0 件のコメント:

コメントを投稿