- On Prem MMS Monitoring >
- Getting Started with On Prem MMS Monitoring >
- Install Monitoring Agent >
- Deploy the Monitoring Agent in Production
Deploy the Monitoring Agent in Production¶
Overview¶
For production deployments of On Prem MMS Monitoring, you will want to daemonize the agent process and ensure that it restarts following a system restart. Your operating system likely has a preferred method for managing daemon processes.
Prerequisites¶
If your datacenter requires that you route outbound https connections via a proxy, you must use a version of Python greater than 2.6.1.
Considerations¶
You must configure the networking rules of your deployment so that:
- the Monitoring Agent can connect to all mongod and mongos instances that you want to monitor.
- the Monitoring agent can connect to On Prem MMS Monitoring server on port 443
(i.e.
https
.)
The On Prem MMS Monitoring server does not make any outbound connections to the agents or to MongoDB instances. If Exposed DB Host Check is enabled, the On Prem MMS Monitoring server will attempt to connect to your servers occasionally as part of a vulnerability check.
Ensure all mongod and mongos instances are not accessible to hosts outside your deployment.
Procedure¶
Daemonize the Process¶
As a temporary measure, the following command will start the agent process detached from the current terminal session:
Replace [LOG-DIRECTORY]
with the path to your MongoDB logs.
This command allows the agent survive the current terminal session and
writes all messages to the agent.log
file. You may include this
command in your MongoDB control script or use your system’s
/etc/rc.local
equivalent; however, avoid running the agent as
root.
Create Control Scripts¶
If you need to create an initialization script to control the daemonized process, consider the resources listed in the Additional Information section below.
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.
Automate Agent Deployments¶
The agent you downloaded from the On-Prem MongoDB Management Service site is automatically configured with the credentials for your account. You can download a configured copy of the Monitoring agent by from the Monitoring Agent section of the Settings page by selecting Download Monitoring Agent (zip) or Download Monitoring Agent (tar.gz).
The URL for the configured agent will resemble the following:
Alternately, you may automate Monitoring agent deployments using an unconfigured agent and the API from the API Settings section of the Settings page. The unconfigured agent is available at the following URLs:
Extract this archive and edit the settings.py
file, updating the
@API_KEY@
with the API key for your account. Also update the
@DEFAULT_REQUIRE_VALID_SERVER_CERTIFICATES@
and @MMS_SERVER@
values.
You may embed this process in your existing deployment scripts to automatically install or redeploy new agents.
Configure any Proxies¶
You will need to export the “https_proxy
” environment variable
(or “HTTPS_PROXY
” on Windows).
Issue the following command before running the Monitoring agent to set the environment variable:
Replace “http://proxyserver.example.net
” with the name or IP
address of the proxy server and “port
with the TCP port that the
proxy service runs on. You may choose to export this variable inside
of your control script.
Next Steps¶
Once the agent is running and configured to your satisfaction, see Configure On Prem MMS Monitoring. Also see Using the MMS Console for more information about the On Prem MMS Monitoring interface.
Additional Information¶
The following resources provide documentation for creating control scripts:
Debian and Ubuntu Systems have an example control script located at
/etc/init.d/skeleton
that you can use as a template.
Red Hat Enterprise Linux and related distributions (e.g. Fedora,
CentOS, etc.) provide example control scripts in the
/usr/share/doc/initscripts-*/sysvinitfiles/
directory.