Zabbix automatically detects and monitors redis

Source: Internet
Author: User

Zabbix automatically detects and monitors redis

1: Write an automatic detection script on zabbix_agentd, mainly to automatically discover the redis monitoring port. The script is as follows:

Vim/usr/local/zabbix/zabbix_discover_redis.sh
#! /Bin/sh
# Zhuangweihong 20160419 zabbix discover redis

Res = 'sudo ss-tulnp | grep redis | awk' {print $ (NF-2)} '| awk-F': ''{print $ (NF )} '| sort-U'
If [[-z "$ res"]; then
Echo "redis has not find"
Exit 2
Fi
Count = 'echo "$ res" | wc-l'
If [$ count-eq 0]; then
Echo "redis has not find"
Exit 2
Fi
Printf' {\ N'
Printf' \ t "data": [\ N'
Mycount = 1
Echo "$ res" | while read line; do
If [$ count-eq $ mycount]; then
Printf "\ t {\" {# REDISPORT} \ ": \" $ line \ "} \ n"
Else
Printf "\ t {\" {# REDISPORT} \ ": \" $ line \ "}, \ n"
Let "mycount ++"
Fi
Done


Printf' \ t] \ N'
Printf'} \ N'
Exit 0

Notes for automatically discovering scripts:
1: The zoodo zabbix user needs the ss running permission. The configuration is as follows:

Zabbix ALL = NOPASSWD:/usr/sbin/ss
Ults: zabbix! Requiretty

2: Configure zabbix_agentd as follows:
UserParameter = zabbix. discovery. redis,/usr/local/zabbix/zabbix_discover_redis.sh
UserParameter = redis. status [*], redis-cli-p $1 info | grep "$2:" | cut-d:-f2


Notes for Configuration:
1: zabbix_discover_redis.sh zabbix requires the execution permission
2: The redis server does not have a password. otherwise, an additional verification is required.

3: restart zabbix_agentd after configuration.

3: configure a Template on the zabbix server webpage, for example, Template Redis Discovery Service

4: Create a Discovery rule named Redis discovery, key value configuration: zabbix. Discovery. redis.

5. Create a project prototype. The name and corresponding key value are as follows:
{# REDISPORT}: Redis Connected Clients redis. status [{# REDISPORT}, connected_clients]
{# REDISPORT}: Redis mem_fragmentation_ratio redis. status [{# REDISPORT}, mem_fragmentation_ratio]
{# REDISPORT}: Redis Port Check net. tcp. service [tcp, {# REDISPORT}]
{# REDISPORT}: Redis used_memory. redis. status [{# REDISPORT}, used_memory]
{# REDISPORT}: Redis used_memory_rss. redis. status [{# REDISPORT}, used_memory_rss]
Monitoring redis client connections, memory fragments, and redis port survival detection respectively.

6. Create a trigger:
1: Port Check

2: The number of connected clients depends on port check.
3: for fragmentation, it depends on Port Check

7. Create a graphic prototype:
1: Number of connected clients

2: memory used by redis and actually useful memory.

Some Zabbix Tutorials:

Compile and install Zabbix2.4.5 source code in Ubuntu 14.04

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy Zabbix in CentOS 6.3

Zabbix distributed monitoring system practice

Under CentOS 6.3, Zabbix monitors apache server-status

Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3

Install Zabbix 2.0.6 in 64-bit CentOS 6.2

ZABBIX details: click here
ZABBIX: click here

This article permanently updates the link address:

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.