Zabbix monitoring Redis Multi-instance (low-level discovery)

Source: Internet
Author: User

For multi-instance deployments of Tomcat, Redis and other applications, you can use Zabbix's low-level discovery feature to monitor and reduce repetitive operations.   Note: Zabbix version: Zabbix 3.0.21, server configuration 1, create template template name: Template_redis_monitor 2, create an Autodiscover rule to add an Autodiscover rule to a template that you have created Template_redis_monitor. 3, add the monitoring item prototype from the above can be seen, I have created 4, as follows: Look at one of the following: Take a look at the monitoring items after the Host association template: second, the client configuration zabbix_agentd.conf configuration file Add or modify the following:
unsafeuserparameters=1   #允许zabbix用户运行root命令UserParameter=redis.discovery,/data/zabbix/ externalscripts/redis_port.py  #获取json格式数据, newspapers Userparameter=redis[*],/data/zabbix/externalscripts /redis_stats. SH $1 $2    #自定义Key值

The following two scripts are used:

Script for Discovery Port:

#Catredis_port.py#!/usr/bin/Envpythonimport osimport Jsonp=os.popen ("""sudo netstat-anp|awk-f: '/redis-server/&&/listen/{sub (/. */,""($), if ($) print $} '""") Ports= [] forPortinchP.readlines (): R= Os.path.basename(Port.strip ()) Ports+= [{'{#REDISPORT}': R}] Print Json.dumps ({'Data':p orts},sort_keys=true,indent=4, separators= (',',':'))

To get a script for monitoring data:

#CatRedis_stats.SH#!/bin/Bashmetric=" $"PORT="${2:-6379}"Cache_file="/data/zabbix/externalscripts/redis_$port.cache"Redis-cli-p ${port} A'uslf93suvwtsf$$#@w' Info> ${cache_file}2>/dev/NULL|| Exit1awk-F'[:,]+' '/' "${metric}"':/{gsub (/^[^0-9]+/, "", $;p rint)'${cache_file}
Third, test on Zabbix_server test, execute the following command: Zabbix_get-s client ip-k Redis.discovery

Client Redis Two instance ports are 6380 and 6444, and you can see that the Autodiscover port is successful! Test to see if data is available: Get data successfully! Finally, you can create a graph to view the data: Other issues: ZABBIX_AGENTD is Zabbix user initiated, the default cannot execute commands such as netstat-p, so you can configure sudo resolution. You can also use chmod +s/usr/bin/netstat for resolution.

Zabbix monitoring Redis Multi-instance (low-level discovery)

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.