redis监控软件---RedisLive

官方文档:http://www.nkrode.com/article/real-time-dashboard-for-redis

1、基础环境安装


-----------------------------------------------------------------------------------------------------------------------------------------------
http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2


tar jxvf  Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make
make install


python -V
替换原有的/usr/bin/python
mv /usr/bin/python  /usr/bin/python.bak
ln -s /usr/local/bin/python2.7 /usr/bin/python


-----------------------------------------------------------------------------------------------------------------------------------------------
安装setuptools


http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg

-----------------------------------------------------------------------------------------------------------------------------------------------

https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-3.4.0.2.tar.gz
# tar xvzf backports.ssl_match_hostname-3.4.0.2.tar.gz 
# cd backports.ssl_match_hostname-3.4.0.2
# python setup.py install


https://github.com/facebook/tornado/archive/v3.2.0.tar.gz
# tar xvzf tornado-3.2.0.tar.gz
# cd tornado-3.2.0
# python setup.py install

-----------------------------------------------------------------------------------------------------------------------------------------------

https://pypi.python.org/packages/source/r/redis/redis-2.9.1.tar.gz
# tar xvzf redis-2.9.1.tar.gz
# cd redis-2.9.1
# python setup.py install

-----------------------------------------------------------------------------------------------------------------------------------------------
https://pypi.python.org/packages/source/s/six/six-1.5.2.tar.gz
# tar xvzf six-1.5.2.tar.gz
# cd six-1.5.2
# python setup.py install



https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.2.tar.gz
# tar xvzf python-dateutil-2.2.tar.gz
# cd python-dateutil-2.2

# python setup.py install


-----------------------------------------------------------------------------------------------------------------------------------------------
You'll also need argparse if you're running Python < 2.7:


https://pypi.python.org/packages/source/a/argparse/argparse-1.2.1.tar.gz
# tar xvzf argparse-1.2.1.tar.gz
# cd argparse-1.2.1
# python setup.py install

-----------------------------------------------------------------------------------------------------------------------------------------------
https://codeload.github.com/nkrode/RedisLive/zip/master
# unzip RedisLive-master.zip
# mv RedisLive-master RedisLive
-----------------------------------------------------------------------------------------------------------------------------------------------


2、RedisLive配置

# cd RedisLive/src


cp redis-live.conf redis-live.conf.bak
# vim redis-live.conf


{
    "RedisServers":
    [
        {
            "server": "192.168.14.192",
            "port" : 6379
        }
    ],
                                                  
    "DataStoreType" : "sqlite",
                                                  
    "RedisStatsServer":
    {
        "server": "192.168.14.192",
        "port" : 6381
    },
                                                  
    "SqliteStatsStore":
    {
        "path": "/opt/portal/RedisLive/src/db/redislive.sqlite"
    }
}

RedisServers为你要监控的redis实例,可以添加多个
如果redis有密码,可以在实例配置中加入password选项;


DataStoreType决定使用那种类型的数据存储,(推荐用sqlite)
如果是redis,使用RedisStatsServer作为数据存储的目标;(配置的redis 不要是被监控的,所以还是推荐用sqlite)
如果是sqlite,使用SqliteStatsStore作为数据存储的目标。


RedisStatsServer是用于存储RedisLive监控数据的redis实例,
if you don't have a spare redis instance to use to store RedisLive data, then you can configure RedisLive to use sqlite by changing to "DataStoreType" : "sqlite"


RedisLive的功能分两个部分:
一个部分是redis-server状态数据的采集,通过src/redis-monitor.py来执行;
另外一部分功能是提供对状态数据的查询服务,通过src/redis-live.py来提供web服务。


3、初始化DB

# cd db
# cat schema.sql | sqlite3 redislive.sqlite


===================================================================================================

4、配置RedisLive的定期监控

cd /opt/portal/RedisLive/src


后台运行不打日志
nohup ./redis-monitor.py --duration 120& >/dev/null 2>&1  
后台运行打日志
nohup ./redis-monitor.py --duration 120&> nohup.out   2>&1& 


===================================================================================================

5、服务启动

# ./redis-live.py


如果启动的时候报错
ImportError: No module named _sqlite3
解决:
  Python-2.7已经自带了sqllit不需要自己再安装sqlite
只要编辑源码下的connection.c这个文件
vi Python-2.7.3/Modules/_sqlite/connection.c





#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
。。。。。
#define HAVE_LOAD_EXTENSION
#endif
#endif


下面添加
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;

再次make


[root@was192 Python-2.7.3]# python
Python 2.7.3 (default, Nov  3 2014, 10:30:55) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>help()
>>>import sqlite3
>>> import dateutil.parser
没有报错。
ImportError: No module named dateutil.parser (之前python-dateutil安装目录有中文没有安装成功,所以才会报错)


===================================================================================================
6、效果展示
http://192.168.14.192:8888/index.html


 www.google.com不能访问的问题。上述path问题解决后,发现还是看不到曲线图。于是查看index.html源码,发现了一行(59行)
<script type="text/javascript" src="https://www.google.com/jsapi"></script>。
呵呵,最近google一直不能访问,看来就是因为不能下载到google的jsapi,
所以看不到曲线图了。于是通过代理来访问RedisLive的index.html,果然看到了令人期待曲线图。

你可能感兴趣的:(redis监控软件---RedisLive)