Zabbix automatic detection and monitoring mongo

Source: Internet
Author: User

Zabbix automatic detection and monitoring mongo

1: zabbix automatically discovers the mongo monitoring port and returns the format required by zabbix_server. The script is deployed on zabbix_agent and the path is/usr/local/zabbix/zabbix_discover_mirror.sh. The script content is as follows:
#! /Bin/sh
# Zhuangweihong 20160419 zabbix discover mysql
Res = 'sudo ss-tulnp | grep mongo | grep-v 28107 | awk '{print $ (NF-2)}' | awk-F ': ''{print $ (NF)} '| sort-U'
Count = 'echo "$ res" | wc-l'
If [$ count-eq 0]; then
Echo "mysql 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 {\" {# MONGOPORT} \ ": \" $ line \ "} \ n"
Else
Printf "\ t {\" {# MONGOPORT} \ ": \" $ line \ "}, \ n"
Let "mycount ++"
Fi
Done


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

Script usage considerations:
1: You need to enable the sudo permission for zabbix. Add the following permissions to do:
Zabbix ALL = NOPASSWD:/usr/sbin/ss
Ults: zabbix! Requiretty

2: Add the following configuration on zabbix_agentd:

Vim/usr/local/zabbix/etc/zabbix_agentd.conf.d/zwh_zabbix.conf
UserParameter = zabbix. discovery. mongo,/usr/local/zabbix/zabbix_discover_assist.sh
UserParameter = mongo. status [*], echo "db. serverStatus (). $2 "| mongo 127.0.0.1: $1 | sed's/,/\ r \ n/G' | grep" $3 "| awk-F': |, |} ''{print $2 }'
Restart zabbix_agentd after adding the configuration.

3: create a monitoring Template Name on the zabbix_server page, for example, Template Mongo Discovery Service, and add a discovery rule. The content filled in by the key value is zabbix. Discovery. mongo.

4: Create a project prototype on the zabbix_server webpage. The key value of the project name is as follows:
{# MONGOPORT}: available connections mongo. status [{# MONGOPORT}, connections, available]
{# MONGOPORT}: current connections mongo. status [{# MONGOPORT}, connections, current]
{# MONGOPORT}: delete per second mongo. status [{# MONGOPORT}, opcounters, delete]
{# MONGOPORT}: insert per second mongo. status [{# MONGOPORT}, opcounters, insert]
{# MONGOPORT}: query per second mongo. status [{# MONGOPORT}, opcounters, query]
{# MONGOPORT}: update per second mongo. status [{# MONGOPORT}, opcounters, update]
Monitor available mongo connections and current connections respectively. The number of Delete, insert, query, and update operations per second is a variable of some difference and the float type is used.

5: Create a trigger on zabbix_server. An alarm is triggered when the available connections are less than 100. Select a prototype and define its own trigger.

6: Create a New Graph on zabbix_server, make available connections into a graph with the current connection, and make the query volume into a graph. Then the template is completed.

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.