David Mytton
posted this on Jan 29 15:52
1) Dependancies
The agent uses the pymongo module (minimum version 1.8) to interact with MongoDB. You must have this installed to use the MongoDB monitoring functionality.
a) Check if you have pymongo already
From the command line, enter the Python shell by running
python
Once the shell appears, enter:
import pymongo
When you hit return, if the command completes and you get no errors then you have the module already installed and can skip to step 2 below. If you get ImportError: No module named pymongo then follow the instructions below.
Also check the version number so you have the latest version with all updates. Older versions do not support some features / syntax so we recommend at least version 2.1 and require at least version 1.8. You can check your version by launching the python shell:
import pymongo
python.version
b) Installation
easy_install pymongo
If you get an error here or easy_install cannot be found, you will need to install manually:
git clone git://github.com/mongodb/mongo-python-driver.git pymongo cd pymongo sudo python setup.py install
2) Agent configuration
The agent /etc/sd-agent/config.cfg file requires 1 additional config line to be completed to allow the agent to connect to your MongoDB server. If you are upgrading from an older agent version and these lines do not exist, you can copy/paste them in anywhere in the file.
mongodb_server:
Fill out the details for your MongoDB server. Your mongodb_server will generally be localhost unless you want the agent to connect to a remote server.
mongodb_server: mongodb://localhost
a) Different ports
If MongoDB is running on a different port than the default, this can be handled with a colon (:) followed by the port number. Assuming a custom port of 12345, the line in the configuration would look like this.
mongodb_server: mongodb://localhost:12345
b) Authentication
If you have authentication enabled then you will need to provide a user for the agent to connect with. If you enable the advanced mongodb_dbstats and/or mongodb_replset options below this user will need to be on the admin database (i.e. it has access to all databases).
mongodb_server: mongodb://user:pass@localhost
Specifying the port here is the same as above.
c) Advanced database and replica set monitoring
2 additional options can be set if you wish to enable the advanced monitoring of your databases and replica sets. These default to off because there is a small performance impact, although it is generally negligible (even on large clusters).
Add these 2 lines to your config file if they do not already exist:
mongodb_dbstats: yes mongodb_replset: yes
Note that once you enable these, it will take up to 5 minutes for the full range of data to be displayed in Server Density.
Also note that the MongoDB dashboard is only compatible with replica sets and not master/slave or replica pairs.
And one more note: the optime value is only available as of MongoDB 1.8. This shows how far behind slaves are in replication.
3) Restart agent
Restart the agent to start the monitoring, which will take up to 5 minutes to show in the Server Density UI.