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 the tsta alias) now supports sorting by any column. Use the -o option 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, or sess alias) 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>)
  • You can also add the --show-query option 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-query will 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 rsta alias (equivalent of dmk_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 stepdown alias 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 systemd unit files of instances: cdsys to access the folder containing the unit file and visys to view the content of the unit file.
  • A MONGO_SERVICE_NAME variable was added to the configuration, which allows specifying the name of the systemd service 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_NAME is set to mongod_${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/product folder.
  • 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 the systemd unit files folder.
  • visys: alias to view the systemd unit file of an instance.
  • stepdown: alias to step down a primary instance with the rs.stepDown() command.
  • mgstatus: alias to show the status of the current instance. It has the same output as the lsta alias, but it was added to work with the other mgstop, mgstart and mgrestart aliases.

Environment variables added in DMK 2.4.0:

  • MONGO_SERVICE_NAME environment variable to specify the name of the systemd service for each instance. By default, it is set to mongod_${MONGO_INSTANCE}.service, but you can overwrite it in your local configuration file if needed.
  • MONGO_CRED variable 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 the msp alias to automatically provide credentials when connecting to an instance with mongosh. More specifically, you can now set MONGO_CRED in the [INSTANCE] group in your local configuration file to have the msp alias automatically use the same credentials for all instances, which is very useful when managing multiple instances with the same credentials.