Database Reference
In-Depth Information
db.currentOp()
[ {
"opid" : "shard-1-test-rs:1232866",
"active" : true,
"lockType" : "read",
"waitingForLock" : false,
"secs_running" : 11,
"op" : "query",
"ns" : "docs.foo",
"query" : {
"$where" : "this.n > 1000"
},
"client_s" : "127.0.0.1:38068",
"desc" : "conn"
} ]
A particularly slow query is at work here. You can see that the query has been running
for a whopping eleven seconds and that like all queries, it's taken a read lock. If this
operation is problematic, you might want to investigate its source by looking at the
client field. Alas, this is a sharded cluster, so the source is a mongos process, as indi-
cated by the field name client_s . If you need to kill the operation, you can pass the
opid to the db.killOp() method:
db.killOp("shard-1-test-rs:1232866")
{
"op" : "shard-1-test-rs:1233339",
"shard" : "shard-1-test-rs",
"shardid" : 1233339
}
If you'd like to see a verbose listing of all the operations running on the current
MongoDB server, you can issue the following virtual command:
db['$cmd.sys.inprog'].find({$all: 1})
MONGOSTAT
The db.currentOp() method shows only the operations queued or in progress at a
particular moment in time. Similarly, the serverStatus command provides a point-in-
time snapshot of various system fields and counters. But sometimes you need a view of
the system's real-time activity, and that's where mongostat comes in. Modeled after
iostat and other similar tools, mongostat polls the server at a fixed interval and dis-
plays an array of statistics, from the number of inserts per second to the amount of res-
ident memory, to the frequency of B-tree page misses.
You can invoke the mongostat command on localhost , and the polling will occur
once a second:
$ mongostat
It's also highly configurable, and you can start it with --help to see all the options.
One of the more notable features is cluster discovery; when you start mongostat with
the --discover option, you can point it to a single node, and it'll discover the
Search WWH ::




Custom Search