Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use zabbix to monitor MongoDB

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Now several game projects of the company mainly use MongoDB to store game data, so the monitoring of MongoDB is very important. Other monitoring methods for MongoDB can be found in the following articles:

MongoDB monitor one

MongoDB monitoring second mongotop

MongoDB Monitoring three MongoDB self-monitoring methods

MongoDB monitors four dbStats and collStats and replSetGetStatus

Http://mayulin.blog.51cto.com/1628315/575541

The basic idea of zabbix monitoring MongoDB is to first write a custom script to collect the status information of MongoDB, obtain it through the output of the db.serverStatus () function, and then add the corresponding template.

The version of MongoDB used in this article is 2.4.6

The following items are mainly monitored:

Memory usage

Number of connections

Lock

Refresh write operations to disk

Number of queries, inserts, deletions, updates, etc., executed per second

The number of indexes accessed per second and the number of hits per second

Total number of page errors generated by MongoDB

Network traffic status of MongoDB

Write a monitoring script mongodb_status.sh

Port 28018 is used by default here, and you can modify the port according to the situation.

This script determines the level of getting the value based on the number of parameters passed.

# This script is used to get mongodb server status#echo "db.serverStatus () .uptime" | mongo 192.168.5.23:30002/admin#echo "db.serverStatus () .mem.mapped" | mongo 192.168.5.23:30002/admin#echo "db.serverStatus () .globalLock.activeClients.total" | mongo 192.168.5.23:30002/admincase $# in 1) output=$ (/ bin/echo "db.serverStatus (). $1" | / data/app_platform/mongodb/bin/mongo Admin-- port 28018 | sed-n '3p') ; 2) output=$ (/ bin/echo "db.serverStatus (). $1.port 2" | / data/app_platform/mongodb/bin/mongo admin-- port 28018 | sed-n '3p'); 3) output=$ (/ bin/echo "db.serverStatus (). $1.02.room3" | / data/app_platform/mongodb/bin/mongo admin-- port 28018 | sed-n' 3p'); esac#check if the output contains "NumberLong" if [["$output" = ~ "NumberLong"] Then echo $output | sed-n 's/NumberLong (/ / p' | sed-n's /) / / p'else echo $outputfi

two。 Add zabbix profile mongodb_status.conf

Put mongodb_status.conf in the / usr/local/zabbix/etc/zabbix_agentd.conf.d/ directory

You need to pay attention to the settings in the main configuration file of zabbix

Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/

UnsafeUserParameters=1

# echo "db.serverStatus () .mem.mapped" | mongo admin-- host xxxx-- port xxx-uroot-pxxxx#echo "db.serverStatus () .mem.mapped" | mongo 10.4.9.112:28018/admin-uroot-pxxxx#UserParameter=MongoDB.Status [*], / bin/echo "db.serverStatus (). $1.Secret2" | / data/app_platform/mongodb/bin/mongo admin-- port 28018 | sed-n '3p'UserParameter=MongoDB.Status [*], / usr/local/zabbix/bin/mongodb_status.sh $1 $2 $3

3. Add MongoDB Monitoring template

Attached is the reference template

Attachment: http://down.51cto.com/data/2364996

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report