器量大者,福泽必厚
全部博文(587)
分类: LINUX
2014-12-25 09:29:09
Redis监控
1:安装redis,启动redis,redis默认的端口为6379 ##该步骤省略.....
下面是监控的相关步骤:
1) Put zbx_redis.conf into your zabbix_agentd.conf config subdirectory (like:/etc/zabbix/zabbix_agentd.d/).
2) Change script name in zbx_redis.conf to use zbx_redis_stats.py if need it (by default there is a .js version script). Redis server params can be passed to the python script as arguments e.g.:
zbx_redis_stats.py localhost -p 6379 -a mypassword ##这里我没有修改zbx_redis.conf的任何内容!
3) Change your zabbix_agentd.conf config so it will include this file:
Include=/etc/zabbix/zabbix_agentd.d/
4) Put zbx_redis_stats.js or zbx_redis_stats.py into your zabbix_agentd.conf config subdirectory (like: /etc/zabbix/script/redis/).
5) Change paths in zbx_redis.conf if need it.
6) In working dir (/etc/zabbix/script/redis/) do:
For use node.js verson script:
npm install redis ##使用这个前,先要安装npm,我执行如下:yum -y install epel-release && yum -y install npm
chmod +x zbx_redis_stats.js
For use python verson script: ##如果不准备使用python,可以忽略该内容
pip install redis
chmod +x zbx_redis_stats.py
7) Import zbx_redis_template.xml into zabbix in Tepmplate section web gui. ##下载下来有两个模板文件,注意不要导错!
我在这里遇到一个问题,有数据,但不出图:
我在128机器上(我的zabbix proxy),执行如下:
[root@localhost tmp]# /usr/local/zabbix/bin/zabbix_get -s 192.168.10.134 -p 10050 -k redis[192.168.10.134,used_memory,none] ##注意[]内的3项之间不能用空格,否则不会有数据
810120
后来又发现一个问题,尽管可以在zabbix proxy上获取到数据,但就是不能出图。
解决方法:
在zabbix client下修改zabbix.agend.conf文件中修改日志的级别为DebugLevel=4 ,发现执行了
[root@zabbiclient1 ~]# /etc/zabbix/script/zbx_redis_stats.js zabbixclient1 used_memory none
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
Error: Error: Redis connection to zabbixclient1:6379 failed - getaddrinfo ENOTFOUND
显然是zabbixclient1 无法被解析。于是在hosts中加入如下:
^C[root@zabbiclient1 ~]# vi /etc/hosts ,
127.0.0.1 zabbixclient1
问题即可解决!