Skip to content

Instantly share code, notes, and snippets.

@bfgits
Created October 15, 2019 08:36
Show Gist options
  • Save bfgits/c222189be7148596f5a7018b6b5f0996 to your computer and use it in GitHub Desktop.
Save bfgits/c222189be7148596f5a7018b6b5f0996 to your computer and use it in GitHub Desktop.
mongodb get current user IPs
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