59

使用zabbix监控redis内存使用

 5 years ago
source link: https://www.linuxprobe.com/zabbix-redis-mem.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本篇提到的监控环境是有条件的,即默认单机只运行一个redis实例,且默认运行的端口是6379(也可以是其他端口,需要通过sed -i 's/6379/你修改的端口/g' xml模板文件 修改模板文件里的端口号) 。即然有这么多局限,岂不是适应用环境很差。确实,本篇算是一个基础部分,为后面提到的lld(low level discovery)自动发现做铺垫 。由于前面几部分也对基础的东西做了很多总结,这里很基本的东西不提,直接上步骤。

1、导入模板

同样,模板我已上传到 github项目 上 。直接下载,通过下面的步骤导入模板:点击configuration ----> templates ------> import -------> 导入下载的xml文件 。

2、客户端key配置

在被监控的主机上,打开/etc/zabbix/zabbix_agentd.conf 配置文件,在最后一行加入:

UserParameter=redis_stats[*],redis-cli -h 127.0.0.1 -p $1 info|grep $2|cut -d : -f2

配置完成后通过/etc/init.d/zabbix_agentd restart 重启服务并应用最新的配置文件。

注:在该文件中还要确认UnsafeUserParameters=1 。

3、服务端验证

验证方式还是通过zabbix_get 程序去获取数据,能正常得到数据,证明通信正常。

# zabbix_get -s 172.20.0.20 -k redis_stats[6379,total_connections_received]
2249669

上面正常从被监控主机上取得了数据,c/s通信正常 。

4、添加主机关联模板

通过configuration ------> hosts ------> create host 创建新的主机,并在templates项中,查找Templates Redis_6379 模板,并link 该模板 。就可以正常获取数据了。同样,验证数据使用 monitoring ----- lastest data ---- 打到刚刚添加的主机,查看是否有数据 。

5、查看监控图

通过monitoring ----- graphs 可以查看刚刚添加的监控项的监控图,这里只截下内存使用情况图


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK