Issue 202 in psutil: Please support GNU/kFreeBSD

5 views
Skip to first unread message

psu...@googlecode.com

unread,
Aug 28, 2011, 7:23:06 PM8/28/11
to psutil-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 202 by matrixhasu: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

Hi,
in debian we have 2 flavors of GNU/kFreeBSD (amd64 and i386) and currently
psutil is unable to detect those OSes since the check is too restrictive.

With the attached patch I'm able to build psutil and start the test suite,
but I currently have 2 hangs:

- test_psutil.py - it hangs at "test_cmdline (__main__.TestCase) ..."
- test/test_memory_leaks.py - it hangs at "test_get_pid_list
(__main__.TestModuleFunctionsLeaks) ..."

I'll see if I'll be able to debug it further in the coming days.

Regards,
Sandro

psu...@googlecode.com

unread,
Aug 28, 2011, 7:27:07 PM8/28/11
to psutil-...@googlegroups.com

Comment #1 on issue 202 by matrixhasu: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

now really attaching the patch

Attachments:
psutil_kfreebsd.diff 1.4 KB

psu...@googlecode.com

unread,
Aug 29, 2011, 5:25:36 PM8/29/11
to psutil-...@googlegroups.com

Comment #2 on issue 202 by matrixhasu: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

For today I've come up to the attached diff: it seems like several tests
are hanging due to get_pid_list() . Currently it's implemented using a
sysctl, but maybe the parameter passed are not the right ones for kFreeBSD.
I've asked on the support IRC channel and they suggest to use a different
approach: kvm_getprocs . the the kvm library interface is provided by most
(of not all?) BSD descendants (f.e. FreeBSD, NetBSD, OpenBSD, DragonFlyBSD,
Darwin, GNU/kFreeBSD too of course :) and Solaris too) - what do you think
about it?

After skipping the hanging tests, there are still a lot of them failing
(I'll try to nail them down in the coming days, if you don't beat me
first ;)):

======================================================================
ERROR: test_connection_fromfd (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 147, in inner
return fun(self, *args, **kwargs)
File "test/test_psutil.py", line 1009, in test_connection_fromfd
for conn in p.get_connections():

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 402, in get_connections
return self._platform_impl.get_connections()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psbsd.py",
line 198, in get_connections
return lsof.get_process_connections()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 184, in get_process_connections
stdout = self.runcmd(cmd)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 253, in runcmd
raise NotImplementedError(msg)
NotImplementedError: this functionnality requires lsof command line utility
to be installed on the system

======================================================================
ERROR: test_get_open_files (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 911, in test_get_open_files
files = p.get_open_files()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 394, in get_open_files
return self._platform_impl.get_open_files()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psbsd.py",
line 191, in get_open_files
return lsof.get_process_open_files()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 142, in get_process_open_files
stdout = self.runcmd(cmd)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 253, in runcmd
raise NotImplementedError(msg)
NotImplementedError: this functionnality requires lsof command line utility
to be installed on the system

======================================================================
ERROR: test_get_open_files2 (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 950, in test_get_open_files2
for path, fd in p.get_open_files():

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 394, in get_open_files
return self._platform_impl.get_open_files()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psbsd.py",
line 191, in get_open_files
return lsof.get_process_open_files()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 142, in get_process_open_files
stdout = self.runcmd(cmd)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 253, in runcmd
raise NotImplementedError(msg)
NotImplementedError: this functionnality requires lsof command line utility
to be installed on the system

======================================================================
ERROR: test_nice (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 851, in test_nice
p.nice = first_nice

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 210, in nice
return self._platform_impl.set_process_nice(value)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psbsd.py",
line 90, in wrapper
raise AccessDenied(self.pid, self._process_name)
AccessDenied: (pid=3099)

======================================================================
ERROR: test_zombie_process (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 1233, in test_zombie_process
meth()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 402, in get_connections
return self._platform_impl.get_connections()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psbsd.py",
line 198, in get_connections
return lsof.get_process_connections()

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 184, in get_process_connections
stdout = self.runcmd(cmd)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 253, in runcmd
raise NotImplementedError(msg)
NotImplementedError: this functionnality requires lsof command line utility
to be installed on the system

======================================================================
ERROR: test_get_pids (_posix.PosixSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_posix.py", line 113, in
test_get_pids
if BSD: return
NameError: global name 'BSD' is not defined

======================================================================
ERROR: test_avail_virtmem (_bsd.BSDSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_bsd.py", line 110, in
test_avail_virtmem
_, sysctl_avail_virtmem = parse_sysctl_vmtotal(result)
File "/home/morph/psutil-read-only/test/_bsd.py", line 33, in
parse_sysctl_vmtotal
total, active = mobj.groups()
AttributeError: 'NoneType' object has no attribute 'groups'

======================================================================
ERROR: test_disks (_bsd.BSDSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_bsd.py", line 146, in test_disks
usage = psutil.disk_usage(part.mountpoint)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/__init__.py",
line 667, in disk_usage
return _psplatform.get_disk_usage(path)

File "/home/morph/psutil-read-only/build/lib.gnukfreebsd-8.2-1-amd64-x86_64-2.6/psutil/_psposix.py",
line 93, in get_disk_usage
st = os.statvfs(path)
OSError: [Errno 2] No such file or directory: '/srv/chroot/sid/home'

======================================================================
ERROR: test_total_virtmem (_bsd.BSDSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_bsd.py", line 89, in
test_total_virtmem
sysctl_total_virtmem, _ = parse_sysctl_vmtotal(result)
File "/home/morph/psutil-read-only/test/_bsd.py", line 33, in
parse_sysctl_vmtotal
total, active = mobj.groups()
AttributeError: 'NoneType' object has no attribute 'groups'

======================================================================
FAIL: test_disk_partitions (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 412, in test_disk_partitions
self.assertTrue(os.path.isdir(disk.mountpoint))
AssertionError

======================================================================
FAIL: test_get_num_threads (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 693, in test_get_num_threads
self.assertEqual(step2, step1 + 1)
AssertionError: 1 != 2

======================================================================
FAIL: test_get_threads (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 708, in test_get_threads
self.assertEqual(len(step2), len(step1) + 1)
AssertionError: 1 != 2

======================================================================
FAIL: test_sys_cpu_times2 (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 331, in test_sys_cpu_times2
self.fail("difference %s" % difference)
AssertionError: difference 1.29999999956e-05

======================================================================
FAIL: test_sys_per_cpu_times2 (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_psutil.py", line 356, in test_sys_per_cpu_times2
self.fail()
AssertionError

======================================================================
FAIL: test_BOOT_TIME (_bsd.BSDSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_bsd.py", line 58, in
test_BOOT_TIME
self.assertEqual(btime, psutil.BOOT_TIME)
AssertionError: 1314001403 != 1314001408.0

======================================================================
FAIL: test_process_create_time (_bsd.BSDSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/morph/psutil-read-only/test/_bsd.py", line 127, in
test_process_create_time
self.assertEqual(start_ps, start_psutil)
AssertionError: 'Mon Aug 29 21:01:47 2011' != 'Mon Aug 29 21:01:48 2011'

----------------------------------------------------------------------
Ran 82 tests in 2.652s

FAILED (failures=7, errors=9)
/usr/lib/python2.6/atexit.py:24: RuntimeWarning:
TestCase.test_get_connections_all was skipped
func(*targs, **kargs)
/usr/lib/python2.6/atexit.py:24: RuntimeWarning:
TestCase.test_get_connections was skipped
func(*targs, **kargs)
/usr/lib/python2.6/atexit.py:24: RuntimeWarning: Couldn't run limited user
tests (super-user privileges are required)
func(*targs, **kargs)

Additionally, after the test suite completes, the terminal control is not
returned, and not even Ctrl-C works (Ctrl-Z + kill %x does the trick).

Attachments:
psutil_kfreebsd2.diff 7.2 KB

psu...@googlecode.com

unread,
Aug 29, 2011, 5:53:59 PM8/29/11
to psutil-...@googlegroups.com

Comment #3 on issue 202 by g.rod...@gmail.com: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

I'll try to reimplement get_pid_list() by using this kvm_getprocs() to fix
get_pid_list() related failures and let you know once done.

As for test_get_num_threads and test_get_threads failures you might try to
add a time.sleep(.1) call here:
http://code.google.com/p/psutil/source/browse/trunk/test/test_psutil.py#698
...and here:
http://code.google.com/p/psutil/source/browse/trunk/test/test_psutil.py#712

Open files/connections failures require lsof to be installed (hopefully
I'll manage to re-implement that part in C and finally get rid of the
stinky lsof python parser).

Other BSD-specific tests such as test_avail_virtmem and others just need to
be adapted a bit or simply be skipped if there's a reliable way to detect
we're on GNU/kFreeBSD (sys.platform?).

As for test_sys_cpu_times* I honestly have no clue. I have the code in
front of me and I don't understand why it fails (it shouldn't).

Generally speaking, these failures are not that terrible and suggest that
adding support for these arcane system I've never heard of might worth the
effort. =)

> st = os.statvfs(path)
> OSError: [Errno 2] No such file or directory: '/srv/chroot/sid/home'

This is interesting. Maybe it worths opening a report against
bugs.python.org.


psu...@googlecode.com

unread,
Sep 16, 2011, 3:03:15 PM9/16/11
to psutil-...@googlegroups.com
Updates:
Labels: -Type-Defect Type-Enhancement

Comment #5 on issue 202 by jlo...@gmail.com: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

(No comment was entered for this change.)

psu...@googlecode.com

unread,
Jan 29, 2013, 9:52:34 AM1/29/13
to psutil-...@googlegroups.com

Comment #6 on issue 202 by m...@akamit.com: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

python -c "import sys; print sys.platform"
openbsd5

Complete output from command python setup.py egg_info:
platform openbsd5 is not supported


psu...@googlecode.com

unread,
Jan 29, 2013, 9:53:55 AM1/29/13
to psutil-...@googlegroups.com

Comment #7 on issue 202 by g.rodola: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

Yes, OpenBSD is currently not supported.

psu...@googlecode.com

unread,
Jun 2, 2013, 4:12:35 PM6/2/13
to psutil-...@googlegroups.com

Comment #8 on issue 202 by landry.b...@gmail.com: Please support
GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

Mozilla imported psutil as part of the buildsystem & mach, so other real
bsds (and debian/kfreebsd) ought to be supported. What should be the way to
go, implement a backend for each of them, or try to stash everything in the
existing bsd backend, with if/switches wrt the family ?

Some work was done a while ago for an older version (0.4.1) in
https://github.com/jasperla/openbsd-wip/blob/master/sysutils/py-psutil/patches/patch-psutil__psbsd_py,
i'll try to reapply that on top of master.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

psu...@googlecode.com

unread,
Jun 2, 2013, 4:24:17 PM6/2/13
to psutil-...@googlegroups.com

Comment #9 on issue 202 by g.rodola: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

Glad to hear Mozilla adopted psutil!

In order to add support for a new OS/architecture one should usually file
an issue on the bug tracker so that we can keep track of the progress and
provide a patch.

Alternatively I can give you commit privileges against the Mercurial
repository and create a separate branch where you can develop and once
everything is ready merge it back into trunk.

This issue is for GNU/kFreeBSD so if you're willkng to work on adding
OpenBSD support please file a separate issue and we'll keep discussing
there.

Thanks,

- Giampaolo

psu...@googlecode.com

unread,
May 26, 2014, 11:15:04 AM5/26/14
to psutil-...@googlegroups.com

Comment #10 on issue 202 by g.rodola: Please support GNU/kFreeBSD
http://code.google.com/p/psutil/issues/detail?id=202

psutil has been migrated from Google Code to Github (see:
http://grodola.blogspot.com/2014/05/goodbye-google-code-im-moving-to-github.html).
Please do NOT reply here but use this instead:
https://github.com/giampaolo/psutil/issues/202

psu...@googlecode.com

unread,
Jan 2, 2015, 11:27:33 AM1/2/15
to psutil-...@googlegroups.com

Comment #11 on issue 202 by g.rodola: Please support GNU/kFreeBSD
https://code.google.com/p/psutil/issues/detail?id=202

Has there been any progress on this front?
Reply all
Reply to author
Forward
0 new messages