The installation document outlines a basic setup process for MMS and the agent. This guide provides a more in depth review of deployment and MMS agent configuration.
The agent does have some resource requirements and should run on separate systems to avoid impacting mongod and mongos performance. To monitor five or fewer nodes, you can safely deploy on an AWS “micro instance.” Similarly, if you are only monitoring a small number of databases, you may be able to deploy the agent on the system running the mongos process. Running PyMongo with the native extensions, which requires GCC, provides significant performance improvements. See Getting Started with MMS for more information.
Only one agent per group or environment will report to MMS at a time, but you can run multiple instances of the agent to provide redundancy. Secondary agents act as hot standbys. If you stop the agent process, MMS removes the agent from the “Agents” tab within a day. If an agent is offline the last ping times for that agent do not update. To install a second or third agent, simply repeat the installation process in the installation guide for each new agent. See instructions for automating the agent installation in the next section.
When the MMS agent restarts, there is a five minute delay before that agent will begin collecting data and sending pings to MMS. If you have multiple agents, this delay permits other agents in your infrastructure to become the “primary agent” and for MMS to determine which agent will be the primary.
During this interval, the restarted MMS agent will not collect data.
In most instances MMS will scale its request cycle to limit more expensive statistics gathering. The information on the DB Stats tab updates every 10 minutes, and the agent will throttle the frequency to reduce the impact on the database.  Even so, the “DB stats” operation impacts the performance of your database, as is possible when installations have a large number of databases and collections.
In these situations you must disable database stats collection. See the “DB Stats” section on the “Settings” page in the MMS Console before starting your agent.
|||The DB Stats tab will not appear until 30 minutes after you add the host to MMS.|
If you have multiple MongoDB systems in distinct environments and cannot monitor all systems with a single agent, you will need to add a new group. Having a second group makes it possible to run two agents, because the API and secret keys are unique to the group.
To add a new group click on the “Users” page, and click on the “Add New Group” link on the upper right hand side of the page. Then, specify the new group name and select the “Add New Group” button on the following next page to create the new group. After creating a group, only the current user account is a member that group. To add more people, click on the “Users” page in your new group.
You may also use a second group and agent to monitor a different set of MongoDB instances in the same environment if you want to segregate the hosts within the MMS console. A user can only view data from the hosts monitored in a single group at once.
After adding a second group, the MMS interface will have a drop down list that will allow you to change groups. Selecting a new group will refresh the current page with the data available from the servers in this group.
Although it’s not possible to delete a group, you can remove your user account from a group to suppress that data.
The agent you downloaded from the MMS site is automatically configured with the credentials for your account. You can download a configured copy of the agent by copying the link available in the Agents section of the “Settings” tab of the MMS console. This link will resemble the following:
Alternately, you may automate MMS agent deployments using an unconfigured agent, and the API and secret keys from the “API Key” and “Secret Key” sections of the settings page. The unconfigured agent is available at the following URL:
Unzip this archive and edit the settings.py file. Replace the strings “@API_KEY@” and “@SECRET_KEY@” with the “API” and “Secret Keys” defined for your account. You can find these in the “Settings” page of the MMS console.
You may embed this process in your existing deployment scripts to automatically install or redeploy new agents.
If you are installing PyMongo and the MMS agent on systems that do not have C compilers, you can create a .egg package of PyMongo with C extensions to install on your system or systems.
The packages distributed in PyPI for Windows include C extensions.
First, on a system that has a C-compiler, download the PyMongo source. Always download the source for the latest version of the driver, which you can find at the PyMongo page on PyPi.
The following example uses version 2.1.1. Issue the following command:
curl http://pypi.python.org/packages/source/p/pymongo/pymongo-2.1.1.tar.gz > pymongo-2.1.1.tar.gz
To install a C-compiler (i.e. gcc) and the necessary dependencies, Debian and Ubuntu users should issue the following command:
sudo apt-get install build-essential python-dev
Red Hat, CentOS, and Fedora Users should issue the following command:
sudo yum install gcc python-devel
Extract the driver as follows:
tar -zxvf pymongo-2.1.1.tar.gz
Change directories and build the .egg package with the following sequence:
cd pymongo-2.1.1 python setup.py bdist_egg
You can find .egg file in the dist/ sub-directory. The file name will resemble “pymongo-2.1.1-py2.7-linux-x86_64.egg” but may have a different name depending on your platform and the version of python you use to compile.
These “binary distributions,” will only work on systems that resemble the environment on which you built the package. In other words, ensure that operating systems and versions of Python and architecture (i.e. “32” or “64” bit) match.
Copy this file to the target system and issue the following command to install the package (with root or “sudo” privileges:)
The agents perform automatic self-updates when 10gen releases new versions of the agent daemon.
Auto-updating requires that agent run as a user that is capable of writing files to the directory that contains the agent.
If you need to create an initialization script to control the demonized process, consider the following resources:
You may also examine the scripts in your system’s /etc/init.d/ or /etc/rc.d/ directory. Ensure that the agent does not run with root privileges.
Use the update-rc.d utility on Debian and Ubuntu and the chkconfig tool on Red Hat related systems to add these scripts to the initialization process. Be sure to test the control script configuration. It is essential that you be able to start, stop, and restart the agent following a system reboot.
This section addresses a potential issue for users running a version of Python in the 2.4-series. Users of later Python versions do not require hmac.
If easy_install produces an error, or you see the following error in your agent logs, you will need to install the hmac package manually:
AttributeError:'builtin_function_or_method' object has no attribute 'new'
To install the hmac package, begin by downloading the latest source package. The following example uses version 20101005. Issue the following command:
curl http://pypi.python.org/packages/source/h/hmac/hmac-20101005.tar.gz > hmac-20101005.tar.gz
Always download the latest version of hmac, which you can find at the hmac page on PyPi.
Extract the files from the archive with the following command:
tar -zxf hmac-20101005.tar.gz
Change directories, build and install the package with the following sequence:
cd hmac-20101005/ python setup.py install
You may need root (i.e. sudo) privileges to run the final install step.