The Mongostat is a mongodb-brought tool that detects the running state of MongoDB.
test:test/node-131/# Mongostat--help
Usage:
Mongostat <options> <polling interval in seconds>
Monitor basic MongoDB Server statistics.
See http://docs.mongodb.org/manual/reference/program/mongostat/for more information.
General Options:
--help Print Usage
--version Print the tool version and exit
verbosity options:
-V,--verbose=<level> more detailed log output (include multiple times for more verbosity, e.g.-VVVVV, or specify a numeric value, e.g.--verbose=n)
--quiet Hide all log output
Connection options:
-H,--host=--port=<port> Server port (can also use--host hostname:port)
SSL options:
--ssl Connect to a mongod or mongos it has SSL enabled
--sslcafile=<filename> the. pem file containing the root certificate chain from the certificate authority
--sslpemkeyfile=<filename> the. Pem file containing the certificate and key
--sslpemkeypassword=<password> the password to decrypt the sslpemkeyfile, if necessary
--sslcrlfile=<filename> the. Pem file containing the certificate revocation list
--sslallowinvalidcertificates bypass the validation for server certificates
--sslallowinvalidhostnames bypass the validation for server name
--sslfipsmode use FIPS mode of the installed OpenSSL library
Authentication options:
-U,--username=<username> username for authentication
-p,--password=<password> password for authentication
--authenticationdatabase=<database-name> database that holds the users credentials
--authenticationmechanism=<mechanism> authentication mechanism to use
Stat options:
--noheaders dont output column names
-N,--rowcount=<count> number of stats lines to print (0 for indefinite)
--discover discover nodes and display stats for all
--http use HTTP instead of raw DB connection
--all all optional fields
--json output as JSON rather than a formatted table
Example:
20秒数据,每1秒钟输出
Mongostat-h 80.81.2.3-p 27017--rowcount 20 1
300秒数据,每5秒输出
Mongostat-h 80.81.2.3-p 27017-n 300 5
以json格式输出
Mongostat-h 80.81.2.4-p 27017-n 1--json
搜集复制集aCloud中所有节点的60s内运行状态,间隔1s刷新,保存到文件mongostat_aCloud.log中。
Mongostat-h acloud/80.81.2.4,80.81.2.5,80.81.2.6-p 27017-n 1 >> mongostat_acloud.log
Monitoring the state of the replication set primary node 80.81.2.4
Sangfor:acloud/node-131/var/lib/mongodb # mongostat-h 80.81.2.4-p 27017-n 60 1
Insert Query update delete getmore command% dirty% used flushes vsize res qr|qw AR|AW netin netout Conn Set REPL time
4327 0 0 0 445 748|0 0.5 4.1 0 1.1G 437.0M 0|0 0|0 834k 1m 7 acloud PRI 2016-07-21t20:56:48+08:00
3857 0 0 0 442 752|0 0.5 4.1 0 1.1G 438.0M 0|0 0|0 771k 1m 7 acloud PRI 2016-07-21t20:56:49+08:00
Result Analysis:
insert 每秒instert操作次数query 每秒query操作次数update 每秒update操作次数delete 每秒delete操作次数getmore每秒getmore操作次数command每秒command执行次数flushes每秒执行fsync将数据写入硬盘的次数vsize 虚拟内存使用量,单位是MBres 物理内存使用量,单位MBqr|qw 队列中waiting的读/写次数ar|aw 已激活active的读/写次数netIn 接收端网络速率,单位是bytesnetOut发送端网络速率,单位是bytesconn 连接数(open connections)set 复制集(replica set)名称repl 成员在复制集中的状态(PRI|SEC|ARB|REC)
Mongostat tool usage in MongoDB database