Monitor MongoDB With SNMP on Linux
On this page
Enterprise Feature
SNMP is only available in MongoDB Enterprise .
Overview
MongoDB Enterprise can provide database metrics via SNMP, in support of centralized data collection and aggregation. This procedure explains the setup and configuration of a mongod
instance as an SNMP subagent, as well as initializing and testing of SNMP support with MongoDB Enterprise.
See also
Troubleshoot SNMP and Monitor MongoDB Windows with SNMP for complete instructions on using MongoDB with SNMP on Windows systems.
Configuration Files
MongoDB Enterprise includes the following SNMP configuration files:
MONGOD-MIB.txt
:The management information base (MIB) file that defines MongoDB’s SNMP output. On Ubuntu and Debian platforms, this file is shipped compressed as
MONGOD-MIB.txt.gz
and must be decompressed withgunzip
.mongod.conf.subagent
:The configuration file to run
mongod
as the SNMP subagent. This file sets SNMP run-time configuration options, including theagentXSocket
to connect to the SNMP master.mongod.conf.master
:The configuration file to run
mongod
as the SNMP master. This file sets SNMP run-time configuration options, including theagentaddress
to run on.
The MongoDB SNMP configuration files are provided with your MongoDB Enterprise installation, as follows:
If you installed MongoDB Enterprise via a package manager, these files are installed to the following directory as part of the package installation process:
Platform Path RHEL / CentOS /usr/share/doc/mongodb-enterprise-server-3.6.19
Ubuntu / Debian /usr/share/doc/mongodb-enterprise-server
SUSE /usr/share/doc/packages/mongodb-enterprise-server
If you installed MongoDB Enterprise from a
.tgz
tarball, these files were included in the tarball.
Procedure
Copy configuration files.
Copy the MongoDB SNMP configuration files from their installation location to their target directories, according to your platform:
- RHEL / CentOS
- Ubuntu / Debian
- SUSE
Navigate to the location where the SNMP files were installed. For example, if you installed the latest version of MongoDB via the
yum
package manager:Copy the two MongoDB SNMP files to their target directories:
Navigate to the location where the SNMP files were installed. For example, if you installed MongoDB via the
apt
package manager:Copy the
MONGOD-MIB.txt.gz
file to its target directory, and unzip it:Copy the
mongod.conf.subagent
file to its target directory:
Navigate to the location where the SNMP files were installed. For example, if you installed the latest version of MongoDB via the
zypper
package manager:Copy the two MongoDB SNMP files to their target directories:
Configure SNMP.
Edit the /etc/snmp/snmpd.conf
file, and add the following:
Install
snmpd
if it is not already installed:Edit the
/etc/snmp/snmpd.conf
file, and add the following:
Edit the /etc/snmp/snmpd.conf
file, and add the following:
This configuration defines a UNIX domain socket for communication between the master (snmpd
) and sub-agent (MongoDB), and defines basic SNMP permissions for access to the relevant MongoDB SNMP fields.
Note
To bind your master to a non-localhost IP address, add that IP address to the agentaddress
field in the /etc/snmp/snmpd.conf
file, and update the appropriate network security ACLs to permit a valid address range. An address range of 10.0.0.0/8 with a security name of “mynetwork” has been provided in the mongod.conf.master
configuration file as an example.
The above configuration is given as an example only; you may wish to customize permissions based on your site security requirements. While MongoDB support can provide guidance on configuring MongoDB for SNMP, configuring SNMP on operating systems is out of scope.
Start MongoDB.
Start mongod
with the snmp-subagent
to send data to the SNMP master.
Confirm SNMP data retrieval.
Verify that MongoDB is accessible for SNMP queries with the snmpwalk
testing command.
Install
snmpwalk
on your system:Run
snmpwalk
with the following parameters to verify the ability to collect data frommongod
:
DEBIAN ONLY: If necessary, add the
non-free
repository to your/etc/apt/sources.list
file to access thesnmp-mibs-downloader
package. For example, on Debian 9 “Stretch”, the primary repo entries might look like this:DEBIAN / UBUNTU: Install the
snmp-mibs-downloader
package to supply necessary MIB files, then restart thesnmpd
service to reload the new MIB files: