In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use the automatic discovery of Zabbix to monitor the mongo database", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the automatic discovery of Zabbix to monitor the mongo database" this article.
Monitoring mongo to write a template is actually quite fast, if the company uses the same port for each mongo, you can directly create a set of templates, and then the template can be linked to each server. However, if the company uses mongo ports that are inconsistent, it is recommended to use zabbix's auto-discovery function to automatically discover the port that mongo listens on and collect relevant data on it.
Take a look at the effect picture first.
This monitoring diagram is the filtering function of zabbix that may integrate related diagrams into one page.
The specific implementation of automatic discovery is as follows:
The exploration rules are configured as above, and the zabbix agent configuration on the machine is as follows:
UserParameter=mongo.discover,python / usr/local/zabbix/discover_mongo.py
Where / usr/local/zabbix/discover_mongo.py is an auto-discovery script, which contains the following:
# coding:utf-8 import simplejson as json import commands (status, output) = commands.getstatusoutput (''sudo netstat-tlnp | grep' mongod' | awk'{print $4}'| awk-fanglu'{print $(NF)}'| sort-u | grep-v "^ 28"'') outputs = output.split ('\ n') ports = [] for port in outputs: ports + = [{'{MONGOPORT}': port}] print json.dumps ({'data':ports}, sort_keys=True,indent=4)
Use the system command netstat to filter out the listening ports and output them in json format. At this point, you can automatically discover the port that zabbix listens on.
Note: netstat general zabbix users do not have permission, and need to be set by visudo. This script may have to make relative adjustments to its own environment.
After exploring the port, zabbix server needs to take the port as one of the parameters to fetch data from zabbix agent. The project prototype is configured as follows:
If there is more than one {# MONGOPORT} returned, the monitoring project is multiplied by several.
The definition of mongo.status is as follows (this definition is also under zabbix agent):
UserParameter=mongo.status [*], sh / usr/local/zabbix/check_mongo.sh-p $1-k $2-K $3
Use a script to pass parameters to obtain some data collection of mongo. Later, you can directly expand this script (- p represents the port). The serverStatus of mongo has multiple parameters, and opcounters is used for collection.-k and-K can obtain their values. The script is as follows:
#! / bin/sh while getopts "p:k:K:" opt do case $opt in p) mongo_port=$OPTARG;; k) key1=$OPTARG;; K) key2=$OPTARG;;?) Echo 'parameter is Wrongems' Exit 1X; esac done if [! "${mongo_port}"] | | [! "${key1}"] | [! "${key2}"] Then echo "parameter is null" exit 1 fi echo "db.serverStatus (). ${key1}" | mongo-- port=$ {mongo_port} | sed's Universe key2 /\ r\ nAccord g' | grep "${key2}" | awk-funding: |, |}'{print $2}'
After deploying a template and associating the template to the mongo machine, you can collect relevant operational information. Add another graphic prototype to the template, as follows:
After the template is applied, if there is no problem, you can collect the data of the mongo cluster on a web page to view in the screening of zabbix.
The above is all the contents of the article "how to use Zabbix Auto-Discovery to Monitor mongo Database". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.