diff --git a/README.md b/README.md index 764c03a..871239f 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ ognom-toolkit is a set of utilities, functions and tests with the goal of making the life of MongoDB/TokuMX administrators easier. -TokuMX Toolkit is set of utilities, functions and tests which make life of TokuMX administrator easier - # name ognom stands for mongo spelled backwards, with the following advantages: diff --git a/mongo-response-time/README b/mongo-response-time/README new file mode 100644 index 0000000..763e244 --- /dev/null +++ b/mongo-response-time/README @@ -0,0 +1,7 @@ +This utility generates a csv file with time,response_time fields, in which: +- time is the current time (one second precision) +- response_time is the response time for an operation + +The file should contain response time data for all operations seen on the wire. + +The Makefile and a required library are located under the ../slowlog-generator/ tree, this symlink is included here only for convenience when browsing the repo. \ No newline at end of file diff --git a/mongo-response-time/mongo-response-time.go b/mongo-response-time/mongo-response-time.go new file mode 120000 index 0000000..a8a5e14 --- /dev/null +++ b/mongo-response-time/mongo-response-time.go @@ -0,0 +1 @@ +../slowlog-generator/response-time/mongo-response-time.go \ No newline at end of file diff --git a/mongo-summary/generated/mongo-summary-extra.js b/mongo-summary/generated/mongo-summary-extra.js index bab770e..cabc6ce 100644 --- a/mongo-summary/generated/mongo-summary-extra.js +++ b/mongo-summary/generated/mongo-summary-extra.js @@ -1,59 +1,58 @@ - - function getHeader(header, filler, length) { - var result = "\n# " + header + " "; - if (result.length < length) { - for (i=result.length; i 0) { - print("Collections: "); - cols.forEach( - function (element, array, index) { - print(" " + element); - auxdb.getCollectionNames().forEach(function(collection) { - indexes = auxdb[collection].getIndexes(); - print("Indexes for " + collection + ":"); - printjson(indexes); - }); - } - ); - } - } - ); + db.adminCommand('listDatabases')["databases"].forEach( + function (element, array, index) { + var auxdb = db.getSiblingDB(element["name"]); + var cols = auxdb.getCollectionNames(); + print(element["name"] + " has " + cols.length + " collections and " + element["sizeOnDisk"] + " bytes on disk"); + if (cols.length > 0) { + print("Collections: "); + cols.forEach( + function (element, array, index) { + print(" " + element); + auxdb.getCollectionNames().forEach(function(collection) { + indexes = auxdb[collection].getIndexes(); + print("Indexes for " + collection + ":"); + printjson(indexes); + }); + } + ); + } + } + ); - if (isMongos()) { - sh.status(); - } else { - printjson(db.adminCommand('replSetGetStatus')); - } - db.isMaster(); - print(getHeader("Logs",FILLER,LENGTH)); - db.adminCommand({'getLog': '*'})["names"].forEach( - function (element, array, index) { - db.adminCommand({'getLog': element})["log"].forEach( - function (element, array, index) { - print(element); - } - ); - } - ); - } + if (isMongos()) { + sh.status(); + } else { + printjson(db.adminCommand('replSetGetStatus')); + } + db.isMaster(); + print(getHeader("Logs",FILLER,LENGTH)); + db.adminCommand({'getLog': '*'})["names"].forEach( + function (element, array, index) { + db.adminCommand({'getLog': element})["log"].forEach( + function (element, array, index) { + print(element); + } + ); + } + ); +} printExtraDiagnosticsInfo(); diff --git a/mongo-summary/generated/mongo-summary-test-replset.js b/mongo-summary/generated/mongo-summary-test-replset.js index f48efab..91407ac 100644 --- a/mongo-summary/generated/mongo-summary-test-replset.js +++ b/mongo-summary/generated/mongo-summary-test-replset.js @@ -1,15 +1,14 @@ - - var BASE_PORT=2800; - var HOSTNAME="telecaster"; - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+0 ,prefix+1, prefix+2, prefix+3].forEach( - function (element, array, index) { - if (element==HOSTNAME+":"+BASE_PORT+3) { - rs.add(element,true); - } else { - rs.add(element); - } - rs.config(); - } - ); + var BASE_PORT=2800; + var HOSTNAME="telecaster.local"; + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+0 ,prefix+1, prefix+2, prefix+3].forEach( + function (element, array, index) { + if (element==HOSTNAME+":"+BASE_PORT+3) { + rs.add(element,true); + } else { + rs.add(element); + } + rs.config(); + } + ); diff --git a/mongo-summary/generated/mongo-summary-test-sharded-rs1.js b/mongo-summary/generated/mongo-summary-test-sharded-rs1.js index b3b2338..6fccb42 100644 --- a/mongo-summary/generated/mongo-summary-test-sharded-rs1.js +++ b/mongo-summary/generated/mongo-summary-test-sharded-rs1.js @@ -1,11 +1,10 @@ - - var BASE_PORT=2800; - var HOSTNAME="telecaster"; - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+0 ,prefix+1 ].forEach( - function (element, array, index) { - rs.add(element); - rs.config(); - } - ); + var BASE_PORT=2800; + var HOSTNAME="telecaster.local"; + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+0 ,prefix+1 ].forEach( + function (element, array, index) { + rs.add(element); + rs.config(); + } + ); diff --git a/mongo-summary/generated/mongo-summary-test-sharded-rs2.js b/mongo-summary/generated/mongo-summary-test-sharded-rs2.js index 2f9be73..aa08a41 100644 --- a/mongo-summary/generated/mongo-summary-test-sharded-rs2.js +++ b/mongo-summary/generated/mongo-summary-test-sharded-rs2.js @@ -1,11 +1,10 @@ - - var BASE_PORT=2800; - var HOSTNAME="telecaster"; - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+2, prefix+3 ].forEach( - function (element, array, index) { - rs.add(element); - rs.config(); - } - ); + var BASE_PORT=2800; + var HOSTNAME="telecaster.local"; + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+2, prefix+3 ].forEach( + function (element, array, index) { + rs.add(element); + rs.config(); + } + ); diff --git a/mongo-summary/generated/mongo-summary-test.sh b/mongo-summary/generated/mongo-summary-test.sh index a2ee05b..07cd2b7 100755 --- a/mongo-summary/generated/mongo-summary-test.sh +++ b/mongo-summary/generated/mongo-summary-test.sh @@ -1,133 +1,153 @@ +_MST_MONGOD=${MST_MONGOD:-mongod} +_MST_MONGOS=${MST_MONGOS:-mongos} +_MST_MONGO=${MST_MONGO:-mongo} export mst_DBPATH_ROOT=~/mongo-summary-tests/ export mst_BASE_PORT=28000 -export mst_HOSTNAME="telecaster" - - function mst_createDatadir() - { - test -d $1 && rm -rf $mst_DBPATH_ROOT/$1 - mkdir -p $mst_DBPATH_ROOT/$1 - } - - function mst_startInstance() - { - program=$1 - dbpath=$2 - port=$3 - dbpath_arg="" - mst_createDatadir $dbpath - [ "$program" != "mongos" ] && dbpath_arg="--dbpath $mst_DBPATH_ROOT/$dbpath" - shift; shift; shift - $program $dbpath_arg --port=$port --logpath $mst_DBPATH_ROOT/$dbpath/log --fork --pidfilepath $mst_DBPATH_ROOT/$dbpath/pid $* - sleep 5 - } - - function mst_stopInstance() - { - kill $(cat $mst_DBPATH_ROOT/$1/pid) - rm -rf $mst_DBPATH_ROOT/$1 - } - - function mst_test_standalone_mongod() - { - mst_startInstance mongod standalone $mst_BASE_PORT - sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_standalone_mongod.result.txt - mst_stopInstance standalone - } - - function mst_test_replica_test() - { - nodes="primary secondary1 secondary2 arbiter" - port_offset=0 - for node in $nodes; do - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet "test" - port_offset=$((port_offset + 1)) - done - - mongo --port $mst_BASE_PORT mongo-summary-test-replset.js - echo "Sleeping 2 seconds wainting for the replica set configuration to get applied" && sleep 2 - sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_replica_set.result.txt - for node in $nodes; do - mst_stopInstance $node - done - } - - function mst_test_shard_pair() - { - nodes="shard1 shard2 config1 config2 config3 mongos" - port_offset=0 - config1_port=$((mst_BASE_PORT + 2)) - config2_port=$((mst_BASE_PORT + 3)) - config3_port=$((mst_BASE_PORT + 4)) - mongos_port=$((mst_BASE_PORT + 5)) - for node in $nodes; do - if [ $(echo $node|grep -c config) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --configsvr - elif [ "$node" == "mongos" ]; then - mst_startInstance mongos $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" - else - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) - fi - port_offset=$((port_offset + 1)) - done - - for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do - mongo --port $mongos_port --eval "sh.addShard(\"$mst_HOSTNAME:$port\")" +export mst_HOSTNAME="telecaster.local" + +function mst_createDatadir() +{ + test -d $1 && rm -rf $mst_DBPATH_ROOT/$1 + mkdir -p $mst_DBPATH_ROOT/$1 +} + +function mst_startInstance() +{ + program=$1 + dbpath=$2 + port=$3 + dbpath_arg="" + mst_createDatadir $dbpath + [ $(echo $program|grep -c mongos) -eq 0 ] && dbpath_arg="--dbpath $mst_DBPATH_ROOT/$dbpath" + shift; shift; shift + $program $dbpath_arg --port=$port --logpath $mst_DBPATH_ROOT/$dbpath/log --fork --pidfilepath $mst_DBPATH_ROOT/$dbpath/pid $* + sleep 5 +} + +function mst_stopInstance() +{ + kill $(cat $mst_DBPATH_ROOT/$1/pid) + rm -rf $mst_DBPATH_ROOT/$1 +} + +function mst_validateOutput() +{ + f=$1; shift + ok=0 + while [ -n "$1" ]; do + grep "$1" $f>/dev/null || { + ok=1 + echo "$1 not found on $f">&2 + } + shift + done + return $ok +} + +function mst_test_standalone_mongod() +{ + mst_startInstance $_MST_MONGOD standalone $mst_BASE_PORT + sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_standalone_mongod.result.txt + mst_stopInstance standalone + mst_validateOutput test_standalone_mongod.result.txt "Standalone mongod" version backgroundFlushing "Server Parameters" argv "local has" Logs +} + +function mst_test_replica_set() +{ + nodes="primary secondary1 secondary2 arbiter" + port_offset=0 + for node in $nodes; do + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet "test" + port_offset=$((port_offset + 1)) done -mongo --port $mongos_port --eval "sh.enableSharding(\"test\")" -mongo $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-replset.js + echo "Sleeping 2 seconds waiting for the replica set configuration to get applied" && sleep 2 + sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_replica_set.result.txt + for node in $nodes; do + mst_stopInstance $node + done + mst_validateOutput test_replica_set.result.txt "Node is PRIMARY" 28002 connections "Server Parameters" argv "local has" +} + +function mst_test_shard_pair() +{ + nodes="shard1 shard2 config1 config2 config3 mongos" + port_offset=0 + config1_port=$((mst_BASE_PORT + 2)) + config2_port=$((mst_BASE_PORT + 3)) + config3_port=$((mst_BASE_PORT + 4)) + mongos_port=$((mst_BASE_PORT + 5)) + for node in $nodes; do + if [ $(echo $node|grep -c config) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --configsvr + elif [ "$node" == "mongos" ]; then + mst_startInstance $_MST_MONGOS $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" + else + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) + fi + port_offset=$((port_offset + 1)) + done - sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster.result.txt - for node in $nodes; do - mst_stopInstance $node + for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do +$_MST_MONGO --port $mongos_port --eval "sh.addShard(\"$mst_HOSTNAME:$port\")" done - } - - function mst_test_shard_replset() - { - nodes="shard1_1 shard1_2 shard2_1 shard2_2 config1 config2 config3 mongos" - port_offset=0 - config1_port=$((mst_BASE_PORT + 4)) - config2_port=$((mst_BASE_PORT + 5)) - config3_port=$((mst_BASE_PORT + 6)) - mongos_port=$((mst_BASE_PORT + 7)) - for node in $nodes; do - if [ $(echo $node|grep -c config) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --configsvr - elif [ "$node" == "mongos" ]; then - mst_startInstance mongos $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" - elif [ $(echo $node|grep -c shard1) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet rs1 - else - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet rs2 - fi - port_offset=$((port_offset + 1)) - done - - mongo --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js - sleep 1 - mongo --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js - sleep 1 - mongo --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js - sleep 1 - mongo --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js - sleep 1 - for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do - mongo --port $mongos_port --eval "sh.addShard(\"rs1/$mst_HOSTNAME:$port\")" - done - for port in $((mst_BASE_PORT + 2)) $((mst_BASE_PORT + 3)); do - mongo --port $mongos_port --eval "sh.addShard(\"rs2/$mst_HOSTNAME:$port\")" - done - - mongo --port $mongos_port --eval "sh.enableSharding(\"test\")" - mongo $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' - - sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster_replset.result.txt - for node in $nodes; do - mst_stopInstance $node - done - } +$_MST_MONGO --port $mongos_port --eval "sh.enableSharding(\"test\")" +$_MST_MONGO $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' + +sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster.result.txt +for node in $nodes; do + mst_stopInstance $node +done +mst_validateOutput test_sharded_cluster.result.txt "Sharding Summary" "Detected 2 shards" "Shards detail" "operations in progress" + +} + +function mst_test_shard_replset() +{ + nodes="shard1_1 shard1_2 shard2_1 shard2_2 config1 config2 config3 mongos" + port_offset=0 + config1_port=$((mst_BASE_PORT + 4)) + config2_port=$((mst_BASE_PORT + 5)) + config3_port=$((mst_BASE_PORT + 6)) + mongos_port=$((mst_BASE_PORT + 7)) + for node in $nodes; do + if [ $(echo $node|grep -c config) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --configsvr + elif [ "$node" == "mongos" ]; then + mst_startInstance $_MST_MONGOS $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" + elif [ $(echo $node|grep -c shard1) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet rs1 + else + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet rs2 + fi + port_offset=$((port_offset + 1)) + done + + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js + sleep 1 + $_MST_MONGO --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js + sleep 1 + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js + sleep 1 + $_MST_MONGO --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js + sleep 1 + for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do + $_MST_MONGO --port $mongos_port --eval "sh.addShard(\"rs1/$mst_HOSTNAME:$port\")" + done + for port in $((mst_BASE_PORT + 2)) $((mst_BASE_PORT + 3)); do + $_MST_MONGO --port $mongos_port --eval "sh.addShard(\"rs2/$mst_HOSTNAME:$port\")" + done + + $_MST_MONGO --port $mongos_port --eval "sh.enableSharding(\"test\")" + $_MST_MONGO$mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' + + sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster_replset.result.txt + for node in $nodes; do + mst_stopInstance $node + done +} diff --git a/mongo-summary/generated/mongo-summary.js b/mongo-summary/generated/mongo-summary.js index 1e34c44..7083356 100644 --- a/mongo-summary/generated/mongo-summary.js +++ b/mongo-summary/generated/mongo-summary.js @@ -1,168 +1,169 @@ +function getFilledDatePart(datepart) { + return datepart < 10 ? "0" + datepart : datepart; +} - function getFilledDatePart(datepart) { - return datepart < 10 ? "0" + datepart : datepart; - } - - function getHeader(header, filler, length) { - var result = "\n# " + header + " "; - if (result.length < length) { - for (i=result.length; i 0) { - print(getHeader("Replica set members",FILLER,LENGTH)); - replicationSummary["members"].forEach( - function(member, array, index) { - print(member); - } - ); - } - } - print(getHeader("Server Status",FILLER,LENGTH)) - printjson(basicInfo["serverStatus"]); - print(getHeader("Server Parameters",FILLER,LENGTH)) - printjson(basicInfo["parameters"]); - print(getHeader("Command Line Options",FILLER,LENGTH)) - printjson(basicInfo["cmdLineOpts"]); +print(getHeader("Ognom Toolkit MongoDB Summary Report",FILLER,LENGTH)); +var basicInfo = getInstanceBasicInfo(db); +print("Report generated on " + basicInfo["hostname"] + " at " + basicInfo["serverTime"]); +print(basicInfo["inprog"]); +if (isMongos()) { + print(getHeader("Sharding Summary (mongos detected)",FILLER,LENGTH)); + shardsInfo = getShardingSummary(); + print("Detected " + shardsInfo["shards"].length + " shards"); + print("Sharded databases: "); + shardsInfo["shardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); + print(""); + print("Unsharded databases: "); + shardsInfo["unshardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); + print(""); + print(getHeader("Shards detail",FILLER,LENGTH)); + getShardsInfo()["shards"].forEach( + function (element, array, index) { + print("Shard " + element["_id"] + " @ " + element["host"]); + print("(" + element["hostInfo"]["inprog"] + ")"); + print(element["replicationSummary"]["summary"]); + print(element["replicationSummary"]["summaryExtra"]); + print(""); + } + ); +} else { + print(getHeader("Replication summary",FILLER,LENGTH)); + replicationSummary = getReplicationSummary(db); + if (replicationSummary["summary"]) { + print(replicationSummary["summary"]) + } else { + print("Something is wrong with the replication summary (it is undefined)") + } + if (replicationSummary["summaryExtra"]) { + print(replicationSummary["summaryExtra"]); + } + if (replicationSummary["members"].length > 0) { + print(getHeader("Replica set members",FILLER,LENGTH)); + replicationSummary["members"].forEach( + function(member, array, index) { + print(member); + } + ); + } +} +print(getHeader("Server Status",FILLER,LENGTH)) +printjson(basicInfo["serverStatus"]); +print(getHeader("Server Parameters",FILLER,LENGTH)) +printjson(basicInfo["parameters"]); +print(getHeader("Command Line Options",FILLER,LENGTH)) +printjson(basicInfo["cmdLineOpts"]); diff --git a/mongo-summary/generated/mongo-summary.sh b/mongo-summary/generated/mongo-summary.sh index b123bbb..97377cf 100755 --- a/mongo-summary/generated/mongo-summary.sh +++ b/mongo-summary/generated/mongo-summary.sh @@ -1,8 +1,7 @@ - - extra=0 - [ "$1" == "--extra" ] && { - extra=1 - shift - } - mongo mongo-summary.js $* - [ $extra -eq 1 ] && mongo mongo-summary-extra.js $* + extra=0 + [ "$1" == "--extra" ] && { + extra=1 + shift + } + mongo mongo-summary.js $* + [ $extra -eq 1 ] && mongo mongo-summary-extra.js $* diff --git a/mongo-summary/mongo-summary.org b/mongo-summary/mongo-summary.org index 120aa1d..02ff19d 100644 --- a/mongo-summary/mongo-summary.org +++ b/mongo-summary/mongo-summary.org @@ -45,20 +45,20 @@ so I need a function to generate similar lines. #+NAME: getHeader #+BEGIN_SRC js - function getHeader(header, filler, length) { - var result = "\n# " + header + " "; - if (result.length < length) { - for (i=result.length; i 0) { - print("Collections: "); - cols.forEach( - function (element, array, index) { - print(" " + element); - auxdb.getCollectionNames().forEach(function(collection) { - indexes = auxdb[collection].getIndexes(); - print("Indexes for " + collection + ":"); - printjson(indexes); - }); - } - ); - } - } - ); + db.adminCommand('listDatabases')["databases"].forEach( + function (element, array, index) { + var auxdb = db.getSiblingDB(element["name"]); + var cols = auxdb.getCollectionNames(); + print(element["name"] + " has " + cols.length + " collections and " + element["sizeOnDisk"] + " bytes on disk"); + if (cols.length > 0) { + print("Collections: "); + cols.forEach( + function (element, array, index) { + print(" " + element); + auxdb.getCollectionNames().forEach(function(collection) { + indexes = auxdb[collection].getIndexes(); + print("Indexes for " + collection + ":"); + printjson(indexes); + }); + } + ); + } + } + ); #+END_SRC Now print some raw json (some of which we've summarized already) depending on the node type we're on #+HEADERS: :tangle mongo-summary-extra.js #+BEGIN_SRC js - if (isMongos()) { - sh.status(); - } else { - printjson(db.adminCommand('replSetGetStatus')); - } - db.isMaster(); - print(getHeader("Logs",FILLER,LENGTH)); - db.adminCommand({'getLog': '*'})["names"].forEach( - function (element, array, index) { - db.adminCommand({'getLog': element})["log"].forEach( - function (element, array, index) { - print(element); - } - ); - } - ); - } + if (isMongos()) { + sh.status(); + } else { + printjson(db.adminCommand('replSetGetStatus')); + } + db.isMaster(); + print(getHeader("Logs",FILLER,LENGTH)); + db.adminCommand({'getLog': '*'})["names"].forEach( + function (element, array, index) { + db.adminCommand({'getLog': element})["log"].forEach( + function (element, array, index) { + print(element); + } + ); + } + ); +} #+END_SRC ** Presentation @@ -297,56 +299,56 @@ This is not a function, because it is what will be run by the mongo shell when i #+HEADERS: :tangle mongo-summary.js #+BEGIN_SRC js - print(getHeader("Percona Toolkit MongoDB Summary Report",FILLER,LENGTH)); - var basicInfo = getInstanceBasicInfo(db); - print("Report generated on " + basicInfo["hostname"] + " at " + basicInfo["serverTime"]); - print(basicInfo["inprog"]); - if (isMongos()) { - print(getHeader("Sharding Summary (mongos detected)",FILLER,LENGTH)); - basicInfo = getShardingSummary(); - print("Detected " + basicInfo["shards"].length + " shards"); - print("Sharded databases: "); - basicInfo["shardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); - print(""); - print("Unsharded databases: "); - basicInfo["unshardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); - print(""); - print(getHeader("Shards detail",FILLER,LENGTH)); - getShardsInfo()["shards"].forEach( - function (element, array, index) { - print("Shard " + element["_id"] + " @ " + element["host"]); - print("(" + element["hostInfo"]["inprog"] + ")"); - print(element["replicationSummary"]["summary"]); - print(element["replicationSummary"]["summaryExtra"]); - print(""); - } - ); - } else { - print(getHeader("Replication summary",FILLER,LENGTH)); - replicationSummary = getReplicationSummary(db); - if (replicationSummary["summary"]) { - print(replicationSummary["summary"]) - } else { - print("Something is wrong with the replication summary (it is undefined)") - } - if (replicationSummary["summaryExtra"]) { - print(replicationSummary["summaryExtra"]); - } - if (replicationSummary["members"].length > 0) { - print(getHeader("Replica set members",FILLER,LENGTH)); - replicationSummary["members"].forEach( - function(member, array, index) { - print(member); - } - ); - } - } - print(getHeader("Server Status",FILLER,LENGTH)) - printjson(basicInfo["serverStatus"]); - print(getHeader("Server Parameters",FILLER,LENGTH)) - printjson(basicInfo["parameters"]); - print(getHeader("Command Line Options",FILLER,LENGTH)) - printjson(basicInfo["cmdLineOpts"]); +print(getHeader("Ognom Toolkit MongoDB Summary Report",FILLER,LENGTH)); +var basicInfo = getInstanceBasicInfo(db); +print("Report generated on " + basicInfo["hostname"] + " at " + basicInfo["serverTime"]); +print(basicInfo["inprog"]); +if (isMongos()) { + print(getHeader("Sharding Summary (mongos detected)",FILLER,LENGTH)); + shardsInfo = getShardingSummary(); + print("Detected " + shardsInfo["shards"].length + " shards"); + print("Sharded databases: "); + shardsInfo["shardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); + print(""); + print("Unsharded databases: "); + shardsInfo["unshardedDatabases"].forEach(function (element, array, index) {print(" " + element["_id"]);}); + print(""); + print(getHeader("Shards detail",FILLER,LENGTH)); + getShardsInfo()["shards"].forEach( + function (element, array, index) { + print("Shard " + element["_id"] + " @ " + element["host"]); + print("(" + element["hostInfo"]["inprog"] + ")"); + print(element["replicationSummary"]["summary"]); + print(element["replicationSummary"]["summaryExtra"]); + print(""); + } + ); +} else { + print(getHeader("Replication summary",FILLER,LENGTH)); + replicationSummary = getReplicationSummary(db); + if (replicationSummary["summary"]) { + print(replicationSummary["summary"]) + } else { + print("Something is wrong with the replication summary (it is undefined)") + } + if (replicationSummary["summaryExtra"]) { + print(replicationSummary["summaryExtra"]); + } + if (replicationSummary["members"].length > 0) { + print(getHeader("Replica set members",FILLER,LENGTH)); + replicationSummary["members"].forEach( + function(member, array, index) { + print(member); + } + ); + } +} +print(getHeader("Server Status",FILLER,LENGTH)) +printjson(basicInfo["serverStatus"]); +print(getHeader("Server Parameters",FILLER,LENGTH)) +printjson(basicInfo["parameters"]); +print(getHeader("Command Line Options",FILLER,LENGTH)) +printjson(basicInfo["cmdLineOpts"]); #+END_SRC We also need presentation code for the extra script. @@ -359,13 +361,13 @@ printExtraDiagnosticsInfo(); And finally, create a shell script that can invoke the js with the right arguments #+HEADERS: :tangle mongo-summary.sh #+BEGIN_SRC sh - extra=0 - [ "$1" == "--extra" ] && { - extra=1 - shift - } - mongo mongo-summary.js $* - [ $extra -eq 1 ] && mongo mongo-summary-extra.js $* + extra=0 + [ "$1" == "--extra" ] && { + extra=1 + shift + } + mongo mongo-summary.js $* + [ $extra -eq 1 ] && mongo mongo-summary-extra.js $* #+END_SRC ** Tests This section includes the test suite for the utilities. @@ -378,7 +380,16 @@ We test the following scenarios: - sharded cluster - sharded cluster of replica sets -At this moment the tests only run the script, but there is no post validation. The ultimate goal is to validate the output files against pre supplied ones. +At this moment the tests only run the script and perform very primitive validations. The ultimate goal is to validate the output files against pre supplied ones. + +If you have multiple mongodb versions available and would like to test a specific one, set the MST_MONGO, MST_MONGOD and MST_MONGOS variables to the full path to mongo, mongod and mongos respectively, before running the scripts. If those are unset, we default to mongo, mongod and mongos: + +#+HEADERS: :tangle mongo-summary-test.sh +#+BEGIN_SRC sh +_MST_MONGOD=${MST_MONGOD:-mongod} +_MST_MONGOS=${MST_MONGOS:-mongos} +_MST_MONGO=${MST_MONGO:-mongo} +#+END_SRC We'll need a global variable pointing to the root directory where we'll be creating the datadirs for each mongod we'll start: #+HEADERS: :tangle mongo-summary-test.sh @@ -411,11 +422,11 @@ Creating a dbpath is just mkdir, with the precaution that if it exists, we'll pu #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_createDatadir() - { - test -d $1 && rm -rf $mst_DBPATH_ROOT/$1 - mkdir -p $mst_DBPATH_ROOT/$1 - } +function mst_createDatadir() +{ + test -d $1 && rm -rf $mst_DBPATH_ROOT/$1 + mkdir -p $mst_DBPATH_ROOT/$1 +} #+END_SRC Starting an instance involves creating its datadir, invoking the right command (mongod or mongos) and setting the dbpath and port arguments. @@ -428,28 +439,46 @@ This function takes the following arguments: If program is mongos, then we create the datadir (as it will be used for logging), but we don't include the --dbpath option, as mongos does not recognize it. #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_startInstance() - { - program=$1 - dbpath=$2 - port=$3 - dbpath_arg="" - mst_createDatadir $dbpath - [ "$program" != "mongos" ] && dbpath_arg="--dbpath $mst_DBPATH_ROOT/$dbpath" - shift; shift; shift - $program $dbpath_arg --port=$port --logpath $mst_DBPATH_ROOT/$dbpath/log --fork --pidfilepath $mst_DBPATH_ROOT/$dbpath/pid $* - sleep 5 - } +function mst_startInstance() +{ + program=$1 + dbpath=$2 + port=$3 + dbpath_arg="" + mst_createDatadir $dbpath + [ $(echo $program|grep -c mongos) -eq 0 ] && dbpath_arg="--dbpath $mst_DBPATH_ROOT/$dbpath" + shift; shift; shift + $program $dbpath_arg --port=$port --logpath $mst_DBPATH_ROOT/$dbpath/log --fork --pidfilepath $mst_DBPATH_ROOT/$dbpath/pid $* + sleep 5 +} #+END_SRC To stop (and destroy) an instance we just need the dbpath, which is $1 for this function: #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_stopInstance() - { - kill $(cat $mst_DBPATH_ROOT/$1/pid) - rm -rf $mst_DBPATH_ROOT/$1 - } +function mst_stopInstance() +{ + kill $(cat $mst_DBPATH_ROOT/$1/pid) + rm -rf $mst_DBPATH_ROOT/$1 +} +#+END_SRC + +This simple function receives a file name and a list of strings, and validates that they are found on the file: +#+HEADERS: :tangle mongo-summary-test.sh +#+BEGIN_SRC sh +function mst_validateOutput() +{ + f=$1; shift + ok=0 + while [ -n "$1" ]; do + grep "$1" $f>/dev/null || { + ok=1 + echo "$1 not found on $f">&2 + } + shift + done + return $ok +} #+END_SRC Now we're ready to go through the test cases in sequence: @@ -460,12 +489,13 @@ We just need to: - terminate the instance and remove the datadir #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_test_standalone_mongod() - { - mst_startInstance mongod standalone $mst_BASE_PORT - sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_standalone_mongod.result.txt - mst_stopInstance standalone - } +function mst_test_standalone_mongod() +{ + mst_startInstance $_MST_MONGOD standalone $mst_BASE_PORT + sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_standalone_mongod.result.txt + mst_stopInstance standalone + mst_validateOutput test_standalone_mongod.result.txt "Standalone mongod" version backgroundFlushing "Server Parameters" argv "local has" Logs +} #+END_SRC *** replica set For this test we'll start four instances: @@ -474,44 +504,45 @@ For this test we'll start four instances: - an arbiter #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_test_replica_test() - { - nodes="primary secondary1 secondary2 arbiter" - port_offset=0 - for node in $nodes; do - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet "test" - port_offset=$((port_offset + 1)) - done +function mst_test_replica_set() +{ + nodes="primary secondary1 secondary2 arbiter" + port_offset=0 + for node in $nodes; do + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet "test" + port_offset=$((port_offset + 1)) + done #+END_SRC Now, we need to configure the replica set. #+HEADERS: :tangle mongo-summary-test-replset.js :noweb yes #+BEGIN_SRC js - <> - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+0 ,prefix+1, prefix+2, prefix+3].forEach( - function (element, array, index) { - if (element==HOSTNAME+":"+BASE_PORT+3) { - rs.add(element,true); - } else { - rs.add(element); - } - rs.config(); - } - ); + <> + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+0 ,prefix+1, prefix+2, prefix+3].forEach( + function (element, array, index) { + if (element==HOSTNAME+":"+BASE_PORT+3) { + rs.add(element,true); + } else { + rs.add(element); + } + rs.config(); + } + ); #+END_SRC And now we're ready to generate the report and stop the instances. #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - mongo --port $mst_BASE_PORT mongo-summary-test-replset.js - echo "Sleeping 2 seconds wainting for the replica set configuration to get applied" && sleep 2 - sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_replica_set.result.txt - for node in $nodes; do - mst_stopInstance $node - done - } + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-replset.js + echo "Sleeping 2 seconds waiting for the replica set configuration to get applied" && sleep 2 + sh mongo-summary.sh --extra --port $mst_BASE_PORT > test_replica_set.result.txt + for node in $nodes; do + mst_stopInstance $node + done + mst_validateOutput test_replica_set.result.txt "Node is PRIMARY" 28002 connections "Server Parameters" argv "local has" +} #+END_SRC *** sharded cluster For this test we'll start six instances: @@ -524,54 +555,55 @@ For this test we'll start six instances: #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_test_shard_pair() - { - nodes="shard1 shard2 config1 config2 config3 mongos" - port_offset=0 - config1_port=$((mst_BASE_PORT + 2)) - config2_port=$((mst_BASE_PORT + 3)) - config3_port=$((mst_BASE_PORT + 4)) - mongos_port=$((mst_BASE_PORT + 5)) - for node in $nodes; do - if [ $(echo $node|grep -c config) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --configsvr - elif [ "$node" == "mongos" ]; then - mst_startInstance mongos $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" - else - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) - fi - port_offset=$((port_offset + 1)) - done +function mst_test_shard_pair() +{ + nodes="shard1 shard2 config1 config2 config3 mongos" + port_offset=0 + config1_port=$((mst_BASE_PORT + 2)) + config2_port=$((mst_BASE_PORT + 3)) + config3_port=$((mst_BASE_PORT + 4)) + mongos_port=$((mst_BASE_PORT + 5)) + for node in $nodes; do + if [ $(echo $node|grep -c config) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --configsvr + elif [ "$node" == "mongos" ]; then + mst_startInstance $_MST_MONGOS $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" + else + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) + fi + port_offset=$((port_offset + 1)) + done #+END_SRC Next, we add the shards: #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do - mongo --port $mongos_port --eval "sh.addShard(\"$mst_HOSTNAME:$port\")" - done + for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do +$_MST_MONGO --port $mongos_port --eval "sh.addShard(\"$mst_HOSTNAME:$port\")" + done #+END_SRC We can now enable sharding for a database: #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh -mongo --port $mongos_port --eval "sh.enableSharding(\"test\")" -mongo $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' +$_MST_MONGO --port $mongos_port --eval "sh.enableSharding(\"test\")" +$_MST_MONGO $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' #+END_SRC And we're now ready to run the test and stop the instances: #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster.result.txt - for node in $nodes; do - mst_stopInstance $node - done +sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster.result.txt +for node in $nodes; do + mst_stopInstance $node +done +mst_validateOutput test_sharded_cluster.result.txt "Sharding Summary" "Detected 2 shards" "Shards detail" "operations in progress" #+END_SRC #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - } +} #+END_SRC @@ -580,26 +612,26 @@ This is the same as the previous case, except that we need 4 data nodes, as each #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - function mst_test_shard_replset() - { - nodes="shard1_1 shard1_2 shard2_1 shard2_2 config1 config2 config3 mongos" - port_offset=0 - config1_port=$((mst_BASE_PORT + 4)) - config2_port=$((mst_BASE_PORT + 5)) - config3_port=$((mst_BASE_PORT + 6)) - mongos_port=$((mst_BASE_PORT + 7)) - for node in $nodes; do - if [ $(echo $node|grep -c config) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --configsvr - elif [ "$node" == "mongos" ]; then - mst_startInstance mongos $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" - elif [ $(echo $node|grep -c shard1) -gt 0 ]; then - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet rs1 - else - mst_startInstance mongod $node $((mst_BASE_PORT + port_offset)) --replSet rs2 - fi - port_offset=$((port_offset + 1)) - done +function mst_test_shard_replset() +{ + nodes="shard1_1 shard1_2 shard2_1 shard2_2 config1 config2 config3 mongos" + port_offset=0 + config1_port=$((mst_BASE_PORT + 4)) + config2_port=$((mst_BASE_PORT + 5)) + config3_port=$((mst_BASE_PORT + 6)) + mongos_port=$((mst_BASE_PORT + 7)) + for node in $nodes; do + if [ $(echo $node|grep -c config) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --configsvr + elif [ "$node" == "mongos" ]; then + mst_startInstance $_MST_MONGOS $node $((mst_BASE_PORT + port_offset)) --configdb "$mst_HOSTNAME:$config1_port,$mst_HOSTNAME:$config2_port,$mst_HOSTNAME:$config3_port" + elif [ $(echo $node|grep -c shard1) -gt 0 ]; then + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet rs1 + else + mst_startInstance $_MST_MONGOD $node $((mst_BASE_PORT + port_offset)) --replSet rs2 + fi + port_offset=$((port_offset + 1)) + done #+END_SRC @@ -607,53 +639,53 @@ Now we need to configure the replica sets. #+HEADERS: :tangle mongo-summary-test-sharded-rs1.js :noweb yes #+BEGIN_SRC js - <> - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+0 ,prefix+1 ].forEach( - function (element, array, index) { - rs.add(element); - rs.config(); - } - ); + <> + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+0 ,prefix+1 ].forEach( + function (element, array, index) { + rs.add(element); + rs.config(); + } + ); #+END_SRC #+HEADERS: :tangle mongo-summary-test-sharded-rs2.js :noweb yes #+BEGIN_SRC js - <> - rs.initiate(); - var prefix = HOSTNAME+":"+BASE_PORT; - [ prefix+2, prefix+3 ].forEach( - function (element, array, index) { - rs.add(element); - rs.config(); - } - ); + <> + rs.initiate(); + var prefix = HOSTNAME+":"+BASE_PORT; + [ prefix+2, prefix+3 ].forEach( + function (element, array, index) { + rs.add(element); + rs.config(); + } + ); #+END_SRC I need to run the sharded-rsN scripts twice because otherwise the secondary won't get added to the replica set. #+HEADERS: :tangle mongo-summary-test.sh #+BEGIN_SRC sh - mongo --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js - sleep 1 - mongo --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js - sleep 1 - mongo --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js - sleep 1 - mongo --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js - sleep 1 - for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do - mongo --port $mongos_port --eval "sh.addShard(\"rs1/$mst_HOSTNAME:$port\")" - done - for port in $((mst_BASE_PORT + 2)) $((mst_BASE_PORT + 3)); do - mongo --port $mongos_port --eval "sh.addShard(\"rs2/$mst_HOSTNAME:$port\")" - done - - mongo --port $mongos_port --eval "sh.enableSharding(\"test\")" - mongo $mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' - - sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster_replset.result.txt - for node in $nodes; do - mst_stopInstance $node - done - } + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js + sleep 1 + $_MST_MONGO --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js + sleep 1 + $_MST_MONGO --port $mst_BASE_PORT mongo-summary-test-sharded-rs1.js + sleep 1 + $_MST_MONGO --port $((mst_BASE_PORT+2)) mongo-summary-test-sharded-rs2.js + sleep 1 + for port in $mst_BASE_PORT $((mst_BASE_PORT + 1)); do + $_MST_MONGO --port $mongos_port --eval "sh.addShard(\"rs1/$mst_HOSTNAME:$port\")" + done + for port in $((mst_BASE_PORT + 2)) $((mst_BASE_PORT + 3)); do + $_MST_MONGO --port $mongos_port --eval "sh.addShard(\"rs2/$mst_HOSTNAME:$port\")" + done + + $_MST_MONGO --port $mongos_port --eval "sh.enableSharding(\"test\")" + $_MST_MONGO$mst_HOSTNAME:$mongos_port/test --eval 'db.test.insert({test:true})' + + sh mongo-summary.sh --extra --port $mongos_port > test_sharded_cluster_replset.result.txt + for node in $nodes; do + mst_stopInstance $node + done +} #+END_SRC diff --git a/mongo-summary/sample_output/test_replica_set.result.txt b/mongo-summary/sample_output/test_replica_set.result.txt new file mode 100644 index 0000000..444dbbb --- /dev/null +++ b/mongo-summary/sample_output/test_replica_set.result.txt @@ -0,0 +1,1350 @@ +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28000/test + +# Percona Toolkit MongoDB Summary Report #################### + +Report generated on telecaster.local:28000 at 2016-02-06 02:44:21 GMT-0300 (ART) +0 operations in progress + +# Replication summary ####################################### + +Node is PRIMARY in a 4 members replica set +The set has 0 secondaries and 1 arbiters + +# Replica set members ####################################### + +telecaster.local:28000 +telecaster.local:28001 +telecaster.local:28002 +telecaster.local:28003 + +# Server Status ############################################# + +{ + "host" : "telecaster.local:28000", + "version" : "3.0.4", + "process" : "mongod", + "pid" : NumberLong(23044), + "uptime" : 24, + "uptimeMillis" : NumberLong(23217), + "uptimeEstimate" : 21, + "localTime" : ISODate("2016-03-26T05:44:21.199Z"), + "asserts" : { + "regular" : 0, + "warning" : 0, + "msg" : 0, + "user" : 0, + "rollovers" : 0 + }, + "backgroundFlushing" : { + "flushes" : 0, + "total_ms" : 0, + "average_ms" : 0, + "last_ms" : 0, + "last_finished" : ISODate("1970-01-01T00:00:00Z") + }, + "connections" : { + "current" : 4, + "available" : 2044, + "totalCreated" : NumberLong(10) + }, + "cursors" : { + "note" : "deprecated, use server status metrics", + "clientCursors_size" : 0, + "totalOpen" : 0, + "pinned" : 0, + "totalNoTimeout" : 0, + "timedOut" : 0 + }, + "dur" : { + "commits" : 24, + "journaledMB" : 0.016384, + "writeToDataFilesMB" : 0.029623, + "compression" : 0.5431640365999204, + "commitsInWriteLock" : 0, + "earlyCommits" : 0, + "timeMs" : { + "dt" : 3027, + "prepLogBuffer" : 0, + "writeToJournal" : 0, + "writeToDataFiles" : 0, + "remapPrivateView" : 0, + "commits" : 352, + "commitsInWriteLock" : 0 + } + }, + "extra_info" : { + "note" : "fields vary by platform", + "page_faults" : 23 + }, + "globalLock" : { + "totalTime" : NumberLong(23216000), + "currentQueue" : { + "total" : 0, + "readers" : 0, + "writers" : 0 + }, + "activeClients" : { + "total" : 15, + "readers" : 0, + "writers" : 0 + } + }, + "locks" : { + "Global" : { + "acquireCount" : { + "r" : NumberLong(106), + "w" : NumberLong(15), + "R" : NumberLong(1), + "W" : NumberLong(12) + } + }, + "MMAPV1Journal" : { + "acquireCount" : { + "r" : NumberLong(35), + "w" : NumberLong(38), + "R" : NumberLong(206) + }, + "acquireWaitCount" : { + "w" : NumberLong(1), + "R" : NumberLong(1) + }, + "timeAcquiringMicros" : { + "w" : NumberLong(33), + "R" : NumberLong(351562) + } + }, + "Database" : { + "acquireCount" : { + "r" : NumberLong(38), + "w" : NumberLong(4), + "R" : NumberLong(1), + "W" : NumberLong(11) + }, + "acquireWaitCount" : { + "W" : NumberLong(1) + }, + "timeAcquiringMicros" : { + "W" : NumberLong(18) + } + }, + "Collection" : { + "acquireCount" : { + "R" : NumberLong(37) + } + }, + "Metadata" : { + "acquireCount" : { + "W" : NumberLong(9) + } + }, + "oplog" : { + "acquireCount" : { + "w" : NumberLong(4), + "R" : NumberLong(1) + } + } + }, + "network" : { + "bytesIn" : 5192, + "bytesOut" : 12724, + "numRequests" : 38 + }, + "opcounters" : { + "insert" : 0, + "query" : 5, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 34 + }, + "opcountersRepl" : { + "insert" : 0, + "query" : 0, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 0 + }, + "repl" : { + "setName" : "test", + "setVersion" : 4, + "ismaster" : true, + "secondary" : false, + "hosts" : [ + "telecaster.local:28000", + "telecaster.local:28001", + "telecaster.local:28002" + ], + "arbiters" : [ + "telecaster.local:28003" + ], + "primary" : "telecaster.local:28000", + "me" : "telecaster.local:28000", + "electionId" : ObjectId("56f621b3277860e29a51771b"), + "rbid" : 811374282 + }, + "storageEngine" : { + "name" : "mmapv1" + }, + "writeBacksQueued" : false, + "mem" : { + "bits" : 64, + "resident" : 46, + "virtual" : 3188, + "supported" : true, + "mapped" : 336, + "mappedWithJournal" : 672 + }, + "metrics" : { + "commands" : { + "" : NumberLong(0), + "_getUserCacheGeneration" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_isSelf" : { + "failed" : NumberLong(0), + "total" : NumberLong(5) + }, + "_mergeAuthzCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_migrateClone" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkAbort" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkCommit" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_transferMods" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "aggregate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "appendOplogNote" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "applyOps" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authSchemaUpgrade" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authenticate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "availableQueryOptions" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "buildInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "checkShardingIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cleanupOrphaned" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "clone" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cloneCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cloneCollectionAsCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collMod" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "compact" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolSync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connectionStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "convertToCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydb" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydbgetnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydbsaslstart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "count" : { + "failed" : NumberLong(0), + "total" : NumberLong(4) + }, + "create" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "currentOpCtx" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cursorInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dataSize" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbHash" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "delete" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "diagLogging" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "distinct" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "driverOIDTest" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "drop" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllRolesFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllUsersFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "eval" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "explain" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "features" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "filemd5" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "find" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "findAndModify" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "forceerror" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "fsync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoNear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoSearch" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getCmdLineOpts" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLastError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLog" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getPrevError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardMap" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantPrivilegesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "group" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "handshake" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "hostInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "insert" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "invalidateUserCache" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "isMaster" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCommands" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listDatabases" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logRotate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logout" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapReduce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapreduce" : { + "shardedfinish" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "medianKey" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mergeChunks" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "moveChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "parallelCollectionScan" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "ping" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClearFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListPlans" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListQueryShapes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheSetFilter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "profile" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "reIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "renameCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairCursor" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetElect" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetFreeze" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetFresh" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetConfig" : { + "failed" : NumberLong(0), + "total" : NumberLong(4) + }, + "replSetGetRBID" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetHeartbeat" : { + "failed" : NumberLong(0), + "total" : NumberLong(11) + }, + "replSetInitiate" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "replSetMaintenance" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetReconfig" : { + "failed" : NumberLong(1), + "total" : NumberLong(4) + }, + "replSetStepDown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetSyncFrom" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetUpdatePosition" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resetError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokePrivilegesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "rolesInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslContinue" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "serverStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "setParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "setShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardConnPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardingState" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shutdown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitVector" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "top" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "touch" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "unsetSharding" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "update" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "usersInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "validate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "whatsmyuri" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "writebacklisten" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "cursor" : { + "timedOut" : NumberLong(0), + "open" : { + "noTimeout" : NumberLong(0), + "pinned" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "document" : { + "deleted" : NumberLong(0), + "inserted" : NumberLong(0), + "returned" : NumberLong(4), + "updated" : NumberLong(0) + }, + "getLastError" : { + "wtime" : { + "num" : 0, + "totalMillis" : 0 + }, + "wtimeouts" : NumberLong(0) + }, + "operation" : { + "fastmod" : NumberLong(0), + "idhack" : NumberLong(0), + "scanAndOrder" : NumberLong(0), + "writeConflicts" : NumberLong(0) + }, + "queryExecutor" : { + "scanned" : NumberLong(0), + "scannedObjects" : NumberLong(4) + }, + "record" : { + "moves" : NumberLong(1) + }, + "repl" : { + "apply" : { + "batches" : { + "num" : 0, + "totalMillis" : 0 + }, + "ops" : NumberLong(0) + }, + "buffer" : { + "count" : NumberLong(0), + "maxSizeBytes" : 268435456, + "sizeBytes" : NumberLong(0) + }, + "network" : { + "bytes" : NumberLong(0), + "getmores" : { + "num" : 0, + "totalMillis" : 0 + }, + "ops" : NumberLong(0), + "readersCreated" : NumberLong(1) + }, + "preload" : { + "docs" : { + "num" : 0, + "totalMillis" : 0 + }, + "indexes" : { + "num" : 0, + "totalMillis" : 0 + } + } + }, + "storage" : { + "freelist" : { + "search" : { + "bucketExhausted" : NumberLong(0), + "requests" : NumberLong(22), + "scanned" : NumberLong(0) + } + } + }, + "ttl" : { + "deletedDocuments" : NumberLong(0), + "passes" : NumberLong(0) + } + }, + "ok" : 1 +} + +# Server Parameters ######################################### + +{ + "authSchemaVersion" : 5, + "authenticationMechanisms" : [ + "MONGODB-CR", + "MONGODB-X509", + "SCRAM-SHA-1" + ], + "clusterAuthMode" : "undefined", + "connPoolMaxConnsPerHost" : 200, + "connPoolMaxShardedConnsPerHost" : 200, + "cursorTimeoutMillis" : 600000, + "enableCollectionLocking" : true, + "enableLocalhostAuthBypass" : true, + "enableTestCommands" : 0, + "failIndexKeyTooLong" : true, + "internalGeoNearQuery2DMaxCoveringCells" : 16, + "internalGeoPredicateQuery2DMaxCoveringCells" : 16, + "internalQueryCacheEvictionRatio" : 10, + "internalQueryCacheFeedbacksStored" : 20, + "internalQueryCacheReplanningEnabled" : false, + "internalQueryCacheSize" : 5000, + "internalQueryCacheStdDeviations" : 2, + "internalQueryCacheWriteOpsBetweenFlush" : 1000, + "internalQueryEnumerationMaxIntersectPerAnd" : 3, + "internalQueryEnumerationMaxOrSolutions" : 10, + "internalQueryExecMaxBlockingSortBytes" : 33554432, + "internalQueryExecYieldIterations" : 128, + "internalQueryExecYieldPeriodMS" : 10, + "internalQueryForceIntersectionPlans" : false, + "internalQueryMaxScansToExplode" : 200, + "internalQueryPlanEvaluationCollFraction" : 0.3, + "internalQueryPlanEvaluationMaxResults" : 101, + "internalQueryPlanEvaluationWorks" : 10000, + "internalQueryPlanOrChildrenIndependently" : true, + "internalQueryPlannerEnableHashIntersection" : false, + "internalQueryPlannerEnableIndexIntersection" : true, + "internalQueryPlannerMaxIndexedSolutions" : 64, + "internalSCCAllowFastestAuthConfigReads" : false, + "internalSCCAllowFastestMetadataConfigReads" : false, + "journalCommitInterval" : 0, + "logComponentVerbosity" : { + "verbosity" : 0, + "accessControl" : { + "verbosity" : -1 + }, + "command" : { + "verbosity" : -1 + }, + "control" : { + "verbosity" : -1 + }, + "geo" : { + "verbosity" : -1 + }, + "index" : { + "verbosity" : -1 + }, + "network" : { + "verbosity" : -1 + }, + "query" : { + "verbosity" : -1 + }, + "replication" : { + "verbosity" : -1 + }, + "sharding" : { + "verbosity" : -1 + }, + "storage" : { + "verbosity" : -1, + "journal" : { + "verbosity" : -1 + } + }, + "write" : { + "verbosity" : -1 + } + }, + "logLevel" : 0, + "logUserIds" : false, + "maxSyncSourceLagSecs" : 30, + "newCollectionsUsePowerOf2Sizes" : true, + "notablescan" : false, + "queueForMigrationCommit" : true, + "quiet" : false, + "replApplyBatchSize" : 1, + "replIndexPrefetch" : "all", + "replMonitorMaxFailedChecks" : 30, + "saslHostName" : "telecaster.local", + "saslServiceName" : "mongodb", + "saslauthdPath" : "", + "scramIterationCount" : 10000, + "skipCorruptDocumentsWhenCloning" : false, + "sslMode" : "disabled", + "syncdelay" : 60, + "textSearchEnabled" : true, + "traceExceptions" : false, + "traceWriteConflictExceptions" : false, + "ttlMonitorEnabled" : true, + "ttlMonitorSleepSecs" : 60, + "wiredTigerConcurrentReadTransactions" : 128, + "wiredTigerConcurrentWriteTransactions" : 128, + "ok" : 1 +} + +# Command Line Options ###################################### + +{ + "argv" : [ + "mongod", + "--dbpath", + "/Users/fernandoipar/mongo-summary-tests//primary", + "--port=28000", + "--logpath", + "/Users/fernandoipar/mongo-summary-tests//primary/log", + "--fork", + "--pidfilepath", + "/Users/fernandoipar/mongo-summary-tests//primary/pid", + "--replSet", + "test" + ], + "parsed" : { + "net" : { + "port" : 28000 + }, + "processManagement" : { + "fork" : true, + "pidFilePath" : "/Users/fernandoipar/mongo-summary-tests//primary/pid" + }, + "replication" : { + "replSet" : "test" + }, + "storage" : { + "dbPath" : "/Users/fernandoipar/mongo-summary-tests//primary" + }, + "systemLog" : { + "destination" : "file", + "path" : "/Users/fernandoipar/mongo-summary-tests//primary/log" + } + }, + "ok" : 1 +} +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28000/test + +# Extra info ################################################ + +local has 5 collections and 352321536 bytes on disk +Collections: + me +Indexes for me: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.me" + } +] +Indexes for oplog.rs: +[ ] +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +Indexes for system.replset: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.system.replset" + } +] + oplog.rs +Indexes for me: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.me" + } +] +Indexes for oplog.rs: +[ ] +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +Indexes for system.replset: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.system.replset" + } +] + startup_log +Indexes for me: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.me" + } +] +Indexes for oplog.rs: +[ ] +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +Indexes for system.replset: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.system.replset" + } +] + system.indexes +Indexes for me: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.me" + } +] +Indexes for oplog.rs: +[ ] +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +Indexes for system.replset: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.system.replset" + } +] + system.replset +Indexes for me: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.me" + } +] +Indexes for oplog.rs: +[ ] +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +Indexes for system.replset: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.system.replset" + } +] +{ + "set" : "test", + "date" : ISODate("2016-03-26T05:44:21.267Z"), + "myState" : 1, + "members" : [ + { + "_id" : 0, + "name" : "telecaster.local:28000", + "health" : 1, + "state" : 1, + "stateStr" : "PRIMARY", + "uptime" : 24, + "optime" : Timestamp(1458971059, 5), + "optimeDate" : ISODate("2016-03-26T05:44:19Z"), + "electionTime" : Timestamp(1458971059, 2), + "electionDate" : ISODate("2016-03-26T05:44:19Z"), + "configVersion" : 4, + "self" : true + }, + { + "_id" : 1, + "name" : "telecaster.local:28001", + "health" : 1, + "state" : 5, + "stateStr" : "STARTUP2", + "uptime" : 2, + "optime" : Timestamp(0, 0), + "optimeDate" : ISODate("1970-01-01T00:00:00Z"), + "lastHeartbeat" : ISODate("2016-03-26T05:44:21.143Z"), + "lastHeartbeatRecv" : ISODate("2016-03-26T05:44:21.141Z"), + "pingMs" : 0, + "configVersion" : 4 + }, + { + "_id" : 2, + "name" : "telecaster.local:28002", + "health" : 1, + "state" : 5, + "stateStr" : "STARTUP2", + "uptime" : 2, + "optime" : Timestamp(0, 0), + "optimeDate" : ISODate("1970-01-01T00:00:00Z"), + "lastHeartbeat" : ISODate("2016-03-26T05:44:21.143Z"), + "lastHeartbeatRecv" : ISODate("2016-03-26T05:44:21.151Z"), + "pingMs" : 0, + "configVersion" : 4 + }, + { + "_id" : 3, + "name" : "telecaster.local:28003", + "health" : 1, + "state" : 7, + "stateStr" : "ARBITER", + "uptime" : 2, + "lastHeartbeat" : ISODate("2016-03-26T05:44:21.144Z"), + "lastHeartbeatRecv" : ISODate("2016-03-26T05:44:21.151Z"), + "pingMs" : 1, + "configVersion" : 4 + } + ], + "ok" : 1 +} + +# Logs ###################################################### + +2016-03-26T02:43:58.017-0300 I JOURNAL [initandlisten] journal dir=/Users/fernandoipar/mongo-summary-tests//primary/journal +2016-03-26T02:43:58.017-0300 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed +2016-03-26T02:43:58.032-0300 I JOURNAL [durability] Durability thread started +2016-03-26T02:43:58.033-0300 I CONTROL [initandlisten] MongoDB starting : pid=23044 port=28000 dbpath=/Users/fernandoipar/mongo-summary-tests//primary 64-bit host=telecaster.local +2016-03-26T02:43:58.033-0300 I JOURNAL [journal writer] Journal writer thread started +2016-03-26T02:43:58.033-0300 I CONTROL [initandlisten] db version v3.0.4 +2016-03-26T02:43:58.033-0300 I CONTROL [initandlisten] git version: nogitversion +2016-03-26T02:43:58.034-0300 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49 +2016-03-26T02:43:58.034-0300 I CONTROL [initandlisten] allocator: system +2016-03-26T02:43:58.034-0300 I CONTROL [initandlisten] options: { net: { port: 28000 }, processManagement: { fork: true, pidFilePath: "/Users/fernandoipar/mongo-summary-tests//primary/pid" }, replication: { replSet: "test" }, storage: { dbPath: "/Users/fernandoipar/mongo-summary-tests//primary" }, systemLog: { destination: "file", path: "/Users/fernandoipar/mongo-summary-tests//primary/log" } } +2016-03-26T02:43:58.034-0300 I INDEX [initandlisten] allocating new ns file /Users/fernandoipar/mongo-summary-tests//primary/local.ns, filling with zeroes... +2016-03-26T02:43:58.061-0300 I STORAGE [FileAllocator] allocating new datafile /Users/fernandoipar/mongo-summary-tests//primary/local.0, filling with zeroes... +2016-03-26T02:43:58.061-0300 I STORAGE [FileAllocator] creating directory /Users/fernandoipar/mongo-summary-tests//primary/_tmp +2016-03-26T02:43:58.136-0300 I STORAGE [FileAllocator] done allocating datafile /Users/fernandoipar/mongo-summary-tests//primary/local.0, size: 64MB, took 0.074 secs +2016-03-26T02:43:58.158-0300 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument Did not find replica set configuration document in local.system.replset +2016-03-26T02:43:58.160-0300 I NETWORK [initandlisten] waiting for connections on port 28000 +2016-03-26T02:44:18.310-0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55371 #1 (1 connection now open) +2016-03-26T02:44:18.311-0300 I COMMAND [conn1] replSet info initiate : no configuration specified. Using a default configuration for the set +2016-03-26T02:44:18.311-0300 I COMMAND [conn1] replSet created this configuration for initiation : { _id: "test", version: 1, members: [ { _id: 0, host: "telecaster.local:28000" } ] } +2016-03-26T02:44:18.311-0300 I REPL [conn1] replSetInitiate admin command received from client +2016-03-26T02:44:18.677-0300 I REPL [conn1] replSet replSetInitiate config object with 1 members parses ok +2016-03-26T02:44:18.680-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 1, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 } } } +2016-03-26T02:44:18.680-0300 I REPL [ReplicationExecutor] This node is telecaster.local:28000 in the config +2016-03-26T02:44:18.680-0300 I REPL [ReplicationExecutor] transition to STARTUP2 +2016-03-26T02:44:18.681-0300 I REPL [conn1] ****** +2016-03-26T02:44:18.681-0300 I REPL [conn1] creating replication oplog of size: 192MB... +2016-03-26T02:44:18.681-0300 I STORAGE [FileAllocator] allocating new datafile /Users/fernandoipar/mongo-summary-tests//primary/local.1, filling with zeroes... +2016-03-26T02:44:19.100-0300 I STORAGE [FileAllocator] done allocating datafile /Users/fernandoipar/mongo-summary-tests//primary/local.1, size: 256MB, took 0.419 secs +2016-03-26T02:44:19.122-0300 I REPL [conn1] ****** +2016-03-26T02:44:19.122-0300 I REPL [conn1] Starting replication applier threads +2016-03-26T02:44:19.123-0300 I COMMAND [conn1] command admin.$cmd command: replSetInitiate { replSetInitiate: undefined } keyUpdates:0 writeConflicts:0 numYields:0 reslen:131 locks:{ Global: { acquireCount: { r: 5, w: 3, W: 2 } }, MMAPV1Journal: { acquireCount: { w: 7 }, acquireWaitCount: { w: 1 }, timeAcquiringMicros: { w: 33 } }, Database: { acquireCount: { w: 1, W: 2 } }, Metadata: { acquireCount: { W: 3 } }, oplog: { acquireCount: { w: 1 } } } 811ms +2016-03-26T02:44:19.123-0300 I REPL [ReplicationExecutor] transition to RECOVERING +2016-03-26T02:44:19.123-0300 I REPL [ReplicationExecutor] transition to SECONDARY +2016-03-26T02:44:19.124-0300 I REPL [ReplicationExecutor] transition to PRIMARY +2016-03-26T02:44:19.125-0300 I REPL [conn1] replSetReconfig admin command received from client +2016-03-26T02:44:19.125-0300 E REPL [conn1] replSetReconfig got BadValue Found two member configurations with same host field, members.0.host == members.1.host == telecaster.local:28000 while validating { _id: "test", version: 2, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1.0, host: "telecaster.local:28000" } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastE +2016-03-26T02:44:19.126-0300 I REPL [conn1] replSetReconfig admin command received from client +2016-03-26T02:44:19.127-0300 I REPL [conn1] replSetReconfig config object with 2 members parses ok +2016-03-26T02:44:19.129-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 2, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: +2016-03-26T02:44:19.129-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55374 #2 (2 connections now open) +2016-03-26T02:44:19.130-0300 I REPL [ReplicationExecutor] This node is telecaster.local:28000 in the config +2016-03-26T02:44:19.130-0300 I REPL [ReplicationExecutor] Member telecaster.local:28001 is now in state STARTUP +2016-03-26T02:44:19.131-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55375 #3 (3 connections now open) +2016-03-26T02:44:19.131-0300 I REPL [conn1] replSetReconfig admin command received from client +2016-03-26T02:44:19.131-0300 I NETWORK [conn3] end connection 192.168.0.2:55375 (2 connections now open) +2016-03-26T02:44:19.134-0300 I REPL [conn1] replSetReconfig config object with 3 members parses ok +2016-03-26T02:44:19.135-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 3, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "telecaster.local:28002", arbiterOnly: false, buildIndexes: true, +2016-03-26T02:44:19.135-0300 I REPL [ReplicationExecutor] This node is telecaster.local:28000 in the config +2016-03-26T02:44:19.136-0300 I REPL [ReplicationExecutor] Member telecaster.local:28001 is now in state STARTUP2 +2016-03-26T02:44:19.136-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55379 #4 (3 connections now open) +2016-03-26T02:44:19.137-0300 I REPL [ReplicationExecutor] Member telecaster.local:28002 is now in state STARTUP +2016-03-26T02:44:19.137-0300 I REPL [conn1] replSetReconfig admin command received from client +2016-03-26T02:44:19.138-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55380 #5 (4 connections now open) +2016-03-26T02:44:19.138-0300 I NETWORK [conn5] end connection 192.168.0.2:55380 (3 connections now open) +2016-03-26T02:44:19.140-0300 I REPL [conn1] replSetReconfig config object with 4 members parses ok +2016-03-26T02:44:19.141-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 4, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "telecaster.local:28002", arbiterOnly: false, buildIndexes: true, +2016-03-26T02:44:19.141-0300 I REPL [ReplicationExecutor] This node is telecaster.local:28000 in the config +2016-03-26T02:44:19.142-0300 I REPL [ReplicationExecutor] Member telecaster.local:28002 is now in state STARTUP2 +2016-03-26T02:44:19.143-0300 I NETWORK [conn1] end connection 127.0.0.1:55371 (2 connections now open) +2016-03-26T02:44:19.144-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55388 #6 (3 connections now open) +2016-03-26T02:44:19.144-0300 I REPL [ReplicationExecutor] Member telecaster.local:28003 is now in state STARTUP +2016-03-26T02:44:19.144-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55389 #7 (4 connections now open) +2016-03-26T02:44:19.145-0300 I NETWORK [conn7] end connection 192.168.0.2:55389 (3 connections now open) +2016-03-26T02:44:19.145-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55390 #8 (4 connections now open) +2016-03-26T02:44:19.146-0300 I NETWORK [conn8] end connection 192.168.0.2:55390 (3 connections now open) +2016-03-26T02:44:20.127-0300 I REPL [rsSync] transition to primary complete; database writes are now permitted +2016-03-26T02:44:21.137-0300 I NETWORK [initandlisten] connection accepted from 192.168.0.2:55398 #9 (4 connections now open) +2016-03-26T02:44:21.138-0300 I NETWORK [conn9] end connection 192.168.0.2:55398 (3 connections now open) +2016-03-26T02:44:21.144-0300 I REPL [ReplicationExecutor] Member telecaster.local:28003 is now in state ARBITER +2016-03-26T02:44:21.195-0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55403 #10 (4 connections now open) +2016-03-26T02:44:21.212-0300 I NETWORK [conn10] end connection 127.0.0.1:55403 (3 connections now open) +2016-03-26T02:44:21.253-0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55404 #11 (4 connections now open) +2016-03-26T02:44:18.680-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 1, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 } } } +2016-03-26T02:44:18.680-0300 I REPL [ReplicationExecutor] transition to STARTUP2 +2016-03-26T02:44:19.123-0300 I REPL [ReplicationExecutor] transition to RECOVERING +2016-03-26T02:44:19.123-0300 I REPL [ReplicationExecutor] transition to SECONDARY +2016-03-26T02:44:19.124-0300 I REPL [ReplicationExecutor] transition to PRIMARY +2016-03-26T02:44:19.129-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 2, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: +2016-03-26T02:44:19.130-0300 I REPL [ReplicationExecutor] Member telecaster.local:28001 is now in state STARTUP +2016-03-26T02:44:19.135-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 3, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "telecaster.local:28002", arbiterOnly: false, buildIndexes: true, +2016-03-26T02:44:19.136-0300 I REPL [ReplicationExecutor] Member telecaster.local:28001 is now in state STARTUP2 +2016-03-26T02:44:19.137-0300 I REPL [ReplicationExecutor] Member telecaster.local:28002 is now in state STARTUP +2016-03-26T02:44:19.141-0300 I REPL [ReplicationExecutor] New replica set config in use: { _id: "test", version: 4, members: [ { _id: 0, host: "telecaster.local:28000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "telecaster.local:28001", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "telecaster.local:28002", arbiterOnly: false, buildIndexes: true, +2016-03-26T02:44:19.142-0300 I REPL [ReplicationExecutor] Member telecaster.local:28002 is now in state STARTUP2 +2016-03-26T02:44:19.144-0300 I REPL [ReplicationExecutor] Member telecaster.local:28003 is now in state STARTUP +2016-03-26T02:44:20.127-0300 I REPL [rsSync] transition to primary complete; database writes are now permitted +2016-03-26T02:44:21.144-0300 I REPL [ReplicationExecutor] Member telecaster.local:28003 is now in state ARBITER diff --git a/mongo-summary/sample_output/test_sharded_cluster.result.txt b/mongo-summary/sample_output/test_sharded_cluster.result.txt new file mode 100644 index 0000000..06a624f --- /dev/null +++ b/mongo-summary/sample_output/test_sharded_cluster.result.txt @@ -0,0 +1,892 @@ +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28005/test + +# Percona Toolkit MongoDB Summary Report #################### + +Report generated on telecaster.local:28005 at 2016-02-06 02:42:14 GMT-0300 (ART) +0 operations in progress + +# Sharding Summary (mongos detected) ######################## + +Detected 2 shards +Sharded databases: + test + +Unsharded databases: + admin + + +# Shards detail ############################################# + +Shard undefined @ telecaster.local:28000 +(0 operations in progress) +Standalone mongod + + +Shard undefined @ telecaster.local:28001 +(0 operations in progress) +Standalone mongod + + + +# Server Status ############################################# + +{ + "host" : "telecaster.local:28005", + "version" : "3.0.4", + "process" : "mongos", + "pid" : NumberLong(22849), + "uptime" : 7, + "uptimeMillis" : NumberLong(6892), + "uptimeEstimate" : 5, + "localTime" : ISODate("2016-03-26T05:42:14.773Z"), + "asserts" : { + "regular" : 0, + "warning" : 0, + "msg" : 0, + "user" : 0, + "rollovers" : 0 + }, + "connections" : { + "current" : 1, + "available" : 2047, + "totalCreated" : NumberLong(5) + }, + "extra_info" : { + "note" : "fields vary by platform", + "page_faults" : 0 + }, + "network" : { + "bytesIn" : 950, + "bytesOut" : 3015, + "numRequests" : 14 + }, + "opcounters" : { + "insert" : 1, + "query" : 0, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 14 + }, + "mem" : { + "bits" : 64, + "resident" : 5, + "virtual" : 2420, + "supported" : true + }, + "metrics" : { + "commands" : { + "" : NumberLong(0), + "_getUserCacheGeneration" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_isSelf" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_mergeAuthzCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "addShard" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "aggregate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "applyOps" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authSchemaUpgrade" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authenticate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "availableQueryOptions" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "buildInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collMod" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "compact" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolSync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connectionStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "convertToCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydb" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "count" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "create" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cursorInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dataSize" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "delete" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "distinct" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "drop" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllRolesFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllUsersFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "enableSharding" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "eval" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "explain" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "features" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "filemd5" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "find" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "findAndModify" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "flushRouterConfig" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "forceerror" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "fsync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoNear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getCmdLineOpts" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLastError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLog" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getPrevError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardMap" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantPrivilegesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "group" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "hostInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "insert" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "invalidateUserCache" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "isMaster" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "isdbgrid" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCommands" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listDatabases" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listShards" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logRotate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logout" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapReduce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mergeChunks" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "moveChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "movePrimary" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "netstat" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "ping" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClearFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListPlans" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListQueryShapes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheSetFilter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "profile" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "reIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "removeShard" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "renameCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resetError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokePrivilegesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "rolesInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslContinue" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "serverStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "setParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardConnPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shutdown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "split" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitVector" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "update" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "usersInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "validate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "whatsmyuri" : { + "failed" : NumberLong(0), + "total" : NumberLong(5) + } + }, + "cursor" : { + "open" : { + "multiTarget" : NumberLong(0), + "singleTarget" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "getLastError" : { + "wtime" : { + "num" : 0, + "totalMillis" : 0 + } + } + }, + "ok" : 1 +} + +# Server Parameters ######################################### + +{ + "authSchemaVersion" : 5, + "authenticationMechanisms" : [ + "MONGODB-CR", + "MONGODB-X509", + "SCRAM-SHA-1" + ], + "clusterAuthMode" : "undefined", + "connPoolMaxConnsPerHost" : 200, + "connPoolMaxShardedConnsPerHost" : 200, + "cursorTimeoutMillis" : NumberLong(600000), + "enableLocalhostAuthBypass" : true, + "enableTestCommands" : 0, + "internalGeoNearQuery2DMaxCoveringCells" : 16, + "internalGeoPredicateQuery2DMaxCoveringCells" : 16, + "internalQueryCacheEvictionRatio" : 10, + "internalQueryCacheFeedbacksStored" : 20, + "internalQueryCacheReplanningEnabled" : false, + "internalQueryCacheSize" : 5000, + "internalQueryCacheStdDeviations" : 2, + "internalQueryCacheWriteOpsBetweenFlush" : 1000, + "internalQueryEnumerationMaxIntersectPerAnd" : 3, + "internalQueryEnumerationMaxOrSolutions" : 10, + "internalQueryExecMaxBlockingSortBytes" : 33554432, + "internalQueryExecYieldIterations" : 128, + "internalQueryExecYieldPeriodMS" : 10, + "internalQueryForceIntersectionPlans" : false, + "internalQueryMaxScansToExplode" : 200, + "internalQueryPlanEvaluationCollFraction" : 0.3, + "internalQueryPlanEvaluationMaxResults" : 101, + "internalQueryPlanEvaluationWorks" : 10000, + "internalQueryPlanOrChildrenIndependently" : true, + "internalQueryPlannerEnableHashIntersection" : false, + "internalQueryPlannerEnableIndexIntersection" : true, + "internalQueryPlannerMaxIndexedSolutions" : 64, + "internalSCCAllowFastestAuthConfigReads" : false, + "internalSCCAllowFastestMetadataConfigReads" : false, + "logComponentVerbosity" : { + "verbosity" : 0, + "accessControl" : { + "verbosity" : -1 + }, + "command" : { + "verbosity" : -1 + }, + "control" : { + "verbosity" : -1 + }, + "geo" : { + "verbosity" : -1 + }, + "index" : { + "verbosity" : -1 + }, + "network" : { + "verbosity" : -1 + }, + "query" : { + "verbosity" : -1 + }, + "replication" : { + "verbosity" : -1 + }, + "sharding" : { + "verbosity" : -1 + }, + "storage" : { + "verbosity" : -1, + "journal" : { + "verbosity" : -1 + } + }, + "write" : { + "verbosity" : -1 + } + }, + "logLevel" : 0, + "logUserIds" : false, + "quiet" : false, + "replMonitorMaxFailedChecks" : 30, + "saslHostName" : "telecaster.local", + "saslServiceName" : "mongodb", + "saslauthdPath" : "", + "scramIterationCount" : 10000, + "sslMode" : "disabled", + "textSearchEnabled" : true, + "traceExceptions" : false, + "userCacheInvalidationIntervalSecs" : 30, + "ok" : 1 +} + +# Command Line Options ###################################### + +{ + "argv" : [ + "mongos", + "--port=28005", + "--logpath", + "/Users/fernandoipar/mongo-summary-tests//mongos/log", + "--fork", + "--pidfilepath", + "/Users/fernandoipar/mongo-summary-tests//mongos/pid", + "--configdb", + "telecaster.local:28002,telecaster.local:28003,telecaster.local:28004" + ], + "parsed" : { + "net" : { + "port" : 28005 + }, + "processManagement" : { + "fork" : true, + "pidFilePath" : "/Users/fernandoipar/mongo-summary-tests//mongos/pid" + }, + "sharding" : { + "configDB" : "telecaster.local:28002,telecaster.local:28003,telecaster.local:28004" + }, + "systemLog" : { + "destination" : "file", + "path" : "/Users/fernandoipar/mongo-summary-tests//mongos/log" + } + }, + "ok" : 1 +} +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28005/test + +# Extra info ################################################ + +test has 2 collections and 83886080 bytes on disk +Collections: + system.indexes +Indexes for system.indexes: +[ ] +Indexes for test: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "test.test" + } +] + test +Indexes for system.indexes: +[ ] +Indexes for test: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "test.test" + } +] +config has 12 collections and 16777216 bytes on disk +Collections: + actionlog +Indexes for actionlog: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.actionlog" + } +] +Indexes for changelog: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.changelog" + } +] +Indexes for chunks: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "min" : 1 + }, + "name" : "ns_1_min_1", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "shard" : 1, + "min" : 1 + }, + "name" : "ns_1_shard_1_min_1", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "lastmod" : 1 + }, + "name" : "ns_1_lastmod_1", + "ns" : "config.chunks" + } +] +Indexes for databases: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.databases" + } +] +Indexes for lockpings: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.lockpings" + }, + { + "v" : 1, + "key" : { + "ping" : 1 + }, + "name" : "ping_1", + "ns" : "config.lockpings" + } +] +Indexes for locks: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.locks" + }, + { + "v" : 1, + "key" : { + "ts" : 1 + }, + "name" : "ts_1", + "ns" : "config.locks" + }, + { + "v" : 1, + "key" : { + "state" : 1, + "process" : 1 + }, + "name" : "state_1_process_1", + "ns" : "config.locks" + } +] +Indexes for mongos: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.mongos" + } +] +Indexes for settings: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.settings" + } +] +Indexes for shards: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.shards" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "host" : 1 + }, + "name" : "host_1", + "ns" : "config.shards" + } +] +Indexes for system.indexes: +[ ] +Indexes for tags: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.tags" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "min" : 1 + }, + "name" : "ns_1_min_1", + "ns" : "config.tags" + } +] +2016-03-26T02:42:14.853-0300 E QUERY TypeError: Object function (){ + return this.serverBuildInfo().version; +} has no method 'getIndexes' + at mongo-summary-extra.js:31:36 + at Array.forEach (native) + at mongo-summary-extra.js:30:32 + at Array.forEach (native) + at mongo-summary-extra.js:27:22 + at Array.forEach (native) + at printExtraDiagnosticsInfo (mongo-summary-extra.js:20:51) + at mongo-summary-extra.js:59:1 at mongo-summary-extra.js:31 +failed to load: mongo-summary-extra.js diff --git a/mongo-summary/sample_output/test_sharded_cluster_replset.result.txt b/mongo-summary/sample_output/test_sharded_cluster_replset.result.txt new file mode 100644 index 0000000..e822ae3 --- /dev/null +++ b/mongo-summary/sample_output/test_sharded_cluster_replset.result.txt @@ -0,0 +1,872 @@ +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28007/test + +# Percona Toolkit MongoDB Summary Report #################### + +Report generated on telecaster.local:28007 at 2016-02-06 02:43:24 GMT-0300 (ART) +0 operations in progress + +# Sharding Summary (mongos detected) ######################## + +Detected 2 shards +Sharded databases: + test + +Unsharded databases: + admin + + +# Shards detail ############################################# + +Shard undefined @ telecaster.local:28000 +(0 operations in progress) +Node is PRIMARY in a 2 members replica set +The set has 0 secondaries and 0 arbiters + +Shard undefined @ telecaster.local:28001 +(0 operations in progress) +Node is STARTUP2 in a 2 members replica set +The set has 0 secondaries and 0 arbiters + +Shard undefined @ telecaster.local:28002 +(0 operations in progress) +Node is PRIMARY in a 2 members replica set +The set has 0 secondaries and 0 arbiters + +Shard undefined @ telecaster.local:28003 +(0 operations in progress) +Node is STARTUP2 in a 2 members replica set +The set has 0 secondaries and 0 arbiters + + +# Server Status ############################################# + +{ + "host" : "telecaster.local:28007", + "version" : "3.0.4", + "process" : "mongos", + "pid" : NumberLong(22978), + "uptime" : 12, + "uptimeMillis" : NumberLong(11971), + "uptimeEstimate" : 10, + "localTime" : ISODate("2016-03-26T05:43:24.360Z"), + "asserts" : { + "regular" : 0, + "warning" : 0, + "msg" : 0, + "user" : 0, + "rollovers" : 0 + }, + "connections" : { + "current" : 1, + "available" : 2047, + "totalCreated" : NumberLong(6) + }, + "extra_info" : { + "note" : "fields vary by platform", + "page_faults" : 0 + }, + "network" : { + "bytesIn" : 1008, + "bytesOut" : 3091, + "numRequests" : 15 + }, + "opcounters" : { + "insert" : 0, + "query" : 0, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 15 + }, + "mem" : { + "bits" : 64, + "resident" : 5, + "virtual" : 2420, + "supported" : true + }, + "metrics" : { + "commands" : { + "" : NumberLong(0), + "_getUserCacheGeneration" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_isSelf" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_mergeAuthzCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "addShard" : { + "failed" : NumberLong(2), + "total" : NumberLong(4) + }, + "aggregate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "applyOps" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authSchemaUpgrade" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authenticate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "availableQueryOptions" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "buildInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collMod" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "compact" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolSync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connectionStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "convertToCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydb" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "count" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "create" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cursorInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dataSize" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "delete" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "distinct" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "drop" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllRolesFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllUsersFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "enableSharding" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "eval" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "explain" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "features" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "filemd5" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "find" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "findAndModify" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "flushRouterConfig" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "forceerror" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "fsync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoNear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getCmdLineOpts" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLastError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLog" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getPrevError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardMap" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantPrivilegesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "group" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "hostInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "insert" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "invalidateUserCache" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "isMaster" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "isdbgrid" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCommands" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listDatabases" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listShards" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logRotate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logout" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapReduce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mergeChunks" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "moveChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "movePrimary" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "netstat" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "ping" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClearFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListPlans" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListQueryShapes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheSetFilter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "profile" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "reIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "removeShard" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "renameCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resetError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokePrivilegesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "rolesInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslContinue" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "serverStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "setParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardConnPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shutdown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "split" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitVector" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "update" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "usersInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "validate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "whatsmyuri" : { + "failed" : NumberLong(0), + "total" : NumberLong(6) + } + }, + "cursor" : { + "open" : { + "multiTarget" : NumberLong(0), + "singleTarget" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "getLastError" : { + "wtime" : { + "num" : 0, + "totalMillis" : 0 + } + } + }, + "ok" : 1 +} + +# Server Parameters ######################################### + +{ + "authSchemaVersion" : 5, + "authenticationMechanisms" : [ + "MONGODB-CR", + "MONGODB-X509", + "SCRAM-SHA-1" + ], + "clusterAuthMode" : "undefined", + "connPoolMaxConnsPerHost" : 200, + "connPoolMaxShardedConnsPerHost" : 200, + "cursorTimeoutMillis" : NumberLong(600000), + "enableLocalhostAuthBypass" : true, + "enableTestCommands" : 0, + "internalGeoNearQuery2DMaxCoveringCells" : 16, + "internalGeoPredicateQuery2DMaxCoveringCells" : 16, + "internalQueryCacheEvictionRatio" : 10, + "internalQueryCacheFeedbacksStored" : 20, + "internalQueryCacheReplanningEnabled" : false, + "internalQueryCacheSize" : 5000, + "internalQueryCacheStdDeviations" : 2, + "internalQueryCacheWriteOpsBetweenFlush" : 1000, + "internalQueryEnumerationMaxIntersectPerAnd" : 3, + "internalQueryEnumerationMaxOrSolutions" : 10, + "internalQueryExecMaxBlockingSortBytes" : 33554432, + "internalQueryExecYieldIterations" : 128, + "internalQueryExecYieldPeriodMS" : 10, + "internalQueryForceIntersectionPlans" : false, + "internalQueryMaxScansToExplode" : 200, + "internalQueryPlanEvaluationCollFraction" : 0.3, + "internalQueryPlanEvaluationMaxResults" : 101, + "internalQueryPlanEvaluationWorks" : 10000, + "internalQueryPlanOrChildrenIndependently" : true, + "internalQueryPlannerEnableHashIntersection" : false, + "internalQueryPlannerEnableIndexIntersection" : true, + "internalQueryPlannerMaxIndexedSolutions" : 64, + "internalSCCAllowFastestAuthConfigReads" : false, + "internalSCCAllowFastestMetadataConfigReads" : false, + "logComponentVerbosity" : { + "verbosity" : 0, + "accessControl" : { + "verbosity" : -1 + }, + "command" : { + "verbosity" : -1 + }, + "control" : { + "verbosity" : -1 + }, + "geo" : { + "verbosity" : -1 + }, + "index" : { + "verbosity" : -1 + }, + "network" : { + "verbosity" : -1 + }, + "query" : { + "verbosity" : -1 + }, + "replication" : { + "verbosity" : -1 + }, + "sharding" : { + "verbosity" : -1 + }, + "storage" : { + "verbosity" : -1, + "journal" : { + "verbosity" : -1 + } + }, + "write" : { + "verbosity" : -1 + } + }, + "logLevel" : 0, + "logUserIds" : false, + "quiet" : false, + "replMonitorMaxFailedChecks" : 30, + "saslHostName" : "telecaster.local", + "saslServiceName" : "mongodb", + "saslauthdPath" : "", + "scramIterationCount" : 10000, + "sslMode" : "disabled", + "textSearchEnabled" : true, + "traceExceptions" : false, + "userCacheInvalidationIntervalSecs" : 30, + "ok" : 1 +} + +# Command Line Options ###################################### + +{ + "argv" : [ + "mongos", + "--port=28007", + "--logpath", + "/Users/fernandoipar/mongo-summary-tests//mongos/log", + "--fork", + "--pidfilepath", + "/Users/fernandoipar/mongo-summary-tests//mongos/pid", + "--configdb", + "telecaster.local:28004,telecaster.local:28005,telecaster.local:28006" + ], + "parsed" : { + "net" : { + "port" : 28007 + }, + "processManagement" : { + "fork" : true, + "pidFilePath" : "/Users/fernandoipar/mongo-summary-tests//mongos/pid" + }, + "sharding" : { + "configDB" : "telecaster.local:28004,telecaster.local:28005,telecaster.local:28006" + }, + "systemLog" : { + "destination" : "file", + "path" : "/Users/fernandoipar/mongo-summary-tests//mongos/log" + } + }, + "ok" : 1 +} +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28007/test + +# Extra info ################################################ + +config has 12 collections and 16777216 bytes on disk +Collections: + actionlog +Indexes for actionlog: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.actionlog" + } +] +Indexes for changelog: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.changelog" + } +] +Indexes for chunks: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "min" : 1 + }, + "name" : "ns_1_min_1", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "shard" : 1, + "min" : 1 + }, + "name" : "ns_1_shard_1_min_1", + "ns" : "config.chunks" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "lastmod" : 1 + }, + "name" : "ns_1_lastmod_1", + "ns" : "config.chunks" + } +] +Indexes for databases: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.databases" + } +] +Indexes for lockpings: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.lockpings" + }, + { + "v" : 1, + "key" : { + "ping" : 1 + }, + "name" : "ping_1", + "ns" : "config.lockpings" + } +] +Indexes for locks: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.locks" + }, + { + "v" : 1, + "key" : { + "ts" : 1 + }, + "name" : "ts_1", + "ns" : "config.locks" + }, + { + "v" : 1, + "key" : { + "state" : 1, + "process" : 1 + }, + "name" : "state_1_process_1", + "ns" : "config.locks" + } +] +Indexes for mongos: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.mongos" + } +] +Indexes for settings: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.settings" + } +] +Indexes for shards: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.shards" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "host" : 1 + }, + "name" : "host_1", + "ns" : "config.shards" + } +] +Indexes for system.indexes: +[ ] +Indexes for tags: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "config.tags" + }, + { + "v" : 1, + "unique" : true, + "key" : { + "ns" : 1, + "min" : 1 + }, + "name" : "ns_1_min_1", + "ns" : "config.tags" + } +] +2016-03-26T02:43:24.482-0300 E QUERY TypeError: Object function (){ + return this.serverBuildInfo().version; +} has no method 'getIndexes' + at mongo-summary-extra.js:31:36 + at Array.forEach (native) + at mongo-summary-extra.js:30:32 + at Array.forEach (native) + at mongo-summary-extra.js:27:22 + at Array.forEach (native) + at printExtraDiagnosticsInfo (mongo-summary-extra.js:20:51) + at mongo-summary-extra.js:59:1 at mongo-summary-extra.js:31 +failed to load: mongo-summary-extra.js diff --git a/mongo-summary/sample_output/test_standalone_mongod.result.txt b/mongo-summary/sample_output/test_standalone_mongod.result.txt new file mode 100644 index 0000000..b3d969a --- /dev/null +++ b/mongo-summary/sample_output/test_standalone_mongod.result.txt @@ -0,0 +1,1012 @@ +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28000/test + +# Percona Toolkit MongoDB Summary Report #################### + +Report generated on telecaster.local:28000 at 2016-02-06 02:43:57 GMT-0300 (ART) +0 operations in progress + +# Replication summary ####################################### + +Standalone mongod + +# Server Status ############################################# + +{ + "host" : "telecaster.local:28000", + "version" : "3.0.4", + "process" : "mongod", + "pid" : NumberLong(23024), + "uptime" : 5, + "uptimeMillis" : NumberLong(5103), + "uptimeEstimate" : 4, + "localTime" : ISODate("2016-03-26T05:43:57.882Z"), + "asserts" : { + "regular" : 0, + "warning" : 0, + "msg" : 0, + "user" : 0, + "rollovers" : 0 + }, + "backgroundFlushing" : { + "flushes" : 0, + "total_ms" : 0, + "average_ms" : 0, + "last_ms" : 0, + "last_finished" : ISODate("1970-01-01T00:00:00Z") + }, + "connections" : { + "current" : 1, + "available" : 2047, + "totalCreated" : NumberLong(1) + }, + "cursors" : { + "note" : "deprecated, use server status metrics", + "clientCursors_size" : 0, + "totalOpen" : 0, + "pinned" : 0, + "totalNoTimeout" : 0, + "timedOut" : 0 + }, + "dur" : { + "commits" : 28, + "journaledMB" : 0.024576, + "writeToDataFilesMB" : 0.021399, + "compression" : 1.1306067994663478, + "commitsInWriteLock" : 0, + "earlyCommits" : 0, + "timeMs" : { + "dt" : 3002, + "prepLogBuffer" : 0, + "writeToJournal" : 0, + "writeToDataFiles" : 0, + "remapPrivateView" : 0, + "commits" : 2, + "commitsInWriteLock" : 0 + } + }, + "extra_info" : { + "note" : "fields vary by platform", + "page_faults" : 10 + }, + "globalLock" : { + "totalTime" : NumberLong(5102000), + "currentQueue" : { + "total" : 0, + "readers" : 0, + "writers" : 0 + }, + "activeClients" : { + "total" : 9, + "readers" : 0, + "writers" : 0 + } + }, + "locks" : { + "Global" : { + "acquireCount" : { + "r" : NumberLong(21), + "w" : NumberLong(2), + "W" : NumberLong(5) + } + }, + "MMAPV1Journal" : { + "acquireCount" : { + "r" : NumberLong(5), + "w" : NumberLong(10), + "R" : NumberLong(46) + }, + "acquireWaitCount" : { + "w" : NumberLong(1), + "R" : NumberLong(1) + }, + "timeAcquiringMicros" : { + "w" : NumberLong(38), + "R" : NumberLong(1298) + } + }, + "Database" : { + "acquireCount" : { + "r" : NumberLong(7), + "W" : NumberLong(2) + } + }, + "Collection" : { + "acquireCount" : { + "R" : NumberLong(7) + } + }, + "Metadata" : { + "acquireCount" : { + "W" : NumberLong(4) + } + } + }, + "network" : { + "bytesIn" : 238, + "bytesOut" : 2010, + "numRequests" : 4 + }, + "opcounters" : { + "insert" : 0, + "query" : 1, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 4 + }, + "opcountersRepl" : { + "insert" : 0, + "query" : 0, + "update" : 0, + "delete" : 0, + "getmore" : 0, + "command" : 0 + }, + "storageEngine" : { + "name" : "mmapv1" + }, + "writeBacksQueued" : false, + "mem" : { + "bits" : 64, + "resident" : 45, + "virtual" : 2654, + "supported" : true, + "mapped" : 80, + "mappedWithJournal" : 160 + }, + "metrics" : { + "commands" : { + "" : NumberLong(0), + "_getUserCacheGeneration" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_isSelf" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_mergeAuthzCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_migrateClone" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkAbort" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkCommit" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_recvChunkStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "_transferMods" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "aggregate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "appendOplogNote" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "applyOps" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authSchemaUpgrade" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "authenticate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "availableQueryOptions" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "buildInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "checkShardingIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cleanupOrphaned" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "clone" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cloneCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cloneCollectionAsCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collMod" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "collStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "compact" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connPoolSync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "connectionStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "convertToCapped" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydb" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydbgetnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "copydbsaslstart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "count" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "create" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "createUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "currentOpCtx" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "cursorInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dataSize" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbHash" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dbStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "delete" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "diagLogging" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "distinct" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "driverOIDTest" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "drop" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllRolesFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropAllUsersFromDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "dropUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "eval" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "explain" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "features" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "filemd5" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "find" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "findAndModify" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "forceerror" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "fsync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoNear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "geoSearch" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getCmdLineOpts" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLastError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getLog" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getPrevError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardMap" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "getnonce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantPrivilegesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "grantRolesToUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "group" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "handshake" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "hostInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(2) + }, + "insert" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "invalidateUserCache" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "isMaster" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCollections" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listCommands" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listDatabases" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "listIndexes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logRotate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "logout" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapReduce" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mapreduce" : { + "shardedfinish" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "medianKey" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "mergeChunks" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "moveChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "parallelCollectionScan" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "ping" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClear" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheClearFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListFilters" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListPlans" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheListQueryShapes" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "planCacheSetFilter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "profile" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "reIndex" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "renameCollection" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairCursor" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "repairDatabase" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetElect" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetFreeze" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetFresh" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetConfig" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetRBID" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetGetStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetHeartbeat" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetInitiate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetMaintenance" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetReconfig" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetStepDown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetSyncFrom" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "replSetUpdatePosition" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resetError" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "resync" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokePrivilegesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "revokeRolesFromUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "rolesInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslContinue" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "saslStart" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "serverStatus" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "setParameter" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "setShardVersion" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardConnPoolStats" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shardingState" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "shutdown" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitChunk" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "splitVector" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "top" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "touch" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "unsetSharding" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "update" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateRole" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "updateUser" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "usersInfo" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "validate" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + }, + "whatsmyuri" : { + "failed" : NumberLong(0), + "total" : NumberLong(1) + }, + "writebacklisten" : { + "failed" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "cursor" : { + "timedOut" : NumberLong(0), + "open" : { + "noTimeout" : NumberLong(0), + "pinned" : NumberLong(0), + "total" : NumberLong(0) + } + }, + "document" : { + "deleted" : NumberLong(0), + "inserted" : NumberLong(0), + "returned" : NumberLong(0), + "updated" : NumberLong(0) + }, + "getLastError" : { + "wtime" : { + "num" : 0, + "totalMillis" : 0 + }, + "wtimeouts" : NumberLong(0) + }, + "operation" : { + "fastmod" : NumberLong(0), + "idhack" : NumberLong(0), + "scanAndOrder" : NumberLong(0), + "writeConflicts" : NumberLong(0) + }, + "queryExecutor" : { + "scanned" : NumberLong(0), + "scannedObjects" : NumberLong(0) + }, + "record" : { + "moves" : NumberLong(0) + }, + "repl" : { + "apply" : { + "batches" : { + "num" : 0, + "totalMillis" : 0 + }, + "ops" : NumberLong(0) + }, + "buffer" : { + "count" : NumberLong(0), + "maxSizeBytes" : 268435456, + "sizeBytes" : NumberLong(0) + }, + "network" : { + "bytes" : NumberLong(0), + "getmores" : { + "num" : 0, + "totalMillis" : 0 + }, + "ops" : NumberLong(0), + "readersCreated" : NumberLong(0) + }, + "preload" : { + "docs" : { + "num" : 0, + "totalMillis" : 0 + }, + "indexes" : { + "num" : 0, + "totalMillis" : 0 + } + } + }, + "storage" : { + "freelist" : { + "search" : { + "bucketExhausted" : NumberLong(0), + "requests" : NumberLong(8), + "scanned" : NumberLong(0) + } + } + }, + "ttl" : { + "deletedDocuments" : NumberLong(0), + "passes" : NumberLong(0) + } + }, + "ok" : 1 +} + +# Server Parameters ######################################### + +{ + "authSchemaVersion" : 5, + "authenticationMechanisms" : [ + "MONGODB-CR", + "MONGODB-X509", + "SCRAM-SHA-1" + ], + "clusterAuthMode" : "undefined", + "connPoolMaxConnsPerHost" : 200, + "connPoolMaxShardedConnsPerHost" : 200, + "cursorTimeoutMillis" : 600000, + "enableCollectionLocking" : true, + "enableLocalhostAuthBypass" : true, + "enableTestCommands" : 0, + "failIndexKeyTooLong" : true, + "internalGeoNearQuery2DMaxCoveringCells" : 16, + "internalGeoPredicateQuery2DMaxCoveringCells" : 16, + "internalQueryCacheEvictionRatio" : 10, + "internalQueryCacheFeedbacksStored" : 20, + "internalQueryCacheReplanningEnabled" : false, + "internalQueryCacheSize" : 5000, + "internalQueryCacheStdDeviations" : 2, + "internalQueryCacheWriteOpsBetweenFlush" : 1000, + "internalQueryEnumerationMaxIntersectPerAnd" : 3, + "internalQueryEnumerationMaxOrSolutions" : 10, + "internalQueryExecMaxBlockingSortBytes" : 33554432, + "internalQueryExecYieldIterations" : 128, + "internalQueryExecYieldPeriodMS" : 10, + "internalQueryForceIntersectionPlans" : false, + "internalQueryMaxScansToExplode" : 200, + "internalQueryPlanEvaluationCollFraction" : 0.3, + "internalQueryPlanEvaluationMaxResults" : 101, + "internalQueryPlanEvaluationWorks" : 10000, + "internalQueryPlanOrChildrenIndependently" : true, + "internalQueryPlannerEnableHashIntersection" : false, + "internalQueryPlannerEnableIndexIntersection" : true, + "internalQueryPlannerMaxIndexedSolutions" : 64, + "internalSCCAllowFastestAuthConfigReads" : false, + "internalSCCAllowFastestMetadataConfigReads" : false, + "journalCommitInterval" : 0, + "logComponentVerbosity" : { + "verbosity" : 0, + "accessControl" : { + "verbosity" : -1 + }, + "command" : { + "verbosity" : -1 + }, + "control" : { + "verbosity" : -1 + }, + "geo" : { + "verbosity" : -1 + }, + "index" : { + "verbosity" : -1 + }, + "network" : { + "verbosity" : -1 + }, + "query" : { + "verbosity" : -1 + }, + "replication" : { + "verbosity" : -1 + }, + "sharding" : { + "verbosity" : -1 + }, + "storage" : { + "verbosity" : -1, + "journal" : { + "verbosity" : -1 + } + }, + "write" : { + "verbosity" : -1 + } + }, + "logLevel" : 0, + "logUserIds" : false, + "maxSyncSourceLagSecs" : 30, + "newCollectionsUsePowerOf2Sizes" : true, + "notablescan" : false, + "queueForMigrationCommit" : true, + "quiet" : false, + "replApplyBatchSize" : 1, + "replIndexPrefetch" : "uninitialized", + "replMonitorMaxFailedChecks" : 30, + "saslHostName" : "telecaster.local", + "saslServiceName" : "mongodb", + "saslauthdPath" : "", + "scramIterationCount" : 10000, + "skipCorruptDocumentsWhenCloning" : false, + "sslMode" : "disabled", + "syncdelay" : 60, + "textSearchEnabled" : true, + "traceExceptions" : false, + "traceWriteConflictExceptions" : false, + "ttlMonitorEnabled" : true, + "ttlMonitorSleepSecs" : 60, + "wiredTigerConcurrentReadTransactions" : 128, + "wiredTigerConcurrentWriteTransactions" : 128, + "ok" : 1 +} + +# Command Line Options ###################################### + +{ + "argv" : [ + "mongod", + "--dbpath", + "/Users/fernandoipar/mongo-summary-tests//standalone", + "--port=28000", + "--logpath", + "/Users/fernandoipar/mongo-summary-tests//standalone/log", + "--fork", + "--pidfilepath", + "/Users/fernandoipar/mongo-summary-tests//standalone/pid" + ], + "parsed" : { + "net" : { + "port" : 28000 + }, + "processManagement" : { + "fork" : true, + "pidFilePath" : "/Users/fernandoipar/mongo-summary-tests//standalone/pid" + }, + "storage" : { + "dbPath" : "/Users/fernandoipar/mongo-summary-tests//standalone" + }, + "systemLog" : { + "destination" : "file", + "path" : "/Users/fernandoipar/mongo-summary-tests//standalone/log" + } + }, + "ok" : 1 +} +MongoDB shell version: 3.0.4 +connecting to: 127.0.0.1:28000/test + +# Extra info ################################################ + +local has 2 collections and 83886080 bytes on disk +Collections: + startup_log +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] + system.indexes +Indexes for startup_log: +[ + { + "v" : 1, + "key" : { + "_id" : 1 + }, + "name" : "_id_", + "ns" : "local.startup_log" + } +] +Indexes for system.indexes: +[ ] +{ "ok" : 0, "errmsg" : "not running with --replSet", "code" : 76 } + +# Logs ###################################################### + +2016-03-26T02:43:52.809-0300 I JOURNAL [initandlisten] journal dir=/Users/fernandoipar/mongo-summary-tests//standalone/journal +2016-03-26T02:43:52.809-0300 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed +2016-03-26T02:43:52.826-0300 I JOURNAL [durability] Durability thread started +2016-03-26T02:43:52.826-0300 I CONTROL [initandlisten] MongoDB starting : pid=23024 port=28000 dbpath=/Users/fernandoipar/mongo-summary-tests//standalone 64-bit host=telecaster.local +2016-03-26T02:43:52.826-0300 I JOURNAL [journal writer] Journal writer thread started +2016-03-26T02:43:52.827-0300 I CONTROL [initandlisten] db version v3.0.4 +2016-03-26T02:43:52.827-0300 I CONTROL [initandlisten] git version: nogitversion +2016-03-26T02:43:52.827-0300 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49 +2016-03-26T02:43:52.827-0300 I CONTROL [initandlisten] allocator: system +2016-03-26T02:43:52.827-0300 I CONTROL [initandlisten] options: { net: { port: 28000 }, processManagement: { fork: true, pidFilePath: "/Users/fernandoipar/mongo-summary-tests//standalone/pid" }, storage: { dbPath: "/Users/fernandoipar/mongo-summary-tests//standalone" }, systemLog: { destination: "file", path: "/Users/fernandoipar/mongo-summary-tests//standalone/log" } } +2016-03-26T02:43:52.828-0300 I INDEX [initandlisten] allocating new ns file /Users/fernandoipar/mongo-summary-tests//standalone/local.ns, filling with zeroes... +2016-03-26T02:43:52.859-0300 I STORAGE [FileAllocator] allocating new datafile /Users/fernandoipar/mongo-summary-tests//standalone/local.0, filling with zeroes... +2016-03-26T02:43:52.860-0300 I STORAGE [FileAllocator] creating directory /Users/fernandoipar/mongo-summary-tests//standalone/_tmp +2016-03-26T02:43:52.959-0300 I STORAGE [FileAllocator] done allocating datafile /Users/fernandoipar/mongo-summary-tests//standalone/local.0, size: 64MB, took 0.098 secs +2016-03-26T02:43:53.091-0300 I NETWORK [initandlisten] waiting for connections on port 28000 +2016-03-26T02:43:57.879-0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55364 #1 (1 connection now open) +2016-03-26T02:43:57.896-0300 I NETWORK [conn1] end connection 127.0.0.1:55364 (0 connections now open) +2016-03-26T02:43:57.935-0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55365 #2 (1 connection now open) diff --git a/slowlog-generator/pcap/bin/darwin/slowlog-from-pcap b/slowlog-generator/pcap/bin/darwin/slowlog-from-pcap index 68a95b4..584900a 100755 Binary files a/slowlog-generator/pcap/bin/darwin/slowlog-from-pcap and b/slowlog-generator/pcap/bin/darwin/slowlog-from-pcap differ diff --git a/slowlog-generator/pcap/bin/linux64/slowlog-from-pcap b/slowlog-generator/pcap/bin/linux64/slowlog-from-pcap index 640b472..4806643 100755 Binary files a/slowlog-generator/pcap/bin/linux64/slowlog-from-pcap and b/slowlog-generator/pcap/bin/linux64/slowlog-from-pcap differ diff --git a/slowlog-generator/pcap/slowlog-from-pcap.go b/slowlog-generator/pcap/slowlog-from-pcap.go index 8843e4f..7adde45 100644 --- a/slowlog-generator/pcap/slowlog-from-pcap.go +++ b/slowlog-generator/pcap/slowlog-from-pcap.go @@ -25,12 +25,27 @@ import ( "gopkg.in/mgo.v2/bson" ) -var iface = flag.String("i", "eth0", "Interface to read packets from") -var fname = flag.String("r", "", "Filename to read from, overrides -i") -var snaplen = flag.Int("s", 65536, "Snap length (number of bytes max to read per packet") -var tstype = flag.String("timestamp_type", "", "Type of timestamps to use") -var promisc = flag.Bool("promisc", true, "Set promiscuous mode") -var verbose = 1 +const idxMessageLength = 0 +const idxRequestId = 4 +const idxResponseTo = 8 +const idxOpCode = 12 + +//const idxFlags = 16 +const idxStartingFrom = 28 + +var iface = "eth0" +var fname = "" +var snaplen = 65536 +var tstype = "" +var verbose = false + +func init() { + flag.StringVar(&iface, "i", "eth0", "Interface to read packets from") + flag.BoolVar(&verbose, "v", false, "Enable verbose mode") + flag.StringVar(&fname, "r", "", "Filename to read from, overrides -i") + flag.IntVar(&snaplen, "s", 65536, "Number of bytes max to read per packet") + flag.StringVar(&tstype, "t", "", "Type of timestamp to use") +} // next code all copied from facebookgo/dvara @@ -165,7 +180,7 @@ func processUpdatePayload(data []byte, header messageHeader) (output string) { bdoc := mybson[:docEndsAt] json := make(map[string]interface{}) bson.Unmarshal(bdoc, json) - if verbose > 2 { + if verbose { fmt.Print("Unmarshalled selector json: ") fmt.Println(json) } @@ -173,7 +188,7 @@ func processUpdatePayload(data []byte, header messageHeader) (output string) { aux_output, _, _ := myutil.RecurseJsonMap(json) output += aux_output output += "},{" - if verbose > 2 { + if verbose { fmt.Print("Selector: ") fmt.Print("mybson bytes: ") fmt.Println(mybson) @@ -187,7 +202,7 @@ func processUpdatePayload(data []byte, header messageHeader) (output string) { bdoc = mybson[:docEndsAt] json = make(map[string]interface{}) bson.Unmarshal(bdoc, json) - if verbose > 2 { + if verbose { fmt.Print("Unmarshalled updater json: ") fmt.Println(json) } @@ -211,7 +226,7 @@ func processInsertPayload(data []byte, header messageHeader) (output string) { bdoc := mybson[:docEndsAt] json := make(map[string]interface{}) bson.Unmarshal(bdoc, json) - if verbose > 2 { + if verbose { fmt.Print("Unmarshalled selector json: ") fmt.Println(json) } @@ -223,7 +238,7 @@ func processInsertPayload(data []byte, header messageHeader) (output string) { } func processGetMorePayload(data []byte, header messageHeader) (output string) { - // if verbose > 2 { + // if verbose { // fmt.Println("Processing GetMore payload") // } sub := data[20:] @@ -235,7 +250,7 @@ func processGetMorePayload(data []byte, header messageHeader) (output string) { } collectionName := sub[0:docStartsAt] output = fmt.Sprintf("%v.getMore();\n", string(collectionName[:])) - //if verbose > 2 { + //if verbose { //fmt.Println(output) //} return output @@ -251,7 +266,7 @@ func processQueryPayload(data []byte, header messageHeader) (output string) { } collectionName := sub[0:docStartsAt] docStartsAt++ - if verbose > 2 { + if verbose { fmt.Print("Raw data: ") fmt.Println(data) fmt.Printf("Querying collection %v\n", string(collectionName[:])) @@ -266,7 +281,7 @@ func processQueryPayload(data []byte, header messageHeader) (output string) { bdoc := mybson[:docEndsAt] json := make(map[string]interface{}) bson.Unmarshal(bdoc, json) - if verbose > 2 { + if verbose { fmt.Print("Unmarshalled json: ") fmt.Println(json) } @@ -277,7 +292,7 @@ func processQueryPayload(data []byte, header messageHeader) (output string) { output += aux_output output += "});\n" } - if verbose > 2 { + if verbose { fmt.Print("mybson bytes: ") fmt.Println(mybson) fmt.Print("Document bytes:") @@ -302,10 +317,12 @@ func dump(src gopacket.PacketDataSource) { var dec gopacket.Decoder var ok bool if dec, ok = gopacket.DecodersByLayerName["Ethernet"]; !ok { - log.Fatalln("No decoder named", "Ethernet") + if dec, ok = gopacket.DecodersByLayerName["Loopback"]; !ok { + log.Fatalln("No decoder named", "Ethernet or Loopback") + } } source := gopacket.NewPacketSource(src, dec) - //source.Lazy = *lazy + source.Lazy = true source.NoCopy = true for packet := range source.Packets() { //fmt.Println(packet.ApplicationLayer().Payload()) @@ -337,48 +354,61 @@ func dump(src gopacket.PacketDataSource) { // This code is unsafe. It performs no check and will fail miserably if the packet is // not a mongo packet. Pass the proper 'port N' filter to pcap when invoking the program var header messageHeader - header.MessageLength = getInt32(payload, 0) - header.RequestID = getInt32(payload, 4) - header.ResponseTo = getInt32(payload, 8) - header.OpCode = OpCode(getInt32(payload, 12)) + header.MessageLength = getInt32(payload, idxMessageLength) + header.RequestID = getInt32(payload, idxRequestId) + header.ResponseTo = getInt32(payload, idxResponseTo) + header.OpCode = OpCode(getInt32(payload, idxOpCode)) + //responseFlags := getInt32(payload, idxFlags) + startingFrom := getInt32(payload, idxStartingFrom) + startTimes[header.RequestID] = time.Now() - if verbose > 2 { + if verbose { fmt.Println("OpCode: ", header.OpCode) fmt.Println("Captured packet") - fmt.Printf("Captured packet (OpCode: %v)\n", header.OpCode) + fmt.Printf("Captured packet (OpCode: %v, cursorStartingFrom: %v)\n", header.OpCode, startingFrom) } switch header.OpCode { case OpQuery: queries[header.RequestID] = processQueryPayload(payload, header) - if verbose > 2 { - fmt.Printf("Saved Query for %v", header.RequestID) + if verbose { + fmt.Printf("Saved Query for %v(%v)\n", header.RequestID, queries[header.RequestID]) } case OpGetMore: queries[header.RequestID] = processGetMorePayload(payload, header) - if verbose > 2 { + if verbose { fmt.Printf("Saved GetMore for %v", header.RequestID) } case OpReply: - elapsed := processReplyPayload(payload, header) - opInfo := make(myutil.OpInfo) - opInfo["millis"] = fmt.Sprintf("%f", elapsed) - opInfo["sent"] = fmt.Sprintf("%v", len(payload)) - fmt.Print(myutil.GetSlowQueryLogHeader(opInfo)) - query, ok := queries[header.ResponseTo] - if ok { - fmt.Print(query) - delete(queries, header.ResponseTo) - } else { - if verbose > 1 { - fmt.Printf(" Orphaned reply for %v\n", header.ResponseTo) + if startingFrom == 0 { + elapsed := processReplyPayload(payload, header) + opInfo := make(myutil.OpInfo) + opInfo["millis"] = fmt.Sprintf("%f", elapsed) + opInfo["sent"] = fmt.Sprintf("%v", len(payload)) + query, ok := queries[header.ResponseTo] + if ok { + fmt.Print(myutil.GetSlowQueryLogHeader(opInfo)) + fmt.Print(query) + delete(queries, header.ResponseTo) + } else { + if verbose { + //json := make(map[string]interface{}) + //var mbson []bson.M + //bson.Unmarshal(al.Payload(), json) + //aux_output, _, _ := myutil.RecurseJsonMap(json) + fmt.Printf(" Orphaned reply for %v\n", header.ResponseTo) + //fmt.Printf(" byte array to string: %v", string(payload[:])) + //fmt.Printf(" recurse json for byte array: %v", aux_output) + } } + } else if verbose { + fmt.Printf(" Not printing reply to GetMore for existing cursor") } case OpUpdate: queries[header.RequestID] = processUpdatePayload(payload, header) case OpInsert: queries[header.RequestID] = processInsertPayload(payload, header) default: - if verbose > 1 { + if verbose { fmt.Println("Unimplemented Opcode ", header.OpCode) } } @@ -395,28 +425,31 @@ func main() { var handle *pcap.Handle var err error flag.Parse() - if *fname != "" { - if handle, err = pcap.OpenOffline(*fname); err != nil { + if verbose { + fmt.Println("Running in verbose mode") + } + if fname != "" { + if handle, err = pcap.OpenOffline(fname); err != nil { log.Fatal("PCAP OpenOffline error:", err) } } else { // This is a little complicated because we want to allow all possible options // for creating the packet capture handle... instead of all this you can // just call pcap.OpenLive if you want a simple handle. - inactive, err := pcap.NewInactiveHandle(*iface) + inactive, err := pcap.NewInactiveHandle(iface) if err != nil { log.Fatal("could not create: %v", err) } defer inactive.CleanUp() - if err = inactive.SetSnapLen(*snaplen); err != nil { + if err = inactive.SetSnapLen(snaplen); err != nil { log.Fatal("could not set snap length: %v", err) - } else if err = inactive.SetPromisc(*promisc); err != nil { + } else if err = inactive.SetPromisc(true); err != nil { log.Fatal("could not set promisc mode: %v", err) } else if err = inactive.SetTimeout(time.Second); err != nil { log.Fatal("could not set timeout: %v", err) } - if *tstype != "" { - if t, err := pcap.TimestampSourceFromString(*tstype); err != nil { + if tstype != "" { + if t, err := pcap.TimestampSourceFromString(tstype); err != nil { log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) } else if err := inactive.SetTimestampSource(t); err != nil { log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) diff --git a/slowlog-generator/profile/bin/darwin/slowlog-from-profile b/slowlog-generator/profile/bin/darwin/slowlog-from-profile index 34620b2..568423b 100755 Binary files a/slowlog-generator/profile/bin/darwin/slowlog-from-profile and b/slowlog-generator/profile/bin/darwin/slowlog-from-profile differ diff --git a/slowlog-generator/profile/bin/linux64/slowlog-from-profile b/slowlog-generator/profile/bin/linux64/slowlog-from-profile index 45758f6..d337abe 100755 Binary files a/slowlog-generator/profile/bin/linux64/slowlog-from-profile and b/slowlog-generator/profile/bin/linux64/slowlog-from-profile differ diff --git a/slowlog-generator/response-time/Makefile b/slowlog-generator/response-time/Makefile new file mode 100644 index 0000000..434dbe2 --- /dev/null +++ b/slowlog-generator/response-time/Makefile @@ -0,0 +1,8 @@ + + +build: + go build *go + +clean: + go clean + diff --git a/slowlog-generator/response-time/mongo-response-time-dashboard.json b/slowlog-generator/response-time/mongo-response-time-dashboard.json new file mode 100644 index 0000000..a1c5579 --- /dev/null +++ b/slowlog-generator/response-time/mongo-response-time-dashboard.json @@ -0,0 +1,651 @@ +{ + "id": 1, + "title": "MongoDB", + "originalTitle": "MongoDB", + "tags": [], + "style": "dark", + "timezone": "browser", + "editable": true, + "hideControls": false, + "sharedCrosshair": false, + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 1, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "mongodb_memory", + "interval": "1s", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_memory", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Memory", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "Row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 2, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_metrics_document_total{state=\"inserted\"}[5s])", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_metrics_document_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Inserted Documents (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 3, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_metrics_document_total{state=\"deleted\"}[5s])", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_metrics_document_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Deleted Documents (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 4, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_metrics_document_total{state=\"updated\"}[5s])", + "intervalFactor": 2, + "metric": "mongodb_metrics_document_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Updated Documents (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 5, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_metrics_document_total{state=\"returned\"}[5s])", + "intervalFactor": 2, + "metric": "mongodb_metrics_document_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Returned Documents (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 6, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_network_bytes_total[5s])", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_network_bytes_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Network Bytes in/out (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 7, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "delta(mongodb_op_counters_total[5s])", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_op_counters_total", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Operations (/5s)", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + }, + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": null, + "editable": true, + "error": false, + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 8, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "histogram_quantile(0.99,mongodb_response_time_bucket)", + "intervalFactor": 2, + "legendFormat": "", + "metric": "mongodb_response_time_bucket", + "refId": "A", + "step": 2 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "MongoDB Response Time .99 Quantile", + "tooltip": { + "shared": true, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "y-axis": true, + "y_formats": [ + "short", + "short" + ] + } + ], + "title": "New row" + } + ], + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "now": true, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "templating": { + "list": [] + }, + "annotations": { + "list": [] + }, + "schemaVersion": 8, + "version": 11, + "links": [] +} diff --git a/slowlog-generator/response-time/mongo-response-time-exporter.darwin64.bin b/slowlog-generator/response-time/mongo-response-time-exporter.darwin64.bin new file mode 100755 index 0000000..e07aa4f Binary files /dev/null and b/slowlog-generator/response-time/mongo-response-time-exporter.darwin64.bin differ diff --git a/slowlog-generator/response-time/mongo-response-time-exporter.go b/slowlog-generator/response-time/mongo-response-time-exporter.go new file mode 100644 index 0000000..2f007a2 --- /dev/null +++ b/slowlog-generator/response-time/mongo-response-time-exporter.go @@ -0,0 +1,303 @@ +/* +This program uses libpcap to capture MongoDB/TokuMX network traffic and calculate request response time. + +*/ +package main + +import ( + "flag" + "fmt" + "log" + "net/http" + "os" + "os/signal" + "runtime" + "strconv" + "strings" + "syscall" + "time" + + "github.com/google/gopacket" + "github.com/google/gopacket/examples/util" + "github.com/google/gopacket/pcap" + "github.com/prometheus/client_golang/prometheus" +) + +var iface = "eth0" +var fname = "" +var snaplen = 65536 +var tstype = "" +var port = 9119 +var verbose = false + +func init() { + flag.StringVar(&iface, "i", "eth0", "Interface to read packets from") + flag.StringVar(&fname, "r", "", "Filename to read from, overrides -i") + flag.IntVar(&snaplen, "s", 65536, "Number of max bytes to read per packet") + flag.StringVar(&tstype, "t", "", "Type of timestamp to use") + flag.IntVar(&port, "P", 9119, "The port number to listen on ") + flag.BoolVar(&verbose, "v", false, "Enable verbose mode") +} + +// the currently max seen response time value +var max = 0.0 + +// prometheus histogram (https://godoc.org/github.com/prometheus/client_golang/prometheus#Histogram) +var rtHistogram = prometheus.NewHistogram(prometheus.HistogramOpts{ + Name: "mongodb_histogram_response_time", + Help: "Response time for MongoDB operations", + Buckets: prometheus.ExponentialBuckets(0.00000001, 2, 10), +}) + +// prometheus summary (https://godoc.org/github.com/prometheus/client_golang/prometheus#Summary) +var rtSummary = prometheus.NewSummary(prometheus.SummaryOpts{ + Name: "mongodb_summary_response_time", + Help: "Response time for MongoDB operations", +}) + +// prometheus gauge (https://godoc.org/github.com/prometheus/client_golang/prometheus#Gauge) +var rtMax = prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: "ognom", + Name: "mongodb_max_response_time", + Help: "Max response time seen for MongoDB operations in the last 10 seconds", +}) + +// channel to receive SIGHUP +var sigs = make(chan os.Signal, 1) + +// flag to indicate if we've received a SIGHUP signal in the last 30 seconds +var sighupped = false + +// next code all copied from facebookgo/dvara + +// OpCode allows identifying the type of operation: +// +// http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes +type OpCode int32 + +// all data in the MongoDB wire protocol is little-endian. +// all the read/write functions below are little-endian. +func getInt32(b []byte, pos int) int32 { + return (int32(b[pos+0])) | + (int32(b[pos+1]) << 8) | + (int32(b[pos+2]) << 16) | + (int32(b[pos+3]) << 24) +} + +func setInt32(b []byte, pos int, i int32) { + b[pos] = byte(i) + b[pos+1] = byte(i >> 8) + b[pos+2] = byte(i >> 16) + b[pos+3] = byte(i >> 24) +} + +// The full set of known request op codes: +// http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes +const ( + OpReply = OpCode(1) + OpMessage = OpCode(1000) + OpUpdate = OpCode(2001) + OpInsert = OpCode(2002) + Reserved = OpCode(2003) + OpQuery = OpCode(2004) + OpGetMore = OpCode(2005) + OpDelete = OpCode(2006) + OpKillCursors = OpCode(2007) +) + +type messageHeader struct { + // MessageLength is the total message size, including this header + MessageLength int32 + // RequestID is the identifier for this miessage + RequestID int32 + // ResponseTo is the RequestID of the message being responded to. used in DB responses + ResponseTo int32 + // OpCode is the request type, see consts above. + OpCode OpCode +} + +// FromWire reads the wirebytes into this object +func (m *messageHeader) FromWire(b []byte) { + m.MessageLength = getInt32(b, 0) + m.RequestID = getInt32(b, 4) + m.ResponseTo = getInt32(b, 8) + m.OpCode = OpCode(getInt32(b, 12)) +} + +// this map will store the start time for all requests. K:RequestId, v:StartTime +var startTimes = make(map[int32]time.Time) + +// this map will store debugging counters +var debugInfo = make(map[string]int64) + +// my functions now + +func processReplyPayload(data []byte, header messageHeader) (output float64) { + var elapsed float64 = 0 + start, ok := startTimes[header.ResponseTo] + if ok { + elapsed = time.Since(start).Seconds() + delete(startTimes, header.ResponseTo) + if verbose { + deleted, dok := debugInfo["deleted"] + if dok { + debugInfo["deleted"] = deleted + 1 + } else { + debugInfo["deleted"] = 1 + } + } + } else if verbose { + notdeleted, nok := debugInfo["notdeleted"] + if nok { + debugInfo["notdeleted"] = notdeleted + 1 + } else { + debugInfo["notdeleted"] = 1 + } + } + return elapsed +} + +func startWebServer() { + handler := prometheus.Handler() + prometheus.MustRegister(rtHistogram) + prometheus.MustRegister(rtSummary) + prometheus.MustRegister(rtMax) + strport := strconv.Itoa(port) + fmt.Println("Starting HTTP server on port " + strport) + http.Handle("/metrics", handler) + http.ListenAndServe(":"+strport, nil) +} + +func sighandler() { + for { + <-sigs + sighupped = true + startTimes = make(map[int32]time.Time) + time.Sleep(30 * time.Second) + sighupped = false + } +} + +func printDebugInfo() { + if verbose { + for { + fmt.Printf("goroutine count: %d, startTimes size: %d, additions/deletes to/from startTimes: %d/%d. Not deleted due to not ok: %d\n", runtime.NumGoroutine(), len(startTimes), debugInfo["added"], debugInfo["deleted"], debugInfo["notdeleted"]) + time.Sleep(30 * time.Second) + } + } +} + +func process(src gopacket.PacketDataSource) { + var dec gopacket.Decoder + var ok bool + if dec, ok = gopacket.DecodersByLayerName["Ethernet"]; !ok { + if dec, ok = gopacket.DecodersByLayerName["Loopback"]; !ok { + log.Fatalln("No decoder named", "Ethernet or Loopback") + } + } + source := gopacket.NewPacketSource(src, dec) + //source.Lazy = *lazy + source.NoCopy = true + lastMaxPeriodStart := time.Now() + for packet := range source.Packets() { + al := packet.ApplicationLayer() + if al != nil { + payload := al.Payload() + if len(payload) < 16 { + continue + } + //fmt.Println("len(payload) == %d", len(payload)) + // IMPORTANT + // This code is unsafe. It performs no check and will fail miserably if the packet is + // not a mongo packet. Pass the proper 'port N' filter to pcap when invoking the program + var header messageHeader + //fmt.Println(payload) + header.MessageLength = getInt32(payload, 0) + header.RequestID = getInt32(payload, 4) + header.ResponseTo = getInt32(payload, 8) + header.OpCode = OpCode(getInt32(payload, 12)) + //startTimes[header.RequestID] = time.Now() + //fmt.Printf("OpCode == %v\n", header.OpCode) + switch header.OpCode { + case OpReply: + //fmt.Println("reply") + r := processReplyPayload(payload, header) + rtHistogram.Observe(r) + rtSummary.Observe(r) + if !sighupped && (r > max || time.Since(lastMaxPeriodStart).Seconds() >= 5) { + max = r + lastMaxPeriodStart = time.Now() + } else if sighupped { + max = -0.0005 + } + rtMax.Set(max) + //fmt.Printf("%s,%20.10f\n", time.Now().Format("15:04:05"), rt) + default: + startTimes[header.RequestID] = time.Now() + if verbose { + added, aok := debugInfo["added"] + if aok { + debugInfo["added"] = added + 1 + } else { + debugInfo["added"] = 1 + } + } + } + } + } +} + +// this main() is heavily inspired by / is a frankensteined version of https://github.com/google/gopacket/blob/master/examples/pcapdump/main.go + +func main() { + defer util.Run()() + var handle *pcap.Handle + var err error + signal.Notify(sigs, syscall.SIGHUP) + go startWebServer() + go sighandler() + flag.Parse() + go printDebugInfo() + if fname != "" { + if handle, err = pcap.OpenOffline(fname); err != nil { + log.Fatal("PCAP OpenOffline error:", err) + } + } else { + // This is a little complicated because we want to allow all possible options + // for creating the packet capture handle... instead of all this you can + // just call pcap.OpenLive if you want a simple handle. + inactive, err := pcap.NewInactiveHandle(iface) + if err != nil { + log.Fatal("could not create: %v", err) + } + defer inactive.CleanUp() + if err = inactive.SetSnapLen(snaplen); err != nil { + log.Fatal("could not set snap length: %v", err) + } else if err = inactive.SetPromisc(true); err != nil { + log.Fatal("could not set promisc mode: %v", err) + } else if err = inactive.SetTimeout(time.Second); err != nil { + log.Fatal("could not set timeout: %v", err) + } + if tstype != "" { + if t, err := pcap.TimestampSourceFromString(tstype); err != nil { + log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) + } else if err := inactive.SetTimestampSource(t); err != nil { + log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) + } + } + if handle, err = inactive.Activate(); err != nil { + log.Fatal("PCAP Activate error:", err) + } + defer handle.Close() + if len(flag.Args()) > 0 { + bpffilter := strings.Join(flag.Args(), " ") + fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter) + if err = handle.SetBPFFilter(bpffilter); err != nil { + log.Fatal("BPF filter error:", err) + } + } + } + for { + process(handle) + } +} diff --git a/slowlog-generator/response-time/mongo-response-time-exporter.linux64.bin b/slowlog-generator/response-time/mongo-response-time-exporter.linux64.bin new file mode 100755 index 0000000..df40458 Binary files /dev/null and b/slowlog-generator/response-time/mongo-response-time-exporter.linux64.bin differ diff --git a/slowlog-generator/response-time/mongo-response-time.darwin64.bin b/slowlog-generator/response-time/mongo-response-time.darwin64.bin new file mode 100755 index 0000000..77cb5ff Binary files /dev/null and b/slowlog-generator/response-time/mongo-response-time.darwin64.bin differ diff --git a/slowlog-generator/response-time/mongo-response-time.go b/slowlog-generator/response-time/mongo-response-time.go new file mode 100644 index 0000000..d73b6f0 --- /dev/null +++ b/slowlog-generator/response-time/mongo-response-time.go @@ -0,0 +1,204 @@ +/* +This program uses libpcap to capture MongoDB/TokuMX network traffic and calculate request response time. + +*/ +package main + +import ( + "flag" + "fmt" + "log" + "os" + "strings" + "time" + + "github.com/google/gopacket" + "github.com/google/gopacket/examples/util" + "github.com/google/gopacket/pcap" +) + +var iface = flag.String("i", "eth0", "Interface to read packets from") +var fname = flag.String("r", "", "Filename to read from, overrides -i") +var snaplen = flag.Int("s", 65536, "Snap length (number of bytes max to read per packet") +var tstype = flag.String("timestamp_type", "", "Type of timestamps to use") +var promisc = flag.Bool("promisc", true, "Set promiscuous mode") +var verbose = 1 + +const StderrDumpFrequency = 10 + +// next code all copied from facebookgo/dvara + +// OpCode allows identifying the type of operation: +// +// http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes +type OpCode int32 + +// all data in the MongoDB wire protocol is little-endian. +// all the read/write functions below are little-endian. +func getInt32(b []byte, pos int) int32 { + return (int32(b[pos+0])) | + (int32(b[pos+1]) << 8) | + (int32(b[pos+2]) << 16) | + (int32(b[pos+3]) << 24) +} + +func setInt32(b []byte, pos int, i int32) { + b[pos] = byte(i) + b[pos+1] = byte(i >> 8) + b[pos+2] = byte(i >> 16) + b[pos+3] = byte(i >> 24) +} + +// The full set of known request op codes: +// http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes +const ( + OpReply = OpCode(1) + OpMessage = OpCode(1000) + OpUpdate = OpCode(2001) + OpInsert = OpCode(2002) + Reserved = OpCode(2003) + OpQuery = OpCode(2004) + OpGetMore = OpCode(2005) + OpDelete = OpCode(2006) + OpKillCursors = OpCode(2007) +) + +type messageHeader struct { + // MessageLength is the total message size, including this header + MessageLength int32 + // RequestID is the identifier for this miessage + RequestID int32 + // ResponseTo is the RequestID of the message being responded to. used in DB responses + ResponseTo int32 + // OpCode is the request type, see consts above. + OpCode OpCode +} + +// FromWire reads the wirebytes into this object +func (m *messageHeader) FromWire(b []byte) { + m.MessageLength = getInt32(b, 0) + m.RequestID = getInt32(b, 4) + m.ResponseTo = getInt32(b, 8) + m.OpCode = OpCode(getInt32(b, 12)) +} + +// this map will store the start time for all requests. K:RequestId, v:StartTime +var startTimes = make(map[int32]time.Time) + +// my functions now + +func processReplyPayload(data []byte, header messageHeader) (output float64) { + var elapsed float64 = 0 + start, ok := startTimes[header.RequestID] + if ok { + elapsed = time.Since(start).Seconds() + delete(startTimes, header.RequestID) + } + return elapsed +} + +func stderrDump(rt float64, currentMax float64, lastStderrDump time.Time) { + if rt > currentMax { + currentMax = rt + } + if time.Since(lastStderrDump).Seconds() > StderrDumpFrequency { + lastStderrDump = time.Now() + fmt.Fprintf(os.Stderr, "%s,%20.10f\n", time.Now().Format("15:04:05"), currentMax) + currentMax = 0 + } +} + +func process(src gopacket.PacketDataSource) { + var dec gopacket.Decoder + var ok bool + var currentMax float64 = 0 + var lastStderrDump = time.Now() + if dec, ok = gopacket.DecodersByLayerName["Ethernet"]; !ok { + if dec, ok = gopacket.DecodersByLayerName["Loopback"]; !ok { + log.Fatalln("No decoder named", "Ethernet or Loopback") + } + } + source := gopacket.NewPacketSource(src, dec) + //source.Lazy = *lazy + source.NoCopy = true + for packet := range source.Packets() { + al := packet.ApplicationLayer() + if al != nil { + payload := al.Payload() + if len(payload) < 16 { + continue + } + //fmt.Println("len(payload) == %d", len(payload)) + // IMPORTANT + // This code is unsafe. It performs no check and will fail miserably if the packet is + // not a mongo packet. Pass the proper 'port N' filter to pcap when invoking the program + var header messageHeader + //fmt.Println(payload) + header.MessageLength = getInt32(payload, 0) + header.RequestID = getInt32(payload, 4) + header.ResponseTo = getInt32(payload, 8) + header.OpCode = OpCode(getInt32(payload, 12)) + startTimes[header.RequestID] = time.Now() + //fmt.Printf("OpCode == %v\n", header.OpCode) + switch header.OpCode { + case OpReply: + //fmt.Println("reply") + rt := processReplyPayload(payload, header) + fmt.Printf("%s,%20.10f\n", time.Now().Format("15:04:05"), rt) + stderrDump(rt, currentMax, lastStderrDump) + default: + } + } + } +} + +// this main() is heavily inspired by / is a frankensteined version of https://github.com/google/gopacket/blob/master/examples/pcapdump/main.go + +func main() { + defer util.Run()() + var handle *pcap.Handle + var err error + flag.Parse() + if *fname != "" { + if handle, err = pcap.OpenOffline(*fname); err != nil { + log.Fatal("PCAP OpenOffline error:", err) + } + } else { + // This is a little complicated because we want to allow all possible options + // for creating the packet capture handle... instead of all this you can + // just call pcap.OpenLive if you want a simple handle. + inactive, err := pcap.NewInactiveHandle(*iface) + if err != nil { + log.Fatal("could not create: %v", err) + } + defer inactive.CleanUp() + if err = inactive.SetSnapLen(*snaplen); err != nil { + log.Fatal("could not set snap length: %v", err) + } else if err = inactive.SetPromisc(*promisc); err != nil { + log.Fatal("could not set promisc mode: %v", err) + } else if err = inactive.SetTimeout(time.Second); err != nil { + log.Fatal("could not set timeout: %v", err) + } + if *tstype != "" { + if t, err := pcap.TimestampSourceFromString(*tstype); err != nil { + log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) + } else if err := inactive.SetTimestampSource(t); err != nil { + log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps()) + } + } + if handle, err = inactive.Activate(); err != nil { + log.Fatal("PCAP Activate error:", err) + } + defer handle.Close() + if len(flag.Args()) > 0 { + bpffilter := strings.Join(flag.Args(), " ") + fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter) + if err = handle.SetBPFFilter(bpffilter); err != nil { + log.Fatal("BPF filter error:", err) + } + } + } + for { + process(handle) + } +} diff --git a/slowlog-generator/response-time/mongo-response-time.linux64.bin b/slowlog-generator/response-time/mongo-response-time.linux64.bin new file mode 100755 index 0000000..d508216 Binary files /dev/null and b/slowlog-generator/response-time/mongo-response-time.linux64.bin differ