Quantcast
Viewing latest article 2
Browse Latest Browse All 3

Cacti监控memcached

前提
1.Cacti系统
2.需要监控的memcached系统
3.Cacti主机上安装有Python
4.Cacti主机上安装有Python memcached Client API

当前
已满足前提1,2,3。接下来记录配置监控memcached的操作。
各版本:
Cacti: 0.8.7g
Python: 2.7.3

操作
1.下载
下载地址:

http://s1.dlnws.com/dealnews/developers/cacti-memcached-1.0.tar.gz

下载文件 cacti-memcached-1.0.tar.gz
并上传到Cacti主机的/db/soft目录。

2.安装

shell> tar -xzvf cacti-memcached-1.0.tar.gz
cacti-memcached-1.0/
cacti-memcached-1.0/cacti_memcached_host_template.xml
cacti-memcached-1.0/INSTALL
cacti-memcached-1.0/memcached.py
cacti-memcached-1.0/README

拷贝memcached.py至cacti的脚本目录

shell> cp cacti-memcached-1.0/memcached.py /var/www/html/cacti/scripts/

验证memcached.py能否正常运行,memcached主机为:192.168.10.182:11211
如果报错如下:
Traceback (most recent call last):
File “/var/www/html/cacti/scripts/memcached.py”, line 4, in <module>
import memcache
ImportError: No module named memcache
显然memcache模块,那么安装之。
下载:

https://pypi.python.org/pypi/python-memcached/

下载了 python-memcached-1.51.tar.gz,同样上传到/db/soft下。

shell> tar -xzvf python-memcached-1.51.tar.gz
shell> cd python-memcached-1.51
shell> python setup.py install

如果该命令不生效,可以直接拷贝,如

shell> cp memcache.py /usr/local/lib/python2.7/

再次验证:

shell> python /var/www/html/cacti/scripts/memcached.py 192.168.10.182
total_items:2697604 get_hits:2387111 uptime:3385763 cmd_get:4393454 time:1367928374 bytes:134749953 curr_connections:22 connection_structures:28 bytes_written:1559953441 limit_maxbytes:8489271296 cmd_set:2697605 curr_items:1008185 rusage_user:176.662143 get_misses:2006343 rusage_system:319.811381 bytes_read:1744798506 total_connections:115

说明安装正常。

测试无误后,登录Cacti Web端,导入Cacti模板
console-》Import Templates-》Import Template from Local File,选择cacti_memcached_host_template.xml导入。
成功导入后界面:

Image may be NSFW.
Clik here to view.
cacti_memcache

3.配置与使用
1)添加新device,选择Memcached Server
2)创建关联的所有Graph
3)在Graph Trees中创建展示的分支,关联这些Graph即可。
最终可以看到效果如:

Image may be NSFW.
Clik here to view.
cacti_memcache2

ps:
如果memcached安装时使用了非默认的11211,可以操作如下:
1)登录Cacti Web
2)选择console->Data Input Methods,编辑Memcached – Statistics,在Input String中添加-p <port>,如果python的路径不是默认的/usr/bin/python,也可以在这里修改。
不过以上方法修改端口只能是统一修改,如果有多实例,使用不同端口依然无法操作。可以修改使用
http://tag1consulting.com/blog/cacti-memcache-multi-port-templates 提供的多端口的模板,安装方法与上类似,只是需要为每个Graph指定端口。

参考:
http://dealnews.com/developers/cacti/memcached.html

The post Cacti监控memcached appeared first on SQLParty.


Viewing latest article 2
Browse Latest Browse All 3

Trending Articles