Using DMK JavaScript Scripts

DMK JS Scripts

DMK provides a $DMK_HOME/js folder where several scripts are located. Feel free to add yours.

  • collection_sz.js: List all collections on the instance, including size, storage size, document count, and average object size.

  • db_sz.js: List all databases on the instance.

  • get_cfg.js: Retrieve the configuration information from mongosh.

  • get_uri.js: Retrieve the MongoDB URI.

  • rs_status.js: Display the current status of the replica set if the instance is part of one.

  • server_info.js: Retrieve general information about the instance.

Example

mongodb@vm00:/home/mongodb/ [mdb01] msp $DMK_HOME/js/collection_sz.js
Database: admin
--------------------------------------
  Collection: system.version
    Size: 		 0.00 MB
    Storage Size: 	 0.02 MB
    Count: 		 1
    Avg Object Size: 	 0.06 KB

Database: config
--------------------------------------
  Collection: system.sessions
    Size: 		 0.00 MB
    Storage Size: 	 0.00 MB
    Count: 		 0
    Avg Object Size: 	 0.00 KB

Database: local
--------------------------------------
  Collection: startup_log
    Size: 		 0.00 MB
    Storage Size: 	 0.02 MB
    Count: 		 1
    Avg Object Size: 	 2.51 KB

Last updated