System Version CentOS5.10Python version 2.4.31, python support yum-yinstallpython-simplejson2, discovery script [root @ localhostetc] # ca
System Version CentOS5.10Python version 2.4.3 1. python supports yum-y install python-simplejson 2. discovery script [root @ localhost etc] # ca
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 on
Both the user name and password are
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: