Created
October 15, 2019 08:36
-
-
Save bfgits/c222189be7148596f5a7018b6b5f0996 to your computer and use it in GitHub Desktop.
mongodb get current user IPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.currentOp(true).inprog.reduce((accumulator, connection) => { ipaddress = connection.client ? connection.client.split(":")[0] : "unknown"; accumulator[ipaddress] = (accumulator[ipaddress] || 0) + 1; accumulator["TOTAL_CONNECTION_COUNT"]++; return accumulator; }, { TOTAL_CONNECTION_COUNT: 0 }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment