Get the App
SLTechnology News&Howtos  ›  Servers  › 

Zabbix3.4 monitors mongodb status

Shulou Source: shulou.com Published: 2022-06-02 17:55:51 10月25日 Update

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

Tags: Monitoring commands templates status subitems files administrators accounts applications management configuration hosts memory only graphics situations effects effects permissions triggers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Huawei MariaDB Docker