Cacti监控Redis实现过程

Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。被广泛的用于对服务器的运维监控中,Cacti提供了一种插件式的管理,只要按要求写好特定的模板,那么你就可以对任何服务进行流量监控。本文就是要为大家介绍两个模板,分别是MongoDB和Redis的Cacti模板,使用它,你可以对你的MongoDB和Redis服务进行流量监控。
  1,升级python,此时如果是系统默认的python版本,会出现以下错误
python setup.py install
Traceback (most recent call last):
File "setup.py", line 3, in ?
from redis import __version__
File "/usr/local/src/redis-2.4.11/redis/__init__.py", line 1, in ?
from redis.client import Redis, StrictRedis
File "/usr/local/src/redis-2.4.11/redis/client.py", line 240
with self.pipeline(True, shard_hint) as pipe:
^
SyntaxError: invalid syntax
  2,安装python,先配置python环境,下载python源代码
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2
$ tar –jxvf Python-2.5.2.tar.bz2
$ cd Python-2.5.2
$ ./configure
$ make
$ make install
[[email protected] Python-2.5.2]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
  Version还是2.4.3的,解决办法如下:
  #cd /usr/bin
  #ll |grep python   //查看该目录下python
  #rm -rf python
  重新做个软连接就可以了
  [[email protected] Python-2.5.2]# ln -s /usr/local/bin/python /usr/bin/python
  [[email protected] Python-2.5.2]#
  [[email protected] Python-2.5.2]# python
  Python 2.5.2 (r252:60911, Aug  4 2014, 14:43:36)
  [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>>
 3,然后下载redis的模板
  wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
  配置监控脚本
  mongodb或redis的监控所需到的是你下载目录中的better-cacti-templates-1.1.8\scripts下的
  ss_get_by_ssh.php 这个脚本 这个脚本需要放在cacti的服务端。
  如果你cacti是装到/var/www/html/cacti/目录下。
  把该文件放在其下面的scripts目录下。别忘了看下权限。要有执行权限。
  然后修改该文件。主要修改一下选项,大概在40行。
  # ============================================================================
  $ssh_user   = 'root';                          # SSH username
  $ssh_port   = 22;                               # SSH port
  $ssh_iden   = '-i /root/.ssh/id_rsa';   # SSH identity
  ##修改根据你的配置,你的ssh连接用户,还有认证私钥的位置。
  大该在50行,还可以修改其默认的去探测的端口(如果redis不是正常默认端口启动需要修改这些)。
  $redis_port    = 6379;                    # Which port redis listens on
  4,导入模板,模板目录为better-cacti-templates-1.1.8\templates
  在cacti界面导入界面,创建redis服务器的Graph,如下所示:
Cacti监控Redis实现过程
  5,去查看Graph效果图,如下所示:
Cacti监控Redis实现过程
Cacti监控Redis实现过程

最新内容请见作者的GitHub页:http://qaseven.github.io/