Home > Database > Mysql Tutorial > Zabbix监控之Redis自动发现并监控

Zabbix监控之Redis自动发现并监控

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:53:46
Original
1243 people have browsed it

系统版本CentOS5.10Python版本2.4.3 1、python支持yum -y install python-simplejson 2、discovery脚本[root@localhost etc]# ca

系统版本CentOS5.10
Python版本2.4.3

1、python支持
yum -y install python-simplejson

2、discovery脚本
[root@localhost etc]# cat  redis_port.py

#!/usr/bin/env python
import os
#import json
import simplejson as json  #特别要注意的地方
t=os.popen("""sudo netstat -tlpn |grep codis-server|grep 0.0.0.0|awk '{print $4}'|awk -F: '{print $2}' """)
ports = []
for port in  t.readlines():
        r = os.path.basename(port.strip())
        ports += [{'{#REDISPORT}':r}]
print json.dumps({'data':ports},sort_keys=True,indent=4,separators=(',',':'))

3,、试执行脚本
[root@localhost etc]# python redis_port.py
{
    "data":[
        {
            "{#REDISPORT}":"6379"
        }
    ]
}

4,,zabbix_agent设置
[root@localhost ~]# tail -n 2 /usr/local/zabbix/etc/zabbix_agentd.conf
UserParameter=redis.discovery,/usr/local/zabbix/etc/redis_port.py
UserParameter=redis_stats[*],redis-cli -h 127.0.0.1 -a redis_passwd -p $1 info|grep $2|cut -d : -f2
[root@localhost ~]# chmod a+x /usr/local/zabbix/etc/redis_port.py

5,sudo权限
[root@localhost ~]# tail -n 1 /etc/sudoers
zabbix ALL=(root) NOPASSWD:/bin/netstat
[root@localhost ~]# sed -i 's/^Defaults.*.requiretty/#Defaults    requiretty/' /etc/sudoers
[root@localhost ~]# grep requiretty /etc/sudoers
#Defaults    requiretty
# changed in order to be able to use sudo without a tty. See requiretty above.

6,服务端验证
[root@zabbixserver-nginx ~]# zabbix_get -s 172.17.2.114 -k redis.discovery
{
    "data":[
        {
            "{#REDISPORT}":"6379"
        }
    ]
}

[root@zabbixserver-nginx ~]# zabbix_get -s 172.17.2.114 -k redis_stats[6379,used_memory:]
651534360
[root@zabbixserver-nginx ~]# zabbix_get -s 172.17.2.114 -k "redis_stats[6379,blocked_clients]"
0

7,zabbix web界面导入下载的模板,添加监控项后检查监控图像

Zabbix监控之Redis自动发现并监控

redis模板下载见下:

------------------------------------------分割线------------------------------------------

免费下载地址在

用户名与密码都是

具体下载目录在 /2015年资料/7月/19日/Zabbix监控之Redis自动发现并监控/

下载方法见

------------------------------------------分割线------------------------------------------

Ubuntu 14.04下Redis安装及简单测试

Redis集群明细文档

Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis

Redis系列-安装部署维护篇

CentOS 6.3安装Redis

Redis安装部署学习笔记

Redis配置文件redis.conf 详解

Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里

本文永久更新链接地址

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template