Hari Krishnan
Hari Krishnan

Reputation: 1166

get process name for mongodb open connections

I need to know process/file name of the open MongoDB connections.

for example, assume there are files called F1,F2 ..., Fn using Connection pool to get mongodb connection. each running in parallel in different process.

Is there any way to get file name which having open connection to mongodb.

Because, I am on mission to reduce number of open mongodb connections.

when I did below query,

db.serverStatus().connections

It giving me current consumed connections count, available count. But I need filenames which opened connection to optimize.

stack: python,django,some server running in apache, mongodb, pymongo

Upvotes: 3

Views: 2214

Answers (2)

Hari Krishnan
Hari Krishnan

Reputation: 1166

I figured out myself how to know more about connections information.

db.currentOp(true).inprog

Above command will give all current connections information in array. you can see information such as client ip,whether its active or not,connection id,operation type and everything.

Upvotes: 2

Raunak Jhawar
Raunak Jhawar

Reputation: 1651

You can get the connection details in the most rudimentary form using a quick shell command such as

ps -eAf | grep mongo

If you use this command on the host running your mongod process. Essentially you can make a note of all active pid's and take corrective actions

Upvotes: 1

Related Questions