Reputation: 401
I checked number of connections to my MongoDB server using db.serverStatus().connections
and got this result:
matrix:PRIMARY> db.serverStatus().connections
{
"current" : 45,
"available" : 51155,
"totalCreated" : NumberLong(1886475)
}
However when I tried to check which clients are connected by following this answer, I got this result:
$ sudo lsof | grep mongod | grep TCP | wc -l
5390
Which one of the above is correct and why is there a huge difference in the two outputs?
Upvotes: 1
Views: 611
Reputation: 401
This was just a problem with the lsof
output. lsof
includes the offset of the file in the output: https://unix.stackexchange.com/questions/60422/how-to-interpret-this-output-of-lsof-command. So there are multiple entries for the same connection in the output. Once I removed that, number of clients from lsof was same as that reported by db.serverStatus().connections
.
Upvotes: 2