Closed GoogleCodeExporter closed 8 years ago
Is this report about get_connections() not reporting UNIX-socket connections?
In that case that's already tracked in issue 216.
Original comment by g.rodola
on 17 Jun 2012 at 9:42
I didn't know about #216. That tackles the unix domain socket issue.
It's a report about psutil not showing fds it doesn't understand. For example
get_open_files() ignores all files that are not regular files: named pipes,
block devices, char devices. The check os.path.isfile() in
_pslinux.Process.get_open_files() skips the char device /dev/pts/1.
os.path.exists() should be sufficient.
I'm not sure how to handle anon_inode:[eventpoll]. The FD is created by the
epoll() syscall.
Original comment by tiran79
on 27 Jun 2012 at 10:06
get_open_files() is supposed to return *regular* files only, hence the
os.path.isfile() check.
/dev/pts/1 is a terminal fd so it's ok to skip it.
If we want to return information about *all* fds that should be done as a
separate get_open_fds() method mimicking lsof but problem is how to represent
the data and how to conciliate the differences between UNIX platforms, which,
IMO, it's likely to be impossible.
Original comment by g.rodola
on 28 Jun 2012 at 11:58
IMHO the limitation is too strict and removes useful information from the
output. All this files have a fs entry but are not listed
* open directories used by the newly introduced *at() functions like openat()
* char and block devices
* named fifos
* sockets
Deleted are also skipped although they are still opened. Deleted files aren't
correctly handles by psutil, too. Consider the case fd = open(name),
unlink(name), touch(name). psutil returns true for fd but the fd refers to a
different file. You have to compare st_dev and st_ino of fstat(fd) with
stat(name) to detect the case.
Proposal:
* modify signature of the function to get_open_files(kind='REG', deleted=False)
* modify returned named tuple to contain kind (REG, DIR, SOCK, BLK, CHR, FIFO)
and deleted (bool) flag
lsof and kinfo_getfile return the file type information.
I can create a patch if you like my idea.
Original comment by tiran79
on 1 Jul 2012 at 3:27
Point is how to represent the different fd types, which brings to the question:
what 'fields' the returning namedtuple should provide?
Judging from lsof output we should provide:
FD, TYPE, DEVICE, SIZE/OFF, NODE, NAME
...but if you look at hot lsof output is represented you'll notice how
depending on the fd type it examines, certain fields are sometimes represented
with a number, other times with a string.
That alone suggests that this is a feature which is hard to translate in a
consistent and usable API, and I'm not even mentioning the differences between
UNIX flavors.
> All this files have a fs entry but are not listed
> [...]
> * sockets
IMO, sockets are fine being treated as a different entity, as we're currently
doing with get_connections(), mostly because they have a local and remote
address field, which is not present in other fd types.
Feel free to attempt to write a patch for Linux if you want, but IMO pretty
soon you'll realize how difficult it is to come up with a consistent API to
express the data you pull out from the OS.
Original comment by g.rodola
on 2 Jul 2012 at 12:54
Closing this one as won't fix.
Feel free to reopen it if you can come up with a consistent proposal addressing
the problems outlined above.
Original comment by g.rodola
on 13 Dec 2012 at 2:38
Original issue reported on code.google.com by
tiran79
on 15 Jun 2012 at 11:55Attachments: