Zabbix Automatic Discovery Monitoring MONGO

Source: Internet
Author: User

1:zabbix automatically discovers MONGO monitored ports and returns the format required for Zabbix_server, scripts are deployed on zabbix_agent and the path is/usr/local/zabbix/zabbix_discover_ mongo.sh, the script reads 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\t\t{\" {#MONGOPORT}\ ": \" $line \ "}\n"

Else

printf "\t\t\t{\" {#MONGOPORT}\ ": \" $line \ "},\n"

Let "mycount++"

Fi

Done


printf ' \t]\n '

printf '}\n '

Exit 0


Script Usage Considerations:

1: You need to turn on Zabbix sudo permissions, Visudo add the following:

Zabbix all= nopasswd:/usr/sbin/ss

Defaults:zabbix!requiretty


2: Add the following configuration on the Zabbix_agentd side:

Vim/usr/local/zabbix/etc/zabbix_agentd.conf.d/zwh_zabbix.conf

userparameter=zabbix.discovery.mongo,/usr/local/zabbix/zabbix_discover_mongo.sh

Userparameter=mongo.status[*],echo "Db.serverstatus (). $" |mongo 127.0.0.1:$1|sed ' s/,/\r\n/g ' |grep "$" |awk-f ': |,|} ' ' {Print $$2} '

Restart ZABBIX_AGENTD after adding configuration


3: Create a new monitoring template name on the zabbix_server side of the page such as: template Mongo Discovery Service, and then add a discovery rule, the key value is filled in the content of Zabbix.discovery.mongo.


4: Create a new project prototype on the Zabbix_server side of the page, with the following key values:

{#MONGOPORT}:available connections mongo.status[{#MONGOPORT},connections,available]

{#MONGOPORT}:current connections mongo.status[{#MONGOPORT},connections,current]

{#MONGOPORT}:d elete 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]

Separately monitor MONGO available connections, current connections. The number of deletions, insertions, queries, and updates per second, these are bad variables, and the type used is float.


5: Create a new trigger in zabbix_server and alarm when the available connection is less than 100. Select the prototype and define your own triggers.


6: Create a new graphic on the Zabbix_server, the available connection and the current connection into a graph, query volume, etc. into a graph, the template is probably complete.

This article is from the "Zhangweihong" blog, make sure to keep this source http://zhuangweihong.blog.51cto.com/8808431/1771923

Zabbix Automatic Discovery Monitoring MONGO

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.