psutil.error.AccessDenied, using psutil 0.5.1 #8

Open
ming-kernel opened this Issue Aug 13, 2012 · 4 comments

Comments

Projects
None yet
4 participants

v84-207:~ ming$ monner --target-output /dev/null -c wget http://www.google.com
CPU (%) Memory RSS (mb) Network in (kb) Network out (kb) Disk in (kb) Disk out (kb)
Traceback (most recent call last):
File "/usr/local/bin/monner", line 8, in
load_entry_point('monner==0.4.1', 'console_scripts', 'monner')()
File "/Library/Python/2.7/site-packages/monner-0.4.1-py2.7.egg/EGG-INFO/scripts/monner.py", line 115, in main

File "/Library/Python/2.7/site-packages/monner-0.4.1-py2.7.egg/EGG-INFO/scripts/monner.py", line 67, in go

File "/Library/Python/2.7/site-packages/monner-0.4.1-py2.7.egg/EGG-INFO/scripts/monner.py", line 54, in init_stats

File "/Library/Python/2.7/site-packages/monner-0.4.1-py2.7.egg/EGG-INFO/scripts/monner.py", line 12, in get_mem_rss

File "/Library/Python/2.7/site-packages/monner-0.4.1-py2.7.egg/EGG-INFO/scripts/monner.py", line 10, in

File "build/bdist.macosx-10.8-intel/egg/psutil/init.py", line 498, in get_memory_info
File "build/bdist.macosx-10.8-intel/egg/psutil/_psosx.py", line 113, in wrapper
psutil.error.AccessDenied: (pid=995)

mwurth commented Aug 13, 2012

Same Issue here.
Check also:
https://code.google.com/p/psutil/issues/detail?id=215

Although monner doesn't work as root either.

Owner

colinhowe commented Aug 13, 2012

Is it the same error as root?

mwurth commented Aug 13, 2012

As root:

$sudo monner --target-output /dev/null -c wget http://www.google.com
Password:
CPU (%) Memory RSS (mb) Network in (kb) Network out (kb)    Disk in (kb)    Disk out (kb)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner", line 8, in <module>
    load_entry_point('monner==0.4.1', 'console_scripts', 'monner')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 115, in main
    interval=args.interval, fields=args.fields)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 70, in go
    output_stats(target.pid, fields)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 49, in output_stats
    for name, value in gather_stats(pid, fields)]
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 45, in gather_stats
    yield name, fn(pid)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 12, in get_mem_rss
    return get_mem(pid).rss / MEGABYTES
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 10, in <lambda>
    get_mem = lambda pid: psutil.Process(pid).get_memory_info()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/__init__.py", line 498, in get_memory_info
    return self._platform_impl.get_memory_info()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/_psosx.py", line 113, in wrapper
    raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=55035)

not as root:

monner --target-output /dev/null -c wget http://www.google.com
CPU (%) Memory RSS (mb) Network in (kb) Network out (kb)    Disk in (kb)    Disk out (kb)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner", line 8, in <module>
    load_entry_point('monner==0.4.1', 'console_scripts', 'monner')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 115, in main
    interval=args.interval, fields=args.fields)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 67, in go
    init_stats(target.pid)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 54, in init_stats
    fn(pid)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 12, in get_mem_rss
    return get_mem(pid).rss / MEGABYTES
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/monner.py", line 10, in <lambda>
    get_mem = lambda pid: psutil.Process(pid).get_memory_info()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/__init__.py", line 498, in get_memory_info
    return self._platform_impl.get_memory_info()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psutil/_psosx.py", line 113, in wrapper
    raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=55078)

Same problem here for MacOS

Tried psutil and it is working properly:

>>> import psutil
>>> psutil.get_pid_list()
[3959, 3846, 3845, 3843, 3814, 3813, ...]
>>> p = psutil.Process(3959)
>>> p.name
'Python'
>>> p.get_memory_info()
meminfo(rss=7110656L, vms=2500726784L)

I think you should skip the first pid in the pid_list.

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