Skip to main content

Get the MongoDB database statistic to a local CSV file

Project description

Mostats 📊


PyPI Downloads GitHub repo size GitHub last commit (by committer)

Get the MongoDB database statistic e.g : database name, collection, index size, and collection size to a an excel file.

New version support multiple server instance and getting additional host information, uptime, total number of command, read, getmore, command, insert, summarise the cluster report, and recommended sizing. Host information will be save as "Cluster-info.xlsx" on the same folder

To get host information :

mostats -u "mongodb+srv://username:password@cluster1.cluster.mongodb.net/" -m True

To get sizing information (specify frequenly access data in percentage -fa) below is the sample of 5% :

mostats -u "mongodb+srv://username:password@cluster1.cluster.mongodb.net/" -fa 5 -m True

Install

Run this command, please choose pip or pip3

pip3 install mostats
pip install mostats

How to use

Please check on the guide below:

usage: getCluster.py [-h] [-u URL [URL ...]] [-uf URLFILE] [-e EXCELFILE] [-n NAME [NAME ...]] [-nf NAMEFILE] [-m MOREINFO] [-fa FA] [-iops IOPS]

Get the MongoDB database statistic to an excel file

options:
  -h, --help            show this help message and exit
  -u URL [URL ...], --url URL [URL ...]
                        MongoDB cluster URL, default is "mongodb://127.0.0.1". Example:
                        "mongodb+srv://<<username>>:<<password>>@cluster.zqqqy.mongodb.net/?retryWrites=true&w=majority". For multiple server please
                        use the space and "" to seperate
                        example:"mongodb+srv://<<username>>:<<password>>@cluster1.zqqqy.mongodb.net/?retryWrites=true&w=majority"
                        "mongodb+srv://<<username>>:<<password>>@cluster2.zqqqy.mongodb.net/?retryWrites=true&w=majority"
  -uf URLFILE, --urlfile URLFILE
                        Get the MongoDB cluster URL from a file. It will read each line as one MongoDB cluster URL
  -e EXCELFILE, --excelfile EXCELFILE
                        Excel filename, default "Cluster-info.xlsx"
  -n NAME [NAME ...], --name NAME [NAME ...]
                        Cluster name, default value first subdomain example: mongodb+srv://clustername.cl0.mongodb.net will be clustername. For
                        multiple server please use the space and "" to seperate example:"cluster1" "cluster2"
  -nf NAMEFILE, --namefile NAMEFILE
                        Get the cluster name from a file. It will read each line as one cluster name
  -m MOREINFO, --moreinfo MOREINFO
                        Getting the host information, uptime, total number of command, read, and insert
  -fa FA, --fa FA       Frequently access ratio in percent (input number only)
  -iops IOPS, --iops IOPS
                        Expected IOPS

Example

For MongoDB Atlas please leave the cluster name empty

mostats -u "mongodb+srv://username:password@cluster0.cluster.mongodb.net/?retryWrites=true&w=majority" -c "cluster-info.csv"

Specify custom cluster name for MongoDB Community or Enterprise Edition installation only when MongogDB installed without FQDN

mostats -u "mongodb+srv://username:password@cluster0.cluster.mongodb.net/?retryWrites=true&w=majority" -n "Cluster1" -c "Custom-file.xlsx"

Getting host information on multiple cluster with custom cluster name. Please leave it empty when getting the data from MongoDB atlas

mostats -u "mongodb+srv://username:password@cluster1.cluster.mongodb.net/" "mongodb+srv://username:password@cluster2.cluster.mongodb.net/" -n "Cluster 1" "Cluster 2" -m True

Getting host information and sizing on multiple cluster with custom cluster name. Specify frequently access file by adding parameter -fa. Please leave it empty when getting the data from MongoDB atlas. Below are the sample code for adding frequently access data equal to 5%

mostats -u "mongodb+srv://username:password@cluster1.cluster.mongodb.net/" "mongodb+srv://username:password@cluster2.cluster.mongodb.net/" -n "Cluster 1" "Cluster 2" -fa 5 -m True

Getting more than one MongoDB cluster with external file

Mostats can read external files to specify both MongoDB URL and custom name. It will read each line as one MongoDB URL and one cluster name.

Sample mongourl.txt

mongodb+srv://username:password@cluster1.cluster.mongodb.net/
mongodb+srv://username:password@cluster2.cluster.mongodb.net/

Sample name.txt

Cluster 1
Cluster 2

Below are the sample script:

mostats -uf "mongourl.txt" -nf "name.txt" -fa 0 -m True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

mostats-1.0.10-py3-noneb-any.whl (18.8 kB view details)

Uploaded Python 3

mostats-1.0.10-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file mostats-1.0.10-py3-noneb-any.whl.

File metadata

  • Download URL: mostats-1.0.10-py3-noneb-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for mostats-1.0.10-py3-noneb-any.whl
Algorithm Hash digest
SHA256 4e0fad10d34533f1f9e17690dcfe59c9f6e38be03b97012c39a34c10181321c9
MD5 e00f8190b91cac56ea8740d46bf7c42e
BLAKE2b-256 74a6904b6e3967a778d481a1e8c2bbe8d45121591502422a84853c80d8377f58

See more details on using hashes here.

File details

Details for the file mostats-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: mostats-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for mostats-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 97d026070c1dc531d770fab5ec11d61707cf55c8bb1b9ac0c11bb86ec38aefdd
MD5 e5a29f6c8698f4a17b94d7de6cee0aea
BLAKE2b-256 0d9208b18a659daa6842bcea4ade42ea26caf3a20a2a8494883e64a6b11d3fe0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page