Automatic Discovery and monitoring of apsaradb for Redis Based on Zabbix monitoring

Source: Internet
Author: User
Tags redis cluster install redis

Automatic Discovery and monitoring of apsaradb for Redis Based on Zabbix monitoring

System Version: CentOS5.10
Python version 2.4.3

1. python support
Yum-y install python-simplejson

2. discovery script
[Root @ localhost etc] # cat redis_port.py

#! /Usr/bin/env python
Import OS
# Import json
Import simplejson as json # Special notes
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. Execute the script
[Root @ localhost etc] # python redis_port.py
{
"Data ":[
{
"{# REDISPORT}": "6379"
}
]
}

4. zabbix_agent settings
[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 permission
[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 abve.

6. Server Verification
[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. Import and download templates on the zabbix web interface, add monitoring metrics, and check monitoring Images

For details about downloading the apsaradb for redis template, see:

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is available in/July 6, 2015,/July 19, July,/apsaradb for Redis automatically discovered and monitored/

For the download method, see

------------------------------------------ Split line ------------------------------------------

Install and test Redis in Ubuntu 14.04

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.