Zabbix monitoring of Redis automatically discovers and monitors

Source: Internet
Author: User

Zabbix monitoring of Redis automatically discovers and monitors

Some of the information comes from the Internet and is thanked here.

System version centos5.10

Python version 2.4.3

1. Python Support

Yum-y Install Python-simplejson

2. Discovery Script

[email protected] etc]# cat redis_port.py

#!/usr/bin/env pythonimport os#import jsonimport Simplejson as JSON #特别要注意的地方t =os.popen ("" "Sudo netstat-tlpn |grep codis -server|grep 0.0.0.0|awk ' {print $4} ' |awk-f: ' {print $} ' "") ports = []for port in T.readlines (): R = os.path.ba SENAME (Port.strip ()) ports + = [{' {#REDISPORT} ': R}]print json.dumps ({' Data ':p Orts},sort_keys=true,indent=4,separato Rs= (', ', ': '))

3, try to execute the script

[email protected] etc]# python redis_port.py
{
"Data": [
{
"{#REDISPORT}": "6379"
}
]
}

4,zabbix_agent settings

[Email protected] ~]# 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 $ info|grep $2|cut-d:-f2

[Email protected] ~]# chmod a+x/usr/local/zabbix/etc/redis_port.py

5,sudo Permissions

[Email protected] ~]# tail-n 1/etc/sudoers
Zabbix all= (Root) nopasswd:/bin/netstat

[Email protected] ~]# sed-i ' s/^defaults.*.requiretty/#Defaults requiretty/'/etc/sudoers
[[email protected] ~]# grep requiretty/etc/sudoers
#Defaults Requiretty
# changed in order to being able to use sudo without a tty. See requiretty above.

6, service-side verification

[Email protected] ~]# zabbix_get-s 172.17.2.114-k redis.discovery
{
"Data": [
{
"{#REDISPORT}": "6379"
}
]
}

[Email protected] ~]# zabbix_get-s 172.17.2.114-k redis_stats[6379,used_memory:]
651534360
[Email protected] ~]# zabbix_get-s 172.17.2.114-k "redis_stats[6379,blocked_clients]"
0

7,zabbix Web Interface import downloaded template, check monitoring image after adding monitoring item

Redis templates See attachments

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/CE/wKiom1Wov4-y7hlFAAYCdWUDcrw386.jpg "title=" Redis.png "alt=" Wkiom1wov4-y7hlfaaycdwudcrw386.jpg "/>


This article is from the "jerrymin" blog, make sure to keep this source http://jerrymin.blog.51cto.com/3002256/1675728

Zabbix monitoring of Redis automatically discovers and monitors

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.