Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to discover which ip addresses are connected to the db?

Tags:

mongodb

I can determine the current number of connections by

db.serverStatus().connections

but all that gives me is the current number of connections. Is there anywhay to determine which ips are connected and which connection number they have been assigned to?

like image 399
Alexander Avatar asked Mar 30 '12 14:03

Alexander


People also ask

How do I find my MongoDB IP address?

You can find the details around the MongoDB server hostname in the connection string your application uses to connect to the database (See this docs page for details - https://docs.mongodb.com/manual/reference/connection-string/).

How do I find the IP addresses on my network using CMD?

First, click on your Start Menu and type cmd in the search box and press enter. A black and white window will open where you will type ipconfig /all and press enter. There is a space between the command ipconfig and the switch of /all. Your ip address will be the IPv4 address.

How to find all IP addresses on a network?

How to Find All IP Addresses on a Network Open the command prompt. Enter the command “ipconfig” for Mac or “ifconfig” on Linux. Your computer will then display its own IP address, subnet... Next, input the command “arp -a”. ARP stands for “Address Resolution Protocol,” and the “-a” appendage of the ...

Can IP addresses be traced?

In the same way that you can track other people’s IP addresses, they can track the IP addresses for your devices. Obviously, this is a privacy concern for some people, so if you want to hide your IP address information, you should use a virtual private network (VPN). How Easy Is It to Trace an IP Address?

How long does it take to find the IP address?

It only takes a few minutes to determine the IP addresses of the network hardware on your network. Find the default gateway IP address for your computer's network connection. In almost all situations, this will be the private IP address for your router, the most external point on your local network.

Why do I see more than one IP address before the router?

If you see more than one IP address before the router's IP address, you must have more than one network device between your computer and the router. If you see only the router's IP address, then you don't have any managed network hardware between your computer and router, though you might have simple devices like hubs and unmanaged switches.


2 Answers

From mongo shell, this will print client IP:port, along with connection ID:

db.currentOp(true).inprog.forEach(function(d){if(d.client)print(d.client, d.connectionId)})

Note: passing true to db.currentOp() shows all connections (including idle). The docs have more examples on filtering connections, see: db.currentOp reference and currentOp output fileds with descriptions.

like image 136
Gary Avatar answered Oct 16 '22 18:10

Gary


From mongo shell run db.currentOp() to show all active connections or db.currentOp(true) to show all connections.

like image 36
geakie Avatar answered Oct 16 '22 16:10

geakie