Skip to content
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

PermissionError/OSError when starting glances #885

Closed
jakirkham opened this issue Jul 12, 2016 · 9 comments
Closed

PermissionError/OSError when starting glances #885

jakirkham opened this issue Jul 12, 2016 · 9 comments
Milestone

Comments

@jakirkham
Copy link
Contributor

jakirkham commented Jul 12, 2016

When trying to start up glances, it crashes due to a PermissionError or OSError (on Python 2.x). Traceback is shown below. I have tried a few different versions of glances and psutil. If I revert back to psutil version 2.2.1, the issue goes away. Though my guess is that is only because this code path is not present there. It is probably possible to get around this issue by running with sudo. However, that is really not an option for the machine I'm trying to use this on. I used conda to install these from conda-forge. So, it should be reproducible that way.

$ lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: Scientific
Description:    Scientific Linux release 6.3 (Carbon)
Release:    6.3
Codename:   Carbon
$ glances -V
Glances v2.6.2 with psutil v4.3.0
$ glances 
Traceback (most recent call last):
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/bin/glances", line 6, in <module>
    sys.exit(glances.main())
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/__init__.py", line 130, in main
    args=core.get_args())
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/standalone.py", line 67, in __init__
    self.stats.update()
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/stats.py", line 154, in update
    self._plugins[p].update()
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/plugins/glances_plugin.py", line 658, in wrapper
    ret = fct(*args, **kw)
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/plugins/glances_network.py", line 90, in update
    netstatus = psutil.net_if_stats()
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/psutil/__init__.py", line 1961, in net_if_stats
    return _psplatform.net_if_stats()
  File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/psutil/_pslinux.py", line 791, in net_if_stats
    isup, duplex, speed, mtu = cext.net_if_stats(name)
PermissionError: [Errno 1] Operation not permitted
@nicolargo
Copy link
Owner

I think that the bug should be reported to the PsUtil community. Nevertheless, i just code a work around on the DEVELOP branch.

I don't know if you can test it on your system... (i do not use Anaconda). Or you can try to patch the /groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/plugins/glances_network.py file by changing the except line:

        try:
            netstatus = psutil.net_if_stats()
        except:
            pass

@nicolargo nicolargo added the bug label Jul 12, 2016
@nicolargo nicolargo added this to the 2.7 milestone Jul 12, 2016
@jakirkham
Copy link
Contributor Author

Happy to try any proposed fixes. Also, if this needs to be referred upstream, happy to do that as well. Though I'm not exactly sure what we want to ask to have changed at this point.

@nicolargo
Copy link
Owner

@jakirkham just open an issue on the PsUtil Github and copy/paste the result of the following command line on your system:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.net_if_stats()
{'lo': snicstats(isup=True, duplex=0, speed=0, mtu=65536), 'docker0': snicstats(isup=True, duplex=0, speed=0, mtu=1500), 'wlan0': snicstats(isup=True, duplex=0, speed=0, mtu=1500)}

Also add a link to the current Glances issue.

Thanks !

@jakirkham
Copy link
Contributor Author

Sorry running into some issues with things not getting update correctly in the GitHub interface.

@jakirkham
Copy link
Contributor Author

jakirkham commented Jul 12, 2016

So, I had initially discussed this in there issue tracker before raising it here. This amounted to opening this issue ( giampaolo/psutil#860 ), which is the same problem, but the request is different. From the linked discussion in that issue, I gathered that this particular option needs sudo to run though did not confirm that specifically.

If this is an issue where it does resolve to needing to run sudo glances, I won't be able to do that on the target machine. Would it be reasonable to have a fallback where glances simply warns the user that some options will not be available instead of outright failure? I'm not sure I understand why sudo should be required, but maybe a similar request is appropriate for psutil. I just don't have good working knowledge of what this step is doing.

@nicolargo
Copy link
Owner

The patch 2b87295 will hide the error message and disable the function if Glances is not used with sudo. It is strange because, i do not have any issue on my test bed (Redhat and CentOS OS).

@jakirkham
Copy link
Contributor Author

So, you are using Docker to test, correct? Are you root in your test Docker container? If so, you may be able to reproduce this by creating a new user that has ordinary permissions and switching to it first. Just a thought.

@nicolargo
Copy link
Owner

Nope, i do not use Docker to test Glances.

@jakirkham
Copy link
Contributor Author

Sorry, I thought I saw a reference to Docker in the snippet above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants