Cacti监控Redis实现过程


Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监測图形分析工具。被广泛的用于对server的运维监控中,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

 

[root@mysqlvm2 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

又一次做个软连接就能够了

[root@mysqlvm2 Python-2.5.2]# ln -s /usr/local/bin/python /usr/bin/python

[root@mysqlvm2 Python-2.5.2]#

[root@mysqlvm2 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

配置监控脚本

 

mongodbredis的监控所需到的是你下载文件夹中的better-cacti-templates-1.1.8scripts下的

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 emplates

cacti界面导入界面,创建redisserver的Graph,例如以下所看到的:

 

5,去查看Graph效果图,例如以下所看到的:

 


来自:http://blog.itpub.net/26230597/viewspace-1254930/


原文地址:https://www.cnblogs.com/lytwajue/p/6905394.html