Created
August 27, 2020 13:23
-
-
Save karan9/4bbfdb292dfd343a382f979eaaaf340c to your computer and use it in GitHub Desktop.
A simple mongo shell script to return the connections grouped by the source
This file contains 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] : "Internal"; | |
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