subprocess check_output , check kyototycoon
http://docs.python.org/2/library/subprocess.html#replacing-older-functions-with-the-subprocess-module
nagios用のスクリプト
pythonからktremotemgrを呼んで状態を確認する
2.6なのでcheck_outputが使えなかった
http://docs.python.org/2.6/library/subprocess.html#module-subprocess
popenのところだけ
# 略
p = Popen(["ktremotemgr","report","-host",options.hostname,"-port",str(options.port),"-tout","2"], stdout=PIPE)
output = p.communicate()[0]
if re.search(r’db_total_count’, output ):
m = re.search(r’db_total_count: ([0-9]*)’, output )
count = m.group(1)
m = re.search(r’db_total_size: ([0-9]*)’, output )
size = m.group(1)
print “OK: %s %s:%d count:%s size:%s” % (service, options.hostname, options.port, count, size )
else:
raise RuntimeError( “%s data invalid” % service )
こんな感じでデータチェックして報告