
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
How to get connected clients in MongoDB?
To get connected clients in MongoDB, use currentOp() with the set value to true and you need to iterate array result set with the help of field client. Let us first implement currentOp
> db.currentOp(true)
Following is the output. Here the client is 127.0.0.1 since we are using localhost. The output displays all the connected clients
{ "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 }
- Related Articles
- How to get Wi-Fi connected state in android?
- Difference between Thin Clients and Thick Clients
- How to get connected remote desktop users on computers using PowerShell?
- How to get documents by tags in MongoDB?
- How to get a saved object in MongoDB?
- How to get values of cursor in MongoDB?
- How to get the load balancers connected to the Azure VM using PowerShell?
- How to get embedded data in a MongoDB document?
- How to get element with max id in MongoDB?
- How to get the last N records in MongoDB?
- How to get data of array intersection in MongoDB?
- How can I force clients to refresh JavaScript files?
- How to Communicate Your Progress to Clients and/or Stakeholders?
- Using clients in SAP ERP
- How to get array from a MongoDB collection?

Advertisements