YouTip LogoYouTip

Mongodb Mongostat Mongotop

# MongoDB Monitoring After you have installed, deployed, and allowed the MongoDB service, you must understand MongoDB's operational status and check its performance. This allows you to handle high traffic situations well and ensure MongoDB operates normally. MongoDB provides two commands, `mongostat` and `mongotop`, to monitor the running status of MongoDB. * * * ## mongostat Command `mongostat` is a built-in status monitoring tool for MongoDB, used from the command line. It retrieves MongoDB's current running status at fixed intervals and outputs it. If you notice the database suddenly becoming slow or encountering other issues, your first step should be to use `mongostat` to check MongoDB's status. Start your Mongod service, navigate to the `bin` directory within your MongoDB installation directory, and then enter the `mongostat` command, as shown below: D:set upmongodbbin>mongostat The output of the above command is as follows: !(#) ## mongotop Command `mongotop` is also a built-in tool within MongoDB. It provides a method to track a MongoDB instance and see where large amounts of time are spent on reading and writing data. `mongotop` provides statistics at the collection level. By default, `mongotop` returns values every second. Start your Mongod service, navigate to the `bin` directory within your MongoDB installation directory, and then enter the `mongotop` command, as shown below: D:set upmongodbbin>mongotop The output of the above command execution is as follows: !(#) Example with parameters E:mongodb-win32-x86_64-2.2.1bin>mongotop 10 !(#) The `10` at the end is the __ parameter, which is optional. It specifies the length of time to wait, in seconds, between calls to `mongotop`. By default, `mongotop` returns data every second. E:mongodb-win32-x86_64-2.2.1bin>mongotop --locks To report lock usage for each database, use `mongotop --locks`, which will produce the following output: !(#) Output field descriptions: * **ns:** Contains the database namespace, which combines the database name and collection. * **db:** Contains the database name. The database named `.` refers to the global lock, not a specific database. * **total:** The total amount of time mongod has spent working on this namespace. * **read:** The amount of time mongod has spent performing read operations on this namespace. * **write:** The amount of time mongod has spent performing write operations on this namespace.
← Mongodb JavaMongodb Mongodump Mongorestore β†’