|
| 1 | +.. include:: header.tmpl |
| 2 | + |
| 3 | +================================== |
| 4 | +MongoDB SNMP Support Documentation |
| 5 | +================================== |
| 6 | + |
| 7 | +This document outlines the use and operation of MongoDB's SNMP |
| 8 | +extension, which is is only available in the `MongoDB Subscriber Edition |
| 9 | +<http://www.10gen.com/mongodb-subscriber-edition-download>`_ |
| 10 | +(https://www.10gen.com/mongodb-subscriber-edition-download). |
| 11 | + |
| 12 | +MongoDB Installation |
| 13 | +-------------------- |
| 14 | + |
| 15 | +The MongoDB Subscriber Edition (including SSL and SNMP functionality) is |
| 16 | +available on four platforms. See the page on the `subscriber edition |
| 17 | +<https://www.10gen.com/mongodb-subscriber-edition-download>`_ for more |
| 18 | +information. |
| 19 | + |
| 20 | +Included Files |
| 21 | +-------------- |
| 22 | + |
| 23 | +The subscriber edition contains the following files: |
| 24 | + |
| 25 | +- ``MONGO-MIB.txt``: |
| 26 | + |
| 27 | + The ``MIB`` file that describes the data (i.e. schema) for MongoDB's |
| 28 | + SNMP output |
| 29 | + |
| 30 | +- ``mongod.conf``: |
| 31 | + |
| 32 | + The SNMP configuration file for reading the SNMP output of |
| 33 | + MongoDB. The SNMP configures the community names, permissions, |
| 34 | + access controls etc. |
| 35 | + |
| 36 | +Required Packages |
| 37 | +----------------- |
| 38 | + |
| 39 | +To use SNMP, you must install several prerequisites. The names of the |
| 40 | +pacakges vary by distribution, and are as follows: |
| 41 | + |
| 42 | +- *Ubuntu 11.04* requires ``libssl0.9.8``, ``snmp-mibs-downloader``, |
| 43 | + ``snmp``, and ``snmpd``. Issue a command that resembles the |
| 44 | + following to install these packages: :: |
| 45 | + |
| 46 | + sudo apt-get install libssl0.9.8 snmp snmpd snmp-mibs-downloader |
| 47 | + |
| 48 | +- *Red Hat Enterprise Linux 6.x series and Amazon Linux AMI* require: |
| 49 | + ``libssl``, ``net-snmp``, ``net-snmp-libs``, and ``net-snmp-utils``. |
| 50 | + |
| 51 | + .. ``libssl.so.10``, ``net-snmp-5.5-37.9.amzn1.x86_64``, ``net-snmp-libs-5.5-37.9.amzn1.x86_64`` |
| 52 | + ``net-snmp-utils-5.5-37.9.amzn1.x86_64`` |
| 53 | + |
| 54 | + Issue a command that resembles the following to |
| 55 | + install these packages: :: |
| 56 | + |
| 57 | + sudo yum install libssl net-snmp net-snmp-libs net-snmp-utils |
| 58 | + |
| 59 | +- SUSE Enterprise Linux requires ``libopenssl0_9_8``, ``libsnmp15``, |
| 60 | + ``slessp1-libsnmp15``, and ``snmp-mibs``. Issue a command that |
| 61 | + resembles the following to install these packages: :: |
| 62 | + |
| 63 | + sudo zypper install libopenssl0_9_8 libsnmp15 slessp1-libsnmp15 snmp-mibs |
| 64 | + |
| 65 | +Install MIB Configuration Files |
| 66 | +------------------------------- |
| 67 | + |
| 68 | +Ensure that the MIB directory, at ``/usr/share/snmp/mibs`` exits, by |
| 69 | +issuing the following command: :: |
| 70 | + |
| 71 | + sudo mkdir -p /usr/share/snmp/mibs |
| 72 | + |
| 73 | +Use the following command to create a symbolic link: :: |
| 74 | + |
| 75 | + sudo ln -s [/path/to/mongodb/distribution/]MONGO-MIB.txt /usr/share/snmp/mibs/ |
| 76 | + |
| 77 | +Replace ``[/path/to/mongodb/distribution/]`` with the path to your |
| 78 | +``MONGO-MIB.txt`` configuration file. |
| 79 | + |
| 80 | +Finally the ``mongod.conf`` file into the ``/etc/snmp`` directory |
| 81 | +with the following command: :: |
| 82 | + |
| 83 | + cp mongod.conf /etc/snmp/mongod.conf |
| 84 | + |
| 85 | +Replace ``[/path/to/mongodb/distribution/]`` with the path to your |
| 86 | +``mongod.conf`` file. |
| 87 | + |
| 88 | +Start Up |
| 89 | +-------- |
| 90 | + |
| 91 | +You can control the subscriber edition of MongoDB as any other |
| 92 | +``mongod``, using default or custom or control scripts. |
| 93 | + |
| 94 | +Use the following command to view all SNMP options available in your |
| 95 | +MongoDB: :: |
| 96 | + |
| 97 | + mongod --help | grep snmp |
| 98 | + |
| 99 | +The above command should return the following output: :: |
| 100 | + |
| 101 | + Module snmp options: |
| 102 | + --snmp-subagent run snmp subagent |
| 103 | + --snmp-master run snmp as master |
| 104 | + |
| 105 | +Ensure that the ``/data/db/`` (i.e. the path where MongoDB stores the |
| 106 | +data files.) and ``/var/log/mongodb/`` (i.e. the path where MongoDB |
| 107 | +writes the log output) exist, by issuing the following command: :: |
| 108 | + |
| 109 | + mkdir -p /var/log/mongodb/ /data/db/ |
| 110 | + |
| 111 | +Start the ``mongod`` instance with the following command: :: |
| 112 | + |
| 113 | + mongod --snmp-master --port 3001 --fork --dbpath /data/db/ --logpath /var/log/mongodb/1.log |
| 114 | + |
| 115 | +You may set all of these options in a `configuration file`_ at your |
| 116 | +discretion. |
| 117 | + |
| 118 | +To check if ``mongod`` is running with SNMP support, issue the |
| 119 | +following command: :: |
| 120 | + |
| 121 | + ps -ef | grep 'mongod --snmp' |
| 122 | + |
| 123 | +The command should return output that includes the following |
| 124 | +line. This indicates that the proper ``mongod`` instance is running: :: |
| 125 | + |
| 126 | + systemuser 31415 10260 0 Jul13 pts/16 00:00:00 mongod --snmp-master --port 3001 # [...] |
| 127 | + |
| 128 | +.. _`configuration file`: http://docs.mongodb.org/manual/reference/configuration-options/ |
| 129 | + |
| 130 | +.. raw:: latex |
| 131 | + |
| 132 | + \newpage |
| 133 | + |
| 134 | +Troubleshooting |
| 135 | +--------------- |
| 136 | + |
| 137 | +Always check the logs for errors if something doesn't run as |
| 138 | +expected, see the log at ``/var/log/mongodb/1.log``. The presence of |
| 139 | +the following line: :: |
| 140 | + |
| 141 | + [SNMPAgent] warning: error starting SNMPAgent as master err:1 |
| 142 | + |
| 143 | +indicates that the ``mongod`` cannot read the |
| 144 | +``/etc/snmp/mongod.conf`` file. |
| 145 | + |
| 146 | +Initial Testing |
| 147 | +--------------- |
| 148 | + |
| 149 | +Check for the snmp agent process listening on port 1161 with the |
| 150 | +following command: :: |
| 151 | + |
| 152 | + sudo lsof -i :1161 |
| 153 | + |
| 154 | +which return the following output: :: |
| 155 | + |
| 156 | + COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME |
| 157 | + mongod 9238 sysadmin 10u IPv4 96469 0t0 UDP localhost:health-polling |
| 158 | + |
| 159 | +Similarly, the next command: :: |
| 160 | + |
| 161 | + netstat -an | grep 1161 |
| 162 | + |
| 163 | +should return the following output: :: |
| 164 | + |
| 165 | + udp 0 0 127.0.0.1:1161 0.0.0.0:* |
| 166 | + |
| 167 | +Run ``snmpwalk`` Locally |
| 168 | +------------------------ |
| 169 | + |
| 170 | +``snmpwalk`` provides tools for retrieving and parsing the SNMP data |
| 171 | +according to the MIB. If you installed all of the required packages |
| 172 | +above, your system will have ``snmpwalk``. |
| 173 | + |
| 174 | +Issue the following command to collect data from ``mongod`` using |
| 175 | +SNMP: :: |
| 176 | + |
| 177 | + snmpwalk -m MONGO-MIB -v 2c -c mongodb 127.0.0.1:1161 1.3.6.1.4.1.37601 |
| 178 | + |
| 179 | +You may also choose to specify a the path to the MIB file: :: |
| 180 | + |
| 181 | + snmpwalk -m /usr/share/snmp/mibs/MONGO-MIB -v 2c -c mongodb 127.0.0.1:1161 1.3.6.1.4.1.37601 |
| 182 | + |
| 183 | +Use this command *only* to ensure that you can retrieve and validate |
| 184 | +SNMP data from MongoDB. |
0 commit comments