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

Zabbix3.4 monitors mongodb status

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

Share

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

Mongodb has a db.serverStatus () command to check the running status of mongodb, so zabbix can call this command to monitor mongodb.

I. the use of the db.serverStatus () command

Note: only the Super Admin account has permission to use this command.

1. View the status of mongodb service

Echo "db.serverStatus ()" | mongo-- port 37485-u username-p 'password'-- authenticationDatabase 'admin'

2. Check the memory usage of mongodb

Echo "db.serverStatus () .mem" | mongo-- port 37485-u username-p 'password'-- authenticationDatabase' admin'

3. Check the number of mongodb connections

Echo "db.serverStatus () .connections" | mongo-- port 37485-u username-p 'password'-- authenticationDatabase' admin'

Second, create a monitoring profile

1. Write mongodb monitoring configuration file

Vim / etc/zabbix/zabbix_agentd.d/mongodb.conf

UserParameter=MongoDB.status [*], / bin/echo "db.serverStatus (). $1" | / data/mongodb/bin/mongo-- port 37485-u username-p 'password'-- authenticationDatabase' admin' | grep "$2" | awk-F':'{print $2}'| awk-F','{print $1} 'UserParameter=MongoDB.ok / bin/echo "db.serverStatus () .ok" | / data/mongodb/bin/mongo-- port 37485-u username-p 'password'-- authenticationDatabase' admin' | sed-n' 5p'UserParameter=MongoDB.connections [*], / bin/echo "db.serverStatus () .connections.$1" | / data/mongodb/bin/mongo-- port 37485-u username-p 'password'-- authenticationDatabase' admin' | sed-n5p'

Note: use the Super Admin account

2. Restart zabbix-agent

Systemctl restart zabbix-agent

3. Test on the zabbix server side

/ data/zabbix/bin/zabbix_get-s xxx.xxx.xxx.xxx-p 10050-k "MongoDB.status [mem,virtual]" / data/zabbix/bin/zabbix_get-s xxx.xxx.xxx.xxx-p 10050-k "MongoDB.connections [available]" / data/zabbix/bin/zabbix_get-s xxx.xxx.xxx.xxx-p 10050-k "MongoDB.ok"

Create a monitoring template

1. Add a monitoring template

2. Create an application set

Note: create an application set based on the items you want to monitor

3. Create a monitoring item

Note: please create according to the subitems you want to monitor, and create the subitems to be monitored one by one

4. Create a trigger

5. Create a monitoring graph

4. Add monitoring template to the host

5. Monitoring effect map

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

Wechat

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

12
Report