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@vm01:/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
mongodb@vm01:/u01/app/mongodb/local/dmk/js/ [mdb01] msp server_info.js

General
  MongoDB version : 8.0.11
  Environment   : rhel88:x86_64
  Config file     : /u01/app/mongodb/admin/mdb01/etc/mdb01.conf
Replicaset
  No replicaset defined

Active connections:
{
  current: 4,
  available: 815,
  totalCreated: 33,
  rejected: 0,
  active: 1,
  threaded: 4,
  exhaustIsMaster: Long('0'),
  exhaustHello: Long('0'),
  awaitingTopologyChanges: Long('0'),
  loadBalanced: Long('0')
}

Last updated