您的位置:首页 > 数据库 > Redis

zabbix针对redis监控

2015-08-27 17:38 651 查看
1、添加cron作业
find / -name redis-cli
使用crontab –e,在cron的配置文件中添加下面的行:
*/1 * * * * /usr/local/bin/redis-cli info > /tmp/redis.stat
注:通过redis-cli获取默认端口的性能数据,其它类似。
2、配置zabbix-agent
编辑/etc/zabbix/zabbix_agentd.conf,找到以下配置信息所在位置,并编辑:
UnsafeUserParameters=1
UserParameter=redis.stat[*],cat /tmp/redis.stat | grep "$1:" | cut -d":" -f2
注:UnsafeUserParameters=1是允许zabbix-agent使用root权限运行UserParameter中的命令;UserParameter是zabbix提供扩展性能数据的方法,可以存在多个定义,每个定义中对应一
性能数据,后面是每个性能数据提取的命令,对应的性能计数器名称通过$1传递过来。
3、数据采集过程验证
上面的配置完成以后,需要检测各个环境是否正常,需要检查性能数据是否能正常加载和传递。
1、cron环节
cat /tmp/redis.stat
2、zabbix-agent环节
zabbix_agentd -t redis.stat[hits]
3、zabbix-server环节
zabbix_get -s 127.0.0.1 -k redis.stat[hits]
注:1和2在zabbix-agent的机器上运行,3在zabbix-server所在的机器上运行。zabbix_get –s指定的是zabbix-agent所在的机器。

PS:

As root setup a cronjob:
* * * * * /usr/bin/redis-cli info > /tmp/redisstat

Add an user parameter to zabbix:
UserParameter=redis.stat[*],cat /tmp/redisstat | grep "$1:" | cut -d":" -f2

官方研究文档:https://github.com/blacked/zbx_redis_template
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  zabbix redis