-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RHEL 5.3 net_if_stats OSError #797
Comments
I can confirm this on RHEL 5.6.
The ioctl SIOCETHTOOL (cmd ETHTOOL_GSET) returns errno 22 EINVAL. ethtool fails too
I think the driver or kernel or device don't support this IOCTL but I'm not sure. |
Does ethtool fails also if run as root?
|
Yes, I run it as root. |
OK fixed. Can you confirm it works? |
Yes, the latest code works for me. Thanks |
I'm still running into this error with Scientific Linux 6.3. 😕 |
To build / try it yourself: git clone the repo, make changes, run |
Thanks for the quick reply.
So, I'm using 4.3.0 (though I have tried 4.2.0), which both seem to have this commit ( 12c7a20 ).
Sure. Let me give that a try. |
In attempting to build it, I ran into test failures. Though I think the test failures may be related to the original problem. I applied this diff on top of this commit ( d539e58 ) in diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
index 19fd14b..d543483 100644
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -497,7 +497,9 @@ psutil_net_if_stats(PyObject* self, PyObject* args) {
strncpy(ifr.ifr_name, nic_name, sizeof(ifr.ifr_name));
// is up?
+ printf("DEBUG 0\n");
ret = ioctl(sock, SIOCGIFFLAGS, &ifr);
+ printf("DEBUG 1\n");
if (ret == -1)
goto error;
if ((ifr.ifr_flags & IFF_UP) != 0)
@@ -507,7 +509,9 @@ psutil_net_if_stats(PyObject* self, PyObject* args) {
Py_INCREF(py_is_up);
// MTU
+ printf("DEBUG 2\n");
ret = ioctl(sock, SIOCGIFMTU, &ifr);
+ printf("DEBUG 3\n");
if (ret == -1)
goto error;
mtu = ifr.ifr_mtu; ...and got these test results. ======================================================================
ERROR: test_ifconfig (test_misc.TestScripts)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_misc.py", line 407, in test_ifconfig
self.assert_stdout('ifconfig.py')
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_misc.py", line 347, in assert_stdout
out = sh(sys.executable + ' ' + exe).strip()
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/__init__.py", line 257, in sh
raise RuntimeError(stderr)
RuntimeError: Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/scripts/ifconfig.py", line 80, in <module>
main()
File "/groups/dudman/home/kirkhamj/psutil/scripts/ifconfig.py", line 59, in main
stats = psutil.net_if_stats()
File "/groups/dudman/home/kirkhamj/psutil/psutil/__init__.py", line 1971, in net_if_stats
return _psplatform.net_if_stats()
File "/groups/dudman/home/kirkhamj/psutil/psutil/_pslinux.py", line 791, in net_if_stats
isup, duplex, speed, mtu = cext.net_if_stats(name)
OSError: [Errno 1] Operation not permitted
======================================================================
ERROR: test_disk_usage (test_posix.TestSystemAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_posix.py", line 330, in test_disk_usage
total, used, free, percent = df(part.device)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_posix.py", line 320, in df
total = int(fields[1]) * 1024
IndexError: list index out of range
======================================================================
ERROR: test_disk_usage (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 2061, in test_disk_usage
os.mkdir(funny_directory)
OSError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_proc_cmdline (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 2008, in test_proc_cmdline
self.copy_file(self.test_executable, funny_executable)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1975, in copy_file
with open(dst, 'wb') as output:
IOError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_proc_cwd (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 2022, in test_proc_cwd
os.mkdir(funny_directory)
OSError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_proc_exe (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1981, in test_proc_exe
self.copy_file(self.test_executable, funny_executable)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1975, in copy_file
with open(dst, 'wb') as output:
IOError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_proc_name (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1995, in test_proc_name
self.copy_file(self.test_executable, funny_executable)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1975, in copy_file
with open(dst, 'wb') as output:
IOError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_proc_open_files (test_process.TestNonUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 2034, in test_proc_open_files
with open(funny_file, 'wb'):
IOError: [Errno 5] Input/output error: '/groups/dudman/home/kirkhamj/tmp/tmpCFjVnp/\xc0\x80'
======================================================================
ERROR: test_net_if_stats (test_linux.TestSystemNetwork)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_linux.py", line 339, in test_net_if_stats
for name, stats in psutil.net_if_stats().items():
File "/groups/dudman/home/kirkhamj/psutil/psutil/__init__.py", line 1971, in net_if_stats
return _psplatform.net_if_stats()
File "/groups/dudman/home/kirkhamj/psutil/psutil/_pslinux.py", line 791, in net_if_stats
isup, duplex, speed, mtu = cext.net_if_stats(name)
OSError: [Errno 1] Operation not permitted
======================================================================
ERROR: test_net_if_stats (test_system.TestSystemAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_system.py", line 620, in test_net_if_stats
nics = psutil.net_if_stats()
File "/groups/dudman/home/kirkhamj/psutil/psutil/__init__.py", line 1971, in net_if_stats
return _psplatform.net_if_stats()
File "/groups/dudman/home/kirkhamj/psutil/psutil/_pslinux.py", line 791, in net_if_stats
isup, duplex, speed, mtu = cext.net_if_stats(name)
OSError: [Errno 1] Operation not permitted
======================================================================
FAIL: test_connections_unix (test_process.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/__init__.py", line 486, in wrapper
return fun(*args, **kwargs)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1067, in test_connections_unix
check(SOCK_STREAM)
File "/groups/dudman/home/kirkhamj/psutil/psutil/tests/test_process.py", line 1058, in check
self.assertEqual(conn.fd, sock.fileno())
AssertionError: 7 != 5
----------------------------------------------------------------------
Ran 299 tests in 8.694s
FAILED (failures=1, errors=10, skipped=93)
make: *** [test] Error 1 |
So, the error is different (Operation not permitted instead of EINVAL). Also, it seems you didn't get any printf(), meaning you probably didn't recompile or the psutil version you're using is not the one you edited but the one you installed, or I don't know. |
As for the unicode related failures, those are different and would probably deserve a separate ticket. It looks like a problem with your system encoding (what is it?). The test fails but it doesn't mean psutil is broken in that regard. psutil would probably break with UnicodeDecode error if you try to pass or handle a non-unicode string via th APIs dealing with (e.g. disk_usage()) or returning a string (e.g. Process.name()), but that's the correct behavior and the fix should be changing the system (or python) encoding, not changing psutil. Or more probably the unicode tests, which should be skipped. It would be interesting to see what happens with python 3 instead of python 2, but even in that case I expect Python not being able to handle the non-ASCII strings and fail with UnicodeDecode/Encode error. |
I see. Sorry. I can open a new issue if that would be preferable.
So, I did get the print statements, but the log was a bit long. I saw them for
Yeah, that seems reasonable. |
Yes please. I will think about whether it's the case to turn that OSError into AccessDenied. With a ticket it'll be more likely I won't forget about it. |
In regards to the Unicode errors, I wasn't really worried about those on a first pass. Though it could be some Python 2 oddities for sure. It appears that |
Do you know what is going on with the |
Opened this issue ( #860 ). |
Mmmm no. Does it happen all the time? If it does then I would say it's a bug. |
After re-reading this it seems the original issue is fixed (here 12c7a20) and the new one is OSError EACCES, which is "legitimate". |
I am referring to the Google Groups post here: https://groups.google.com/forum/#!topic/psutil/Ld4Z00y1-DE
I have tested with psutil 3.1.1 and 3.4.2. The trace below is with psutil 3.1.1.
As requested, I inserted some printf()'s in the code, here's the result:
So execution goes into psutil_net_if_stats, goes inside:
Goes to error:
Returns NULL to _pslinux.py at
isup, duplex, speed, mtu = cext.net_if_stats(name)
Please let me know if you would like me to try something else. Thanks!
The text was updated successfully, but these errors were encountered: