@hari_dba A more typical approach would be to use a monitoring platform to collect and chart ongoing metrics. For example, MongoDB Cloud Manager for detailed metrics or Free Monitoring for basic metrics. Trends in metrics are generally better visualised in charts rather than tabular text format.
If you want to write something custom for metric collection, refer to Database Commands Used by Monitoring in Cloud Manager for relevant diagnostic & administrative database commands. These are the same commands used by monitoring agents and tools like mongotop/mongostat.
Alternatively, you could write a cron saving the output of mongotop & mongostat (perhaps using the --json option).
A downside of using command line tools is that you will be sampling at a certain rate (for example, an interval in seconds). If you use database commands like serverStatus you can get counters that will allow you to derive a better picture of activity over time. For example, opcounters are a cumulative count of database operations by type since the mongod instance last started.
Can you please provide script for output of Mongotop and Mongostat to .cs file or excel format and also that output will be export into direct emails, if it possible please tell me that solution
How to take output mongotop and mongostat by using --json option this option display output horizontal wise and how to generate into .CS file excel sheet export into email.
If this is your preferred approach, you’ll have to find or create a solution.
If your goal is metrics & monitoring, I’d recommend using an existing monitoring solution such as MongoDB Cloud Manager or Free Monitoring.
JSON output will give you structured documents that you can save or manipulate programatically. Writing a program to work with JSON and Excel files or email is not specific to MongoDB. You need to look into available libraries and tooling available in your preferred programming language.
I believe @Stennie_X answered your question perfectly and showed you the best solution, but I also believe there are so many people out there like “you”, don’t know how to process JSON.