Getting list of IP addresses of Sessions

I’m trying to get a list of the IP address in use for all open sessions of a certain project. Using system.util.getSessionInfo() only shows the device name, not the IP address. I currently get a list of “raspberrypi” instead.

This has come up a number of times in the past, but currently it seems intentional.

The column in the returned dataset holds the self-reported hostname the client sent when it first logged in.

Is this a security issue? Any other way to get the info?

I’m not sure what the reasoning on this is. Each client get use system.net.getExternalIpAddress() though.

1 Like

This isn’t going to work for what I need. I have several dozen client stations that all run the same project. Each station has a static ip address. I want to monitor when each station is active along with total active etc, which I was going to do via the static IP address. Since the getSessionInfo() does not return the IP address I’m wondering what else to do.

I’ve tried writing to a tag based on logging in and logging out, but for some reason, it will miss a tag write every now and then. I will have a station or two that shows logged in, but upon inspection, the worker is logged out. Therefore the tag write did not happen.

Any suggestions?

Why not change the hostname of each pi to something unique?

1 Like

You could always run this script as part of the Session startUp script:

import socket
device_ip = socket.gethostbyname(socket.gethostname())

That returns the device IP for my workstations, though I don’t have a pi to test on.

1 Like

I will play with that a bit and see what happens. I like Jordan’s suggestion too. I will try both. Thanks!

UPDATE:
Looks like changing the host name is the way that works best for my situation. I can’t believe I didn’t think of that. Appreciate the suggestions!

1 Like