在 http://exchange.nagios.org/ 上有shell 写的脚本,nagios可以监控到命中率,他是基于 telnet 的,使用之后看到 进程里有个telnet 进程,很不爽,而且脚本休要修改一下,不然会报错,不知道大家是不是同样的问题,而我,想要的是监控命中率,还有内存使用率以及,当前连接数·所以只能自己动手来写个脚本了·在python 的官网上看到有 python-memcache包,就下来看了一下源码,使用还是很方便的·。
shell $> cat check_memcache.py
#!/usr/bin/python import memcache import getopt import sys def usage(): print """check_memcache is a Nagios to monitor memcached memory Plugin Usage: check_memcache [-h|--help][-w|warning][-c|critical] Options: --help|-h) print check_memcache help --warning|-w) Sets a warning level for memcache use memory.Default is :off --critical|-c) Sets a critical level for memcache use memory.Default is:off. """ sys.exit(0)