Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Oct 2012 01:54:59 +0100
From:      Jan Beich <jbeich@tormail.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/172802: [patch] sysutils/py-psutil: get_swap_mem() returns garbage
Message-ID:  <1TOIZj-000Gj3-QW@internal.tormail.org>
Resent-Message-ID: <201210170140.q9H1e0L5031414@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         172802
>Category:       ports
>Synopsis:       [patch] sysutils/py-psutil: get_swap_mem() returns garbage
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 17 01:40:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Jan Beich
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
$ swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ada1p3       3025940        0  3025940     0%
>Description:
>How-To-Repeat:
>Fix:
--- swap.diff begins here ---
Index: sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c
===================================================================
--- sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	(revision 305988)
+++ sysutils/py-psutil/files/patch-psutil-_psutil_bsd.c	(working copy)
@@ -1,5 +1,21 @@
 --- psutil/_psutil_bsd.c.orig	2012-08-16 23:07:37.000000000 +0800
 +++ psutil/_psutil_bsd.c	2012-09-27 14:50:20.843763756 +0800
+@@ -15,6 +15,7 @@
+ #include <stdio.h>
+ #include <signal.h>
+ #include <fcntl.h>
++#include <paths.h>
+ #include <sys/types.h>
+ #include <sys/sysctl.h>
+ #include <sys/param.h>
+@@ -629,6 +636,7 @@ get_swap_mem(PyObject* self, PyObject* a
+     unsigned int swapin, swapout, nodein, nodeout;
+     size_t size = sizeof(unsigned int);
+ 
++    kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open");
+     if (kvm_getswapinfo(kd, kvmsw, 1, 0) < 0) {
+         PyErr_SetString(PyExc_RuntimeError, "kvm_getswapinfo failed");
+         return NULL;
 @@ -1376,8 +1376,10 @@
              strlcat(opts, ",noclusterr", sizeof(opts));
          if (flags & MNT_NOCLUSTERW)
--- swap.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
 >>> import psutil
 >>> psutil.swap_memory()
 swap(total=32768, used=134974668800, free=-134974636032, percent=411910000.0, sin=0, sout=2208534528)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1TOIZj-000Gj3-QW>