dcrcli is a command-line utility to collect diagnostic information for MongoDB deployments:
- getMongoData output for each node of the cluster.
- FTDC data for each node of the cluster.
- Mongod Logs from all nodes in the cluster.
This enables centralized diagnostics and faster troubleshooting across replica sets and sharded clusters.
- Releases
- Prerequisites
- Usage
- Output Location
- Internal Notes
- Build from Source
- License
- Disclaimer
- Contributing
- Security
- Feedback / Issues
Download the latest prebuilt binaries:
For a successful collection, ensure the following before running dcrcli:
- Network Access
- Hostnames of all nodes in the MongoDB cluster must be resolvable from the machine running dcrcli.
- Use the same hostnames as the cluster configuration (e.g., those shown by rs.status()).
- Allow firewall access from the dcrcli host to MongoDB ports (e.g., 27017, 27018, etc.).
- When FTDC and MongoDB logs are also needed:
- Allow SSH access from the dcrcli host to all nodes in the cluster.
- MongoDB Shell
- Either the mongo or mongosh shell must be installed on the machine running dcrcli.
- If authentication is enabled:
- Use a database user with the appropriate permissions (see “Minimum Required Permissions” in the getMongoData README: https://github.com/mongodb/support-tools/blob/master/getMongoData/README.md#more-details).
- If the password contains special characters (e.g., $, /, ?, #), input them directly without percent encoding.
- Remote Log & FTDC Copy
- The machine running dcrcli must have SSH access to all nodes in the cluster. Using passwordless SSH is recommended for an unattended run.
- Note: rsync over SSH is used to copy files from the hosts to the dcrcli host. If passwordless SSH is not configured, a password prompt will appear for each node during collection.
- The SSH user must have read permissions on MongoDB log and FTDC files.
- Install rsync on the machine running dcrcli.
- If SSH daemons on nodes use non-default ports, specify them via SSH config on the dcrcli host.
- If hostnames used on MongoDB nodes are not resolvable, add their IP addresses to /etc/hosts on the dcrcli host.
- Optional: Ensure at least (300 × number_of_processes + 1024) MB of free space on the host running dcrcli.
- MongoDB v6+
- Ensure the PATH includes the mongosh binary.
- Quick checks:
which mongosh
or
echo "$PATH"
Follow these steps:
- Download the latest release: https://github.com/mongodb-labs/dcrcli/releases
- Transfer the binary to a machine that can access the MongoDB nodes.
- Make it executable:
chmod +x <binary-name>
- Run:
./<binary-name>
- Follow the on-screen prompts to start data collection.
Terminologies:
- Cluster Name: Give the name of cluster to recognise easily ( APAC_PROD_RS)
- Hostname of Seed Mongod/Mongos: Recommended to give mongos hostname for sharded cluster, Primary hostname for replica set.
- Port number of Seed Mongod/Mongos instance: Port number at which mongos/mongod running on the host which we have given in previous ask.
- Admin Username: Admin username of database instance.
- Admin Password: Admin user password of database instance.
- MongoURI options: Any special connection string option to be specified.
- SSH User: Mention the username that have SSH access to the clusters machines. Ensure that this user has read-write permissions on the dbpath of each machine.
- Collected artifacts are written under ./outputs.
- Typical runtime: ~2–15 minutes depending on cluster size and network conditions.
- After completion, compress the output directory (zip/tar.gz) for upload or archival.
- After each execution, a log file is created in the current working directory. E.g: dcrlogfile_1755165313.log
- getMongoData
- dcrcli invokes the mongo or mongosh shell with a compatible getMongoData.js script. Ensure the shell is in PATH.
- rsync
- For remote file copy tasks, dcrcli runs rsync with flags similar to:
rsync -az --include=<file-pattern> --exclude=<file-pattern> --info=progress <ssh-username>@<hostname>:<src-path>/ <dest-path>
- Note: The utility sequentially connects to each node, which may take time for deployments with a large number of nodes.
- For remote file copy tasks, dcrcli runs rsync with flags similar to:
To build dcrcli from source, use the following commands based on your operating system:
Linux amd64 build steps example:
- Assume you are on a Linux amd64 machine
- Clone the rep
git clone <repo-link>
- Run the build:
GOOS=linux GOARCH=amd64 go build
Pull requests are welcome. For significant changes, open an issue first to discuss scope and approach. Add or update tests where applicable.
Do not include sensitive data (credentials, PII) in issues or PRs. For security disclosures, contact maintainers privately.
Please note: all tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. We disclaim any and all warranties, either express or implied, including but not limited to any warranty of noninfringement, merchantability, and/ or fitness for a particular purpose. We do not warrant that the technology will meet your requirements, that the operation thereof will be uninterrupted or error-free, or that any errors will be corrected.
Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.
Thanks, The MongoDB Support Team