In this blog, I will present the new features introduced with the latest release (2.4.0) of the MongoDB DMK.
The DMK is a set of standardized tools that aims at easing the work of DBAs by having dbi’s best practices embedded in common scripts across all the database servers of an organization.
dbi services provides the DMK (Database Management Kit) to its customers for multiple technologies: Oracle, Postgres, MongoDB, etc. This toolkit is provided free of charge to all clients who work with dbi services on a consulting project.
New features of the MongoDB DMK in 2.4.0
Changes made to dmk_status.py script
- The table view (accessible with
dmk_status.py -t, or thetstaalias) now supports sorting by any column. Use the-ooption followed by the column name to specify the sorting column. For instance, use-o='port'to sort by port number. Sorting is ascending by default, but you can add a negative sign-before the column name for descending order, for instance-o='-port'. In addition to this, you can specify multiple columns for sorting, like-o='-version,state'to sort first by version and then by state.
mongodb@dmkmongo:/home/mongodb/ [mdb01] sta -o="-version"
Instance | State | Version | Port | Bind IPs
-------------------------------------------------------------------------------
mdb01 | STARTED | 8.0.16 | 27017 | 0.0.0.0
mdb02 | STARTED | 8.0.16 | 27016 | 0.0.0.0
mdbrs01 | STARTED | 8.0.15 | 27101 | 0.0.0.0
- The session view (
dmk_status.py -s, orsessalias) now supports filtering. You can filter with multiple criteria and combine them as needed. Here are the available filters:- Minimum runtime (
--min-runtime <seconds>) - Client IP (
--client <ip_address>) - User filtering (
--user <username>) - Application name (
--app <application_name>) - Database and collection (
--ns <namespace>)
- Minimum runtime (
- You can also add the
--show-queryoption to display the query for each session, which can be very useful in combination with the filters to quickly identify problematic queries. For instance,--min-runtime 10 --show-querywill show all sessions that have been running for more than 10 seconds along with their queries.
Here is an example of session display filtering with the --app option:
mongodb@dmkmongo:/home/mongodb/ [mdb01] sess --app DataGrip
2026-02-13 13:18:30 | INFO | Total sessions: 6, Active sessions: 6
-------------------------------------------------- Active MongoDB Sessions --------------------------------------------------
Filters applied: app: DataGrip, active only
ID USER CLIENT OP NS COMMAND TIME APP
conn7 - 192.168.105.1:60423 command admin.$cmd hello 7.82s DataGrip
conn8 - 192.168.105.1:60424 command admin.$cmd hello 7.83s DataGrip
conn9 - 192.168.105.1:60425 command admin.$cmd hello 7.83s DataGrip
-------------------------------------------------------------------------------------------------------------------------------
When viewing the status of a single instance with lsta (or dmk_status.py -l), the list of databases is now displayed.
mongodb@dmkmongo:/home/mongodb/ [mdb01] lsta
-------------------------- dbi services ------------------------------
INSTANCE : mdb01
STATUS : STARTED
DATABASES : dbapp01, dbapp02
VERSION : 8.0.16
BIND : 0.0.0.0
PORT : 27017
REPLICA SET STATUS : No replication
CONFIGURATION FILE : /u01/app/mongodb/admin/mdb01/etc/mdb01.conf
BIN PATH : /u01/app/mongodb/product/8.0.16/bin
DATA PATH : /u02/mongodb/data/mdb01
LOG FILE : /u04/mongodb/log/mdb01/mdb01.log
BACKUP PATH : /u90/mongodb/backup/mdb01
--------------------------------------------------------------------------
New replicat set features
- The
rstaalias (equivalent ofdmk_status.py -r) was improved to display more information.
mongodb@dmkmongo:/home/mongodb/ [mdbrs02] rsta
-------------------------------------------------- Replica Set Status Summary --------------------------------------------------
INSTANCE : mdbrs02
REPLICA SET NAME : rs01
DATE : 2026-02-13T12:21:43.755Z
MEMBER STATE : SECONDARY
MEMBERS :
NAME | STATE | UPTIME | LAG | OPTIME | HEALTH | PRIORITY | SYNC FROM
192.168.105.200:27017 | SECONDARY | 1m5s | 0.0s | 2026-02-13T12:21:38 | UP | 1 | 192.168.105.201:27017
192.168.105.201:27017 | SECONDARY | 1m5s | 0.0s | 2026-02-13T12:21:38 | UP | 1 | 192.168.105.202:27017
192.168.105.202:27017 | PRIMARY | 48s | 0.0s | 2026-02-13T12:21:38 | UP | 1 |
----------------------------------------------------------------------------------------------------------------------------------
- A
stepdownalias was added to allow stepping down the primary directly from the DMK command line. Its definition is rather simple:alias stepdown='msp --eval "rs.stepDown()"'.
Improvements to the set_local_dmk_config.py script
The set_local_dmk_config.py script now supports setting the local DMK configuration for custom instances by adding categories. Its usage doesn’t change, and you can find more about it in the Environment variables page of the DMK documentation.
Better support for instances managed with systemd
DMK better supports MongoDB instances that are managed with systemd. The dmk_db_ctl.py script will automatically detect if an instance is managed with systemd and use systemctl commands to start, stop, or restart the instance. This allows for better integration with the operating system and provides a more reliable management of MongoDB instances.
- Two new aliases were added to access
systemdunit files of instances:cdsysto access the folder containing the unit file andvisysto view the content of the unit file. - A
MONGO_SERVICE_NAMEvariable was added to the configuration, which allows specifying the name of thesystemdservice for each instance. This is useful when the service name doesn’t follow a standard pattern based on the instance name. By default,MONGO_SERVICE_NAMEis set tomongod_${MONGO_INSTANCE}.service, but you can overwrite it in your local configuration file if needed.
New aliases and environment variables
Aliases added in DMK 2.4.0:
cdp: alias to access the$MONGO_BASE/productfolder.cdbin: alias to access the MongoDB binaries folder of an instance.dmkjs: alias to access the DMK JavaScript folder. It is also available as a variable (dmkjs=$DMK_HOME/js).cdsys: alias to access thesystemdunit files folder.visys: alias to view thesystemdunit file of an instance.stepdown: alias to step down a primary instance with thers.stepDown()command.mgstatus: alias to show the status of the current instance. It has the same output as thelstaalias, but it was added to work with the othermgstop,mgstartandmgrestartaliases.
Environment variables added in DMK 2.4.0:
MONGO_SERVICE_NAMEenvironment variable to specify the name of thesystemdservice for each instance. By default, it is set tomongod_${MONGO_INSTANCE}.service, but you can overwrite it in your local configuration file if needed.MONGO_CREDvariable to specify the path to the credential file of an instance. It is set by default to${MONGO_BASE}/admin/${MONGO_INSTANCE}/secret/cred.yaml, but you can overwrite it in your local configuration file if needed. This variable is used in themspalias to automatically provide credentials when connecting to an instance withmongosh. More specifically, you can now setMONGO_CREDin the[INSTANCE]group in your local configuration file to have themspalias automatically use the same credentials for all instances, which is very useful when managing multiple instances with the same credentials.