Mongostat is a command line tool that connects to the mongodb server and displays the status of the server.
The following is a simple example:
Run commands directly on the primary server without Parameters
root@vm1:~# mongostatconnected to: 127.0.0.1insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn set repl time *0 1 11 *0 19 3|0 1 1.28g 3.17g 1.13g 0 kaimei:73.4% 0 0|0 0|0 69k 7k 42 rs1 PRI 13:15:32 *0 2 16 *0 32 3|0 0 1.28g 3.17g 1.13g 0 kaimei:22.2% 0 0|0 0|1 38k 8k 42 rs1 PRI 13:15:33 *0 2 148 *0 151 2|0 0 1.28g 3.17g 1.13g 0 kaimei:62.6% 0 0|0 1|0 58k 52k 42 rs1 PRI 13:15:34 *0 1 112 *0 150 2|0 0 1.28g 3.17g 1.13g 0 kaimei:52.9% 0 0|0 0|0 70k 41k 42 rs1 PRI 13:15:35 *0 2 58 *0 48 2|0 0 1.28g 3.17g 1.13g 0 kaimei:44.2% 0 0|0 0|1 49k 21k 42 rs1 PRI 13:15:36
By default, a call is executed every second (called a call in this document) and the result is displayed as one line.
Some parameters can be used.
Sleeptime parameter, for example:
root@vm1:~# mongostat 10connected to: 127.0.0.1insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn set repl time *0 1 34 *0 57 3|0 0 1.28g 3.17g 1.13g 0 kaimei:52.6% 0 0|0 1|0 47k 13k 42 rs1 PRI 13:18:19 *0 1 8 *0 14 3|0 0 1.28g 3.17g 1.13g 0 kaimei:52.6% 0 0|0 0|0 42k 3k 42 rs1 PRI 13:18:29 *0 1 62 *0 100 3|0 0 1.28g 3.17g 1.13g 0 kaimei:54.8% 0 0|0 1|0 46k 24k 42 rs1 PRI 13:18:39 *0 1 11 *0 19 3|0 0 1.28g 3.17g 1.13g 0 kaimei:52.2% 0 0|0 0|0 43k 5k 42 rs1 PRI 13:18:49
-N indicates the number of calls, for example
Oot @ vm1 :~ # Define stat-n 2 connected: 127.0.0.1 insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr | qw ar | aw netIn netOut conn set repl time * 0 2 5*0 8 1 | 0 0 0 1.28g 3.17g 1.13g 0 kaimei: 24.7% 0 0 | 0 1 | 0 20 k 4 k 42 rs1 PRI 13:21:14*0 1 54*0 84 3 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 59.9% 0 0 | 0 0 | 0 61 k 22 k 42 rs1 PRI 13:21:15
You can also use-n and sleeptime in combination.
Mongostat-n 10 10
It means to call every 10 seconds and exit after 10 times.
The-v parameter can output detailed information about the unzip STAT command, for example:
Root @ vm1 :~ # Define stat-v-n 2
Wed Dec 11 13:27:11. 727 creating new connection to: 127.0.0.1: 27017
Wed Dec 11 13:27:11. 727 BackgroundJob starting: ConnectBG
Wed Dec 11 13:27:11. 728 connected connection!
Connected to: 127.0.0.1
Insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr | qw ar | aw netIn netOut conn set repl time
* 0 1 10*0 23 3 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 26.7% 0 0 | 0 0 | 1 37 k 6 k 42 rs1 PRI 13:27:12
* 0 2 65*0 121 3 | 0 0 1.28g 3.17g 1.12g 0 kaimei: 66.0% 0 0 0 | 0 1 | 0 49 k 28 k 42 rs1 PRI 13:27:13
-- Discover can obtain the status information of the entire replica-set member. For example:
Unzip stat -- discover
Connected to: 127.0.0.1
Insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr | qw ar | aw netIn netOut conn set repl tim \
E
Localhost * 0 2 24*0 34 9 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 39.9% 0 0 | 0 1 | 0 46 k 14 k 43 rs1 PRI 29 \
1
Localhost * 0 1 5*0 4 1 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 55.1% 0 0 | 0 0 0 | 0 52 k 3 k 43 rs1 PRI \
2
Vm1: 27017 no data
Vm3: 27017 no data
Vm4: 27017 no data
Localhost * 0 2 5*0 8 10 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 26.5% 0 0 0 | 0 1 | 0 21 k 10 k 44 rs1 PRI \
3
Vm1: 27017*0 2 5*0 8 10 | 0 0 1.28g 3.17g 1.13g 0 kaimei: 26.6% 0 0 | 0 1 | 0 21 k 10 k 44 rs1 PRI \
3
Vm3: 27017*0*0*2*0 4 | 0 0 1.28g 3.12g 485 m 0 local: 0.1% 0 0 | 0 0 | 0 304b 4 k 14 rs1 SEC \
3
Vm4: 27017*0*0*2*0 4 | 0 0 1.28g 3.13g 485 m 0 local: 0.2% 0 0 | 0 0 | 0 304b 4 k 14 rs1 SEC \
3