Monitor MongoDB With SNMP on Linux

Enterprise Feature

SNMP is only available in MongoDB Enterprise.

Overview

MongoDB Enterprise can provide database metrics via SNMP, insupport of centralized data collection and aggregation. This procedureexplains the setup and configuration of a mongod instanceas an SNMP subagent, as well as initializing and testing of SNMPsupport with MongoDB Enterprise.

See also

Troubleshoot SNMP andMonitor MongoDB Windows with SNMP forcomplete instructions on using MongoDB with SNMP on Windowssystems.

Considerations

Only mongod instances provide SNMPsupport. mongos and the other MongoDB binaries do notsupport SNMP.

Configuration Files

Changed in version 2.6.

MongoDB Enterprise contains the following configuration files tosupport SNMP:

  • MONGOD-MIB.txt:

The management information base (MIB) file that defines MongoDB’sSNMP output.

  • mongod.conf.subagent:

The configuration file to run mongod as the SNMPsubagent. This file sets SNMP run-time configuration options,including the AgentX socket to connect to the SNMP master.

  • mongod.conf.master:

The configuration file to run mongod as the SNMPmaster. This file sets SNMP run-time configuration options.

Procedure

Copy configuration files.

Use the following sequence of commands to move the SNMPconfiguration files to the SNMP service configuration directory.

First, create the SNMP configuration directory if needed and then, fromthe installation directory, copy the configuration files to the SNMPservice configuration directory:

  1. mkdir -p /etc/snmp/
  2. cp MONGOD-MIB.txt /usr/share/snmp/mibs/MONGOD-MIB.txt
  3. cp mongod.conf.subagent /etc/snmp/mongod.conf

The configuration filename is tool-dependent. For example, whenusing net-snmp the configuration file is snmpd.conf.

By default SNMP uses UNIX domain for communication between theagent (i.e. snmpd or the master) and sub-agent (i.e. MongoDB).

Ensure that the agentXAddress specified in the SNMPconfiguration file for MongoDB matches the agentXAddress in theSNMP master configuration file.

Start MongoDB.

Start mongod with the snmp-subagent to send datato the SNMP master.

  1. mongod --snmp-subagent

Confirm SNMP data retrieval.

Use snmpwalk to collect data from mongod:

Connect an SNMP client to verify the ability to collect SNMP datafrom MongoDB.

Install the net-snmp package to accessthe snmpwalk client. net-snmp provides the snmpwalkSNMP client.

  1. snmpwalk -m /usr/share/snmp/mibs/MONGOD-MIB.txt -v 2c -c mongodb 127.0.0.1:<port> 1.3.6.1.4.1.34601

<port> refers to the port defined by the SNMP master,not the primary port used by mongod forclient communication.

Optional: Run MongoDB as SNMP Master

You can run mongod with the snmp-masteroption for testing purposes. To do this, use the SNMP masterconfiguration file instead of the subagent configuration file. Fromthe directory containing the unpacked MongoDB installation files:

  1. cp mongod.conf.master /etc/snmp/mongod.conf

Additionally, start mongod with the snmp-masteroption, as in the following:

  1. mongod --snmp-master