MongoDB에서 연결된 클라이언트를 얻으려면 true로 설정된 값과 함께 currentOp()를 사용하고 필드 클라이언트의 도움으로 배열 결과 집합을 반복해야 합니다. 먼저 currentOp를 구현해 보겠습니다.
> db.currentOp(true)
다음은 출력입니다. 여기에서 클라이언트는 localhost를 사용하기 때문에 127.0.0.1입니다. 출력은 연결된 모든 클라이언트를 표시합니다.
{ "inprog" : [ { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "conn1", "connectionId" : 1, "client" : "127.0.0.1:61787", "appName" : "MongoDB Shell", "clientMetadata" : { "application" : { "name" : "MongoDB Shell" }, "driver" : { "name" : "MongoDB Internal Client", "version" : "4.0.5" }, "os" : { "type" : "Windows", "name" : "Microsoft Windows 10", "architecture" : "x86_64", "version" : "10.0 (build 17134)" } }, "active" : true, "currentOpTime" : "2019-03-30T05:13:34.296+0530", "opid" : 12538, "lsid" : { "id" : UUID("da370b0f-093a-45f3-b1fe-697daca8ccd2"), "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=") }, "secs_running" : NumberLong(0), "microsecs_running" : NumberLong(160815), "op" : "command", "ns" : "admin.$cmd.aggregate", "command" : { "currentOp" : 1, "$all" : true, "lsid" : { "id" : UUID("da370b0f-093a-45f3-b1fe-697daca8ccd2") }, "$db" : "admin" }, "numYields" : 0, "locks" : { }, "waitingForLock" : false, "lockStats" : { } }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "LogicalSessionCacheRefresh", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "SessionKiller", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "TTLMonitor", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "free_mon", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "freemon-0", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "startPeriodicThreadToAbortExpiredTransactions", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "WTCheckpointThread", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "ftdc", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "WTJournalFlusher", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "clientcursormon", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" }, { "host" : "DESKTOP-QN2RB3H:27017", "desc" : "initandlisten", "active" : false, "currentOpTime" : "2019-03-30T05:13:34.296+0530" } ], "ok" : 1 }