mongo --eval "JSON.stringify(db.currentOp(true))" | \
tail -n +3 | \
jq -r .inprog[].client | \
sed 's/\(.*\):.*/\1/' \
| sort | uniq -c | sort -nr
  • dump connection information in standard JSON format
  • remove MongoDB header
  • extract IP:port as a list
  • trim port
  • sort IPs by freqencies